Profile: add 'X' button to close the formspec

This commit is contained in:
marco_a 2023-12-08 00:31:44 +01:00
parent 77a8e8a008
commit 2297df19c8
2 changed files with 7 additions and 3 deletions

View File

@ -5,6 +5,7 @@ local function get_formspec() end
function block_league.show_profile(p_name)
minetest.get_player_by_name(p_name):get_meta():set_string("bl_profile_elem_active", "")
minetest.show_formspec(p_name, "block_league:profile", get_formspec(p_name))
end
@ -187,6 +188,7 @@ function get_formspec(p_name)
-- parte destra
"container[13.88,0]",
"image_button[5.2,0;0.8,0.8;bl_gui_profile_close.png;close;;true;false;]",
right_elem,
"container_end[]"
}
@ -205,12 +207,14 @@ end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "block_league:profile" then return end
if fields.quit then
player:get_meta():set_string("bl_profile_elem_active", "")
return end
if fields.quit then return end
local p_name = player:get_player_name()
if fields.close then
minetest.close_formspec(p_name, "block_league:profile")
return end
if fields.weap then
player:get_meta():set_string("bl_profile_elem_active", string.sub(block_league.get_player_weapons(p_name)[tonumber(fields.weap)], 14, -1))
elseif fields.skill then

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B