Got faction name in button event

master
Solebull 2019-12-03 12:53:03 +01:00
parent c8f3eae964
commit 5fa98b20fe
3 changed files with 46 additions and 4 deletions

View File

@ -254,6 +254,7 @@ It's really fast. May be used on a website, to show the actual map.
Maybe used with https://github.com/octacian/spawnpoint Maybe used with https://github.com/octacian/spawnpoint
**** TODO [feature_FactionUI] Try to add a factions UI **** TODO [feature_FactionUI] Try to add a factions UI
:LOGBOOK: :LOGBOOK:
CLOCK: [2019-12-03 mar. 12:04]--[2019-12-03 mar. 12:42] => 0:38
CLOCK: [2019-11-19 mar. 09:06]--[2019-11-19 mar. 09:51] => 0:45 CLOCK: [2019-11-19 mar. 09:06]--[2019-11-19 mar. 09:51] => 0:45
CLOCK: [2019-11-09 sam. 06:47]--[2019-11-09 sam. 07:05] => 0:18 CLOCK: [2019-11-09 sam. 06:47]--[2019-11-09 sam. 07:05] => 0:18
CLOCK: [2019-10-31 jeu. 05:31]--[2019-10-31 jeu. 05:42] => 0:11 CLOCK: [2019-10-31 jeu. 05:31]--[2019-10-31 jeu. 05:42] => 0:11
@ -288,7 +289,10 @@ It's really fast. May be used on a website, to show the actual map.
...etest/games/minetest-pvp/mods/redtrees/sakuragi/init.lua ...etest/games/minetest-pvp/mods/redtrees/sakuragi/init.lua
- [X] Just add a create button with a name textedit - [X] Just add a create button with a name textedit
xpro/sfinv.lua calls a register_page function xpro/sfinv.lua calls a register_page function
- [ ] Handle new faction button event - [-] Handle new faction button event
- [X] Must get the faction name from lineedit
- [ ] Finally create the faction
- [ ] Must correctly place 'Créer' button
**** DONE Trying to install mintest on the raspberry **** DONE Trying to install mintest on the raspberry
CLOCK: [2019-06-25 mar. 23:07]--[2019-06-25 mar. 23:53] => 0:46 CLOCK: [2019-06-25 mar. 23:07]--[2019-06-25 mar. 23:53] => 0:46
CLOCK: [2019-06-25 mar. 04:10]--[2019-06-25 mar. 06:15] => 2:05 CLOCK: [2019-06-25 mar. 04:10]--[2019-06-25 mar. 06:15] => 2:05

3
TODO
View File

@ -11,7 +11,8 @@ minetest-solebull - LGPL-2.1 - A PVP/faction game for minetest based on Cobalt.
* v0.0.2-7 (10 Aug. 2019 - ???) CLOC ???,??? * v0.0.2-7 (10 Aug. 2019 - ???) CLOC ???,???
- (4) Add new faction elements to factions_ui - (5) Got faction name in button event
- Add new faction elements to factions_ui
- Should fix the faction players number - Should fix the faction players number
- Manually set faction leader name to fix for factions_ui - Manually set faction leader name to fix for factions_ui
- Add invite-only value to factions UI - Add invite-only value to factions UI

View File

@ -51,11 +51,32 @@ get_factions_ui = function(faction_id)
label[0,1;Invite-only :] label[2,1;]]..iotext..[[] label[0,1;Invite-only :] label[2,1;]]..iotext..[[]
textlist[0,2;7,4;faclist;]]..facnames..[[] textlist[0,2;7,4;faclist;]]..facnames..[[]
field[5,1;2,1;name;Nouvelle faction :;newFaction] field[5,1;2,1;name;Nouvelle faction :;newFaction]
button[5,3;2,1;name;Créer] button[5,3;2,1;create;Créer]
]] ]]
return formspec return formspec
end end
create_faction_from_UI = function(name)
if faction then
send_error(player, "You are already in a faction.")
return false
end
if factions.can_create_faction(factionname) then
new_faction = factions.new_faction(factionname, nil)
new_faction:add_player(player, new_faction.default_leader_rank)
-- Manual fix ?
new_faction.leader = player
new_faction.players[player] = player
factions.save()
return true
else
send_error(player, "Faction cannot be created.")
return false
end
end
sfinv.register_page("sfinv:factions_ui", { sfinv.register_page("sfinv:factions_ui", {
title = "Factions", title = "Factions",
on_enter = function(self, player, context) on_enter = function(self, player, context)
@ -76,8 +97,24 @@ sfinv.register_page("sfinv:factions_ui", {
sfinv.set_player_inventory_formspec(player, context) sfinv.set_player_inventory_formspec(player, context)
elseif event.type == "INV" then elseif event.type == "INV" then
-- We clicked the Create button -- We clicked the Create button
print("Creating new faction") local factionName = fields.name
print("Creating new faction " .. factionName)
end end
end end
}) })
-- Used to dump a lua table
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end