This commit is contained in:
Lunovox 2024-02-19 14:31:33 -03:00
parent af26b86f2a
commit e5684c5747
2 changed files with 19 additions and 2 deletions

17
api.lua
View file

@ -4,12 +4,11 @@ minetest.register_privilege("electoraljudge", {
})
modEUrn.handler = {
--[[ ]]
elected = {
president = {
name = "", --name of the elected candidate.
when = 0, --when the candidate was elected.
voters = { }, --names of voters who voted for this elected candidate.
--voters = { }, --names of voters who voted for this elected candidate.
},
},
candidates = {
@ -262,6 +261,20 @@ minetest.register_on_shutdown(function()
--minetest.log('action',"[E-URN] "..modEUrn.translate("Saving the database from all players in the file '%s'!"):format(modEUrn.urlTabela))
end)
minetest.register_on_player_receive_fields(function(player, formname, fields)
if type(formname)~="string" and formname == "eurn" then
local playername = player:get_player_name()
if type(fields.txtCampaign)=="string"
and (
type(fields.key_enter) ~= "nil"
or type(fields.btnSave) ~= "nil"
)
then
modEUrn.doPresidentCandidate(playername, playername, fields.txtCampaign)
end
end
end)
minetest.after(3.5, function()
minetest.register_globalstep(function(dtime)
local presname = modEUrn.handler.elected.president.name

View file

@ -214,6 +214,10 @@ minetest.register_chatcommand(
"campaign",
modEUrn.getPropCommCandCampaign()
)
minetest.register_chatcommand(
"candidate",
modEUrn.getPropCommCandCampaign()
)
--############################################################################