From c8f3eae9649ef9cd1e66aab54439088522c56e8e Mon Sep 17 00:00:00 2001 From: Solebull Date: Tue, 3 Dec 2019 12:15:03 +0100 Subject: [PATCH] Handle Create button event --- mods/factions_ui/init.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mods/factions_ui/init.lua b/mods/factions_ui/init.lua index adc3903..e343dd5 100644 --- a/mods/factions_ui/init.lua +++ b/mods/factions_ui/init.lua @@ -33,11 +33,7 @@ get_factions_ui = function(faction_id) fname = list[faction_id]; local faction = factions.get_faction(fname) power = faction.power..'/'..faction.maxpower - - --- members = #faction.players members = fac_player_count(faction) - leader = faction.leader or faction.players[0] or "---" if faction.join_free then iotext = "false" @@ -55,7 +51,7 @@ get_factions_ui = function(faction_id) label[0,1;Invite-only :] label[2,1;]]..iotext..[[] textlist[0,2;7,4;faclist;]]..facnames..[[] field[5,1;2,1;name;Nouvelle faction :;newFaction] - button[7,1;2,1;name;Créer] + button[5,3;2,1;name;Créer] ]] return formspec end @@ -75,9 +71,12 @@ sfinv.register_page("sfinv:factions_ui", { on_player_receive_fields = function(self, player, context, fields) local event = minetest.explode_textlist_event(fields.faclist) if event.type == "CHG" then + -- We're selecting a new faction name context.faction_idx= event.index sfinv.set_player_inventory_formspec(player, context) - + elseif event.type == "INV" then + -- We clicked the Create button + print("Creating new faction") end end