Compare commits

...

36 commits

Author SHA1 Message Date
Lunovox
c338dbf2dd 2024-03-03 01:15:21 -03:00
Lunovox
b8293d95e7 2024-03-03 01:01:47 -03:00
Lunovox
df07ba6766 2024-03-01 20:36:00 -03:00
Lunovox
5d4bcc8db3 2024-02-29 21:37:55 -03:00
Lunovox
a32474939c [bugfix] Correção de bug crítico de auto-contagem de votos! 2024-02-29 21:21:02 -03:00
Lunovox
862fc7c446 2024-02-28 12:45:58 -03:00
Lunovox
704e5127b3 [translate] locale/pt_BR.po
Amo editar coisa pelo PoEdit! Pena que não tem PoEdit para celular. tipo um "PoMobEditor". =S
2024-02-28 11:21:54 -03:00
Lunovox
744b763773 [conf] Novo arquivo a ignorar! 2024-02-28 11:18:13 -03:00
Lunovox
eadb8c3f3c [refact] Revazenfo painel de votação. 2024-02-27 17:37:30 -03:00
Lunovox
fee5afb486 2024-02-27 03:49:51 -03:00
Lunovox
01b8bb8440 2024-02-26 15:00:23 -03:00
Lunovox
f9a44182b1 2024-02-25 23:15:04 -03:00
Lunovox
f7f6a38da4 2024-02-25 22:45:28 -03:00
Lunovox
fa30828d39 2024-02-25 21:21:46 -03:00
Lunovox
a37f854374 2024-02-25 11:28:25 -03:00
Lunovox
a713e0fabb [feat] Menu Gráfico com Áudio nos Botões. 2024-02-25 02:06:51 -03:00
Lunovox
7b6310f6e1 Tentativa falha de consertar bug de tradução. Não sei porque desta parte não está sendo traduzida. 2024-02-25 02:03:18 -03:00
Lunovox
1d2c98a37f 2024-02-23 16:36:17 -03:00
Lunovox
79af9ba864 2024-02-22 17:01:36 -03:00
Lunovox
fba7fef573 2024-02-22 16:43:08 -03:00
Lunovox
b99d75b790 [feat] tradução para pt_BR 2024-02-22 15:59:51 -03:00
Lunovox
cd7f429a26 [docs] update README.md and settingtypes.txt 2024-02-21 23:23:41 -03:00
Lunovox
e8d5b17425 [refact] reorganizando os comandos. 2024-02-21 23:22:08 -03:00
Lunovox
379f726442 2024-02-21 11:02:52 -03:00
Lunovox
68454c2124 2024-02-21 09:51:15 -03:00
Lunovox
7ba6a503c9 [docs] Update README.md 2024-02-21 06:51:57 -03:00
Lunovox
bd273118d2 2024-02-21 02:38:24 -03:00
Lunovox
9c63aa9b40 [feat] Adicionando interface gráfica! 2024-02-20 23:03:09 -03:00
Lunovox
e5684c5747 2024-02-19 14:31:33 -03:00
Lunovox
af26b86f2a 2024-02-19 11:47:01 -03:00
Lunovox
c24e5313d7 2024-02-19 11:44:38 -03:00
Lunovox
f6285d6bc2 2024-02-19 11:37:52 -03:00
Lunovox
75f95d2f8a 2024-02-19 11:22:10 -03:00
Lunovox
f4e224811e [feat] código não testado. 2024-02-19 11:05:38 -03:00
Lunovox
4ca3113c2b Novo README.md 2024-02-19 11:04:41 -03:00
Lunovox
8559d70fb2 2024-02-19 08:56:57 -03:00
16 changed files with 1849 additions and 256 deletions

5
.gitignore vendored
View file

@ -2,5 +2,6 @@
.git
*.old
*~
.backup
.bkp
*.mo
*.backup
*.bkp

117
README.md
View file

@ -1,50 +1,101 @@
![urn_front]
# [E-URN]
[ [Minetest Mod] ] Colect opinion of player with electronic urn.
[![minetest_icon]][minetest_link] [![baixa_icon]][baixa_link] [![projeto_icon]][projeto_link] <!-- [![bower_icon]][bower_link] -->
**Dependencies:**
* default → Minetest Game Included
Adds a presidential election system and an Electronic Urn as an item that helps collect votes.
**Optional Dependencies:**
* [intllib] (Optional) → Facilitates the translation of several other mods into your native language, or other languages.
* [tradelands] (Optional) → Protection your lands and chests.
* [correio] (Optional) → Send mail to offline players.
All players can make promises as candidates. However, only players with more than 72 hours of gameplay will be able to vote for a candidate. The vote is permanent (except if the player has not played for more than 6 months). You can vote at any time, whenever you want, as many times as you want and for as many people as you want. Because the only valid vote is just the last one. Every beginning of the real month there will be an automatic recount of votes.
Don't worry about a possible need for Impeachment for some unwary new president who commits some unpopular act. If the players don't support the possibly unwary president. It is enough for the majority of players to vote for another candidate. At the end of the month, the candidate with the highest number of votes will be automatically elected.
## **License:**
* [GNU AGPL-3.0]
* [![license_icon]][license_link]
More details:
* in English: https://en.wikipedia.org/wiki/GNU_Affero_General_Public_License
* em Português: https://pt.wikipedia.org/wiki/GNU_Affero_General_Public_License
More details:
[![wiki_en_icon]][wiki_en_link] [![wiki_pt_icon]][wiki_pt_link]
**Developers:**
* Lunovox Heavenfinder: [email](mailto:lunovox@disroot.org), [xmpp](xmpp:lunovox@disroot.org?join), [social web](http:qoto.org/@lunovox), [audio conference](mumble:mumble.disroot.org), [more contacts](https:libreplanet.org/wiki/User:Lunovox)
## **Developers:**
## **Internationalization of this Mod:**
* Lunovox Heavenfinder: [email](mailto:lunovox@disroot.org), [xmpp](xmpp:lunovox@disroot.org?join), [social web](http://qoto.org/@lunovox), [audio conference](https://meet.jit.si/MinetestBrasil), [more contacts](https:libreplanet.org/wiki/User:Lunovox)
This mod currently are configured to language:
## 📦 **Depends:**
* [English] (DEFAULT)
* [Portuguese]
| Mod Name | Dependency Type | Descryption |
| :--: | :--: | :-- |
| default | Mandatory | Minetest Game Included. |
To add a new language to this mod just follow the steps below:
1. Enable the complementary mod **'intllib'.**
2. Set your language in **'minetest.conf'** by adding the [````language = <your language>````] property.
3. Example for French Language: ````language = fr````
4. Make a copy of the file [ **template.pot** ] in the [ **locale** ] folder that is inside the mod for [````locale/<your_language>.po````].
5. Example for French language: ````locale/fr.po````
6. Open the file [````locale/<your_language>.po````] in POEdit (Also works in a simple text editor).
7. Translate all and send your translated file to developers of this mod.
## **Commands:**
These commands are not mandatory for you to use this mod. To do the same, you can use the graphical mode of the electronic voting machine and the voter registration card.
| Command | Parameter | Descryption |
| :-- | :--: | :-- |
| ````/president```` | ````[<candidate_name>]```` | Show or Select the presidente of the server. Need the ````electoraljudge```` privilege. |
| ````/candidateme```` | ````[<political campaign>]```` | Register your campaign to run for server president. |
| ````/discandidateme```` | | Unregister your campaign to run for server president. |
| ````/candidates```` | | Show the name of all candidates for president. |
| ````/candidate```` or ````/campaign```` | ````[<candidate_name>]```` | Show the Campaign of candidate for president. |
| ````/vote```` | ````[<candidate_name>]```` | Vote for a specific candidate for president. Need a minimum number of hours of online play. |
| ````/unvote```` or ````/whitevote```` | | Apply Blank Vote. |
| ````/votes```` | | Show the name of all candidates for president with the amount of votes. Need the ````electoraljudge```` privilege. |
| ````/election```` | | Apply presidential selection vote counting! Need the ````electoraljudge```` privilege. |
## **API:**
Extras are functions of this mod that you can use in another mod you create. For example: "create a mod that gives a special power or privilege that only the elected president can enjoy"
| Function | Descryption |
| :--: | :-- |
| ````<array> modEUrn.getPresidentCandidates()```` | Return a array with name of all presidente candidates of the server. Return empty array if not exist.
| ````<string/nil> modEUrn.getPresidentName()```` | Return a string with the presidente name of the server. Return nil if not exist.
| ````modEUrn.doSave()```` | Save database em file ````e-urm.db````.
## **CONFIGURATION:**
You don't need to worry about the settings below to make this mod work. But, if you want to configure, you can change the settings through the graphical menu, or you can change them directly by editing the 'minetest.conf' file.
| Function | Descryption |
| :--: | :-- |
| ````eurn.debug = <true/false>```` | Allows you to print the debug information of this mod on the screen. Default: false |
| ````eurn.save_compressed = <true/false>```` | Whether the database will be BASE64 compressed. If enabled will save database bank without compression in file '.db'. Default: true |
| ````eurn.voter.min_played_hours = <number>```` | Minimum game time in hours to become a voter. Default: 90 | Min: 0 | Max: 8760 |
| ````eurn.crafting_recipe = <true/false>```` | Activate crafting recipe for all players got their own Electronic Urn. Default: false |
## **INTERNACIONALIZATION:**
### **Available Languages:**
* English (Defaul, Concluded: 100%)
* Português (Concluded: 0%)
### **Translate this mod to your Language:**
See more details in file: [locale/README.md]
[correio]:https://gitlab.com/Lunovox/correio
[E-URN]:https://gitlab.com/lunovox/e-urn/
[English]:https://gitlab.com/lunovox/e-urn/-/raw/master/locale/template.pot
[GNU AGPL-3.0]:https://gitlab.com/lunovox/e-urn/-/raw/master/LICENSE
[intllib]:https://github.com/minetest-mods/intllib
[Minetest Mod]:https://minetest.net
[Portuguese]:https://gitlab.com/lunovox/e-urn/-/raw/master/locale/pt.po
[tradelands]:https://github.com/Lunovox/tradelands
[urn_front]:textures/text_eurn_front.png
[E-URN]:https://gitlab.com/lunovox/e-urn/
[baixa_icon]:https://img.shields.io/static/v1?label=Download&message=Mod&color=blue
[baixa_link]:https://gitlab.com/lunovox/e-urn/-/archive/master/e-urn-master.zip?inline=false
[bower_icon]:https://img.shields.io/badge/Bower-Projeto-green.svg
[bower_link]:https://gitlab.com/lunovox/e-urn/-/raw/master/textures/bower.json
[GNU AGPL-3.0]:https://gitlab.com/lunovox/e-urn/-/raw/master/LICENSE
[license_icon]:https://img.shields.io/static/v1?label=GNU%20AGPL%20v3.0&message=Download&color=yellow
[license_link]:https://gitlab.com/lunovox/e-urn/-/raw/master/LICENSE
[locale/README.md]:https://gitlab.com/lunovox/e-urn/-/tree/main/locale?ref_type=heads
[minetest_icon]:https://img.shields.io/static/v1?label=Minetest&message=Game&color=brightgreen
[minetest_link]:https://minetest.net
[projeto_icon]:https://img.shields.io/static/v1?label=Projeto&message=GIT&color=red
[projeto_link]:https://gitlab.com/lunovox/e-urn
[wiki_en_icon]:https://img.shields.io/static/v1?label=GNU%20AGPL%20v3.0&message=EN&color=blue
[wiki_en_link]:https://en.wikipedia.org/wiki/GNU_Affero_General_Public_License
[wiki_pt_icon]:https://img.shields.io/static/v1?label=GNU%20AGPL%20v3.0&message=PT&color=blue
[wiki_pt_link]:https://pt.wikipedia.org/wiki/GNU_Affero_General_Public_License

385
api.lua
View file

@ -1,15 +1,77 @@
modEUrn.MinPlayedHours = tonumber(minetest.settings:get("eurn.voter.min_played_hours") or 72) -- value in hours
modEUrn.save_compressed = minetest.settings:get_bool("eurn.save_compressed") ~= false
minetest.register_privilege("electoraljudge", {
description=modEUrn.translate("Allows you to configure the Electronic Urn."),
give_to_singleplayer=false,
})
modEUrn.debug = function(text, playername)
if text ~= nil
and type(text) == "string"
and text ~= ""
then
if minetest.settings:get_bool("eurn.debug") then
if playername ~= nil
and type(playername) == "string"
and playername ~= ""
then
local player = minetest.get_player_by_name(playername)
if player ~=nil and player:is_player() then
minetest.chat_send_player(
playername, text
)
minetest.log('action',"["..modEUrn.modname:upper()..":DEBUG:"..playername.."] "..text)
else
minetest.log('error',
"["..modEUrn.modname:upper()..":DEBUG] "
..modEUrn.translate(
"Unable to address debug for player '%s'."
):format(dump(playername))
)
minetest.log('action',"["..modEUrn.modname:upper()..":DEBUG] "..text)
end
else
minetest.chat_send_all(text)
minetest.log('action',"["..modEUrn.modname:upper()..":DEBUG] "..text)
end
end
end
end
modEUrn.unsortTableByValue = function(tbl)
if type(tbl)~="table" then
tbl = {}
end
--modEUrn.debug("modEUrn.unsortTableByValue(): tbl = "..dump(tbl))
table.sort(tbl, function(a, b)
local aaa = "a(%s) > b(%s)"
aaa = aaa:format(dump(a), dump(b))
modEUrn.debug(aaa)
return a >= b
end)
--modEUrn.debug("modEUrn.unsortTableByValue(): tbl = "..dump(tbl))
return tbl
end
modEUrn.sortTableLenght = function(tbl)
local count = 0
--modEUrn.debug("t = "..dump(t))
for _ in pairs(tbl) do
count = count + 1
end
return count
end
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 = {
@ -17,12 +79,17 @@ modEUrn.handler = {
},
--]]
voters = { }, --modEUrn.handler.voters[playername]
--month_counted = 0
}
modEUrn.doSave = function()
local file = io.open(modEUrn.urlTabela, "w")
if file then
file:write(minetest.serialize(modEUrn.handler))
local handler = minetest.serialize(modEUrn.handler)
if modEUrn.save_compressed then
handler = minetest.encode_base64(handler)
end
file:write(handler)
file:close()
minetest.log('action',"[E-URN] "..modEUrn.translate("Database saved in file '%s'!"):format(modEUrn.urlTabela))
else
@ -33,7 +100,11 @@ end
modEUrn.doLoad = function()
local file = io.open(modEUrn.urlTabela, "r")
if file then
local handler = minetest.deserialize(file:read("*all"))
local handler = file:read("*all")
if modEUrn.save_compressed then
handler = minetest.decode_base64(handler)
end
handler = minetest.deserialize(handler) --transforma string to table
file:close()
if not handler or type(handler) ~= "table" then
minetest.log('error',"[E-URN:ERRO] "..modEUrn.translate("The file '%s' is not in table format!"):format(modEUrn.urlTabela))
@ -69,45 +140,52 @@ modEUrn.getPresidentName = function()
then
return modEUrn.handler.elected.president.name
end
return ""
end
modEUrn.doCheckDataBase = function(candidatename)
--modEUrn.handler.elected
if type(modEUrn.handler.elected)=="nil" then
modEUrn.handler.elected = { }
end
if type(modEUrn.handler.elected.president)=="nil" then
modEUrn.handler.elected.president = { }
end
if type(modEUrn.handler.elected.president.name)=="nil" then
modEUrn.handler.elected.president.name = ""
end
if type(modEUrn.handler.elected.president.when)=="nil" then
modEUrn.handler.elected.president.when = 0
end
--modEUrn.handler.candidates
if type(modEUrn.handler.candidates)=="nil" then
modEUrn.handler.candidates = { }
end
if type(modEUrn.handler.candidates.president)=="nil" then
modEUrn.handler.candidates.president = { }
end
if type(candidatename)=="string" and candidatename~="" then
if type(modEUrn.handler.candidates.president[candidatename])=="nil" then
modEUrn.handler.candidates.president[candidatename] = { }
end
if type(modEUrn.handler.candidates.president[candidatename].political_campaign)=="nil" then
modEUrn.handler.candidates.president[candidatename].political_campaign = "There are no campaign data about this political candidate."
end
if type(modEUrn.handler.candidates.president[candidatename].voters)=="nil" then
modEUrn.handler.candidates.president[candidatename].voters = { }
end
end
end
modEUrn.doPresident = function(playername, candidatename)
if minetest.player_exists(candidatename) then
local now = os.time() --Em milisegundos
--modEUrn.handler.elected
if modEUrn.handler.elected==nil then
modEUrn.handler.elected = { }
end
if modEUrn.handler.elected.president==nil then
modEUrn.handler.elected.president = { }
end
modEUrn.doCheckDataBase(candidatename)
modEUrn.handler.elected.president.name = candidatename
modEUrn.handler.elected.president.when = now
--modEUrn.handler.candidates
if modEUrn.handler.candidates==nil then
modEUrn.handler.candidates = { }
end
if modEUrn.handler.candidates.president==nil then
modEUrn.handler.candidates.president = { }
end
if modEUrn.handler.candidates.president[candidatename]==nil then
modEUrn.handler.candidates.president[candidatename] = { }
end
if modEUrn.handler.candidates.president[candidatename].political_campaign==nil then
modEUrn.handler.candidates.president[candidatename].political_campaign = "There are no campaign data about this political candidate."
end
if modEUrn.handler.candidates.president[candidatename].voters==nil then
modEUrn.handler.candidates.president[candidatename].voters = { }
end
for _, iCandPresident in ipairs(modEUrn.handler.candidates.president) do
if type(modEUrn.handler.candidates.president[iCandPresident].voters[playername])~="nil" then
modEUrn.handler.candidates.president[iCandPresident].voters[playername] = nil
end
end
modEUrn.handler.candidates.president[candidatename].voters[playername] = now
modEUrn.handler.elected.president.when = os.time() --Em milisegundos
modEUrn.doVote(playername, candidatename)
return true
else
minetest.chat_send_player(
@ -122,29 +200,15 @@ end
modEUrn.doPresidentCandidate = function(playername, candidatename, political_campaign)
if minetest.player_exists(candidatename) then
local now = os.time() --Em milisegundos
--local now = os.time() --Em milisegundos
if type(political_campaign)~="string"
or political_campaign == ""
then
political_campaign = "There are no campaign data about this political candidate."
political_campaign = modEUrn.translate("There are no campaign data about this political candidate.")
end
--modEUrn.handler.candidates
if modEUrn.handler.candidates==nil then
modEUrn.handler.candidates = { }
end
if modEUrn.handler.candidates.president==nil then
modEUrn.handler.candidates.president = { }
end
if modEUrn.handler.candidates.president[candidatename]==nil then
modEUrn.handler.candidates.president[candidatename] = { }
end
modEUrn.doCheckDataBase(candidatename)
modEUrn.handler.candidates.president[candidatename].political_campaign = political_campaign
if modEUrn.handler.candidates.president[candidatename].voters==nil then
modEUrn.handler.candidates.president[candidatename].voters = { }
end
return true
else
minetest.chat_send_player(
@ -158,11 +222,13 @@ modEUrn.doPresidentCandidate = function(playername, candidatename, political_cam
end
modEUrn.getPresCandCampaign = function(candidatename)
local political_campaign = "There are no campaign data about this political candidate."
if type(modEUrn.handler.candidates.president[candidatename].political_campaign)=="string"
local political_campaign = modEUrn.translate("There are no campaign data about this political candidate.")
--modEUrn.debug("candidatename="..dump(candidatename))
if type(modEUrn.handler.candidates.president[candidatename])=="table"
and type(modEUrn.handler.candidates.president[candidatename].political_campaign)=="string"
and modEUrn.handler.candidates.president[candidatename].political_campaign ~= ""
then
political_campaign =modEUrn.handler.candidates.president[candidatename].political_campaign
political_campaign = modEUrn.handler.candidates.president[candidatename].political_campaign
end
return political_campaign
end
@ -176,6 +242,178 @@ modEUrn.getPresidentCandidates = function()
return cands
end
modEUrn.getVoterPlayedTime = function(playername)
if type(playername)=="string"
and playername~=""
and type(modEUrn.handler.voters)=="table"
and type(modEUrn.handler.voters[playername])=="table"
and type(modEUrn.handler.voters[playername].times)=="table"
and type(modEUrn.handler.voters[playername].times.played)=="number"
then
return modEUrn.handler.voters[playername].times.played --in secounds
end
end
modEUrn.showWhiteVote = function(playername)
local resulte, cause = modEUrn.doUnvote(playername)
local color = "#FF0000"
local buttonsound = "sfx_failure"
if resulte then
color = "#00FF00"
buttonsound = "sfx_eurn_confirm"
end
minetest.chat_send_player(
playername,
core.colorize(color, "[E-URN]").." "..cause
)
modEUrn.FormSpecs.showFormAlert(
playername,
"favicon.png",
modEUrn.translate("E-URN"),
color,
cause,
"btnEUrnPresElection",
buttonsound
)
end
modEUrn.showPresCandCampaign = function(playername, candidatename)
if type(candidatename)=="string" and candidatename ~= "" then --Se o nome do candidato foi dito
if minetest.player_exists(candidatename) then --Se existe algum jogador o nome que foi dito
if type(modEUrn.handler.candidates.president[candidatename])=="table" then --Se foi algum candidato registrado.
local player = minetest.get_player_by_name(playername)
if player:is_player() then --verifica se o jogador está online ou por terminal
--modEUrn.FormSpecs.showFormInfoCampaign(playername, candidatename)
modEUrn.FormSpecs.showFormPresVote(playername, candidatename)
else
minetest.chat_send_player(
playername,
core.colorize("#00FF00", "[E-URN]").." "
..core.colorize("#888888",
modEUrn.translate("Candidate Name")..": "
)
..core.colorize("#00FF00", candidatename)
)
local Campaign = modEUrn.getPresCandCampaign(candidatename)
if type(Campaign)=="string" and Campaign~="" then
minetest.chat_send_player(
playername,
core.colorize("#00FF00", "[E-URN]").." "
..core.colorize("#888888",
modEUrn.translate("Candidate Campaign")..": "
)
..Campaign
)
end
end
else
minetest.chat_send_player(
playername,
core.colorize("#FF0000", "[E-URN]").." "
..modEUrn.translate("Player %s is not registered as a candidate for president!"):format(candidatename)
)
end
else
minetest.chat_send_player(
playername,
--os.date("%Y-%m-%d %Hh:%Mm:%Ss", now) ..
core.colorize("#FF0000", "[E-URN]").." "
..modEUrn.translate("The name '%s' is not the player name registered on the server!"):format(candidatename)
)
end
else
minetest.chat_send_player(
playername,
--os.date("%Y-%m-%d %Hh:%Mm:%Ss", now) ..
core.colorize("#FF0000", "[E-URN]").." "
..modEUrn.translate("Please enter the name of the candidate you wish to display the campaign!").."\n"
..core.colorize("#888888", "Syntaxe: ")
..core.colorize("#00FFFF",
"/campaign <"..modEUrn.translate("candidate_name")..">"
)
)
end
end
modEUrn.doUnvote = function(playername)
modEUrn.doCheckDataBase(candidatename)
local voterTimePlayed = modEUrn.getVoterPlayedTime(playername)
if type(voterTimePlayed)=="number" and voterTimePlayed >= modEUrn.MinPlayedHours * (60*60) then
for iCandPresName, _ in pairs(modEUrn.handler.candidates.president) do
--modEUrn.debug("iCandPresName = "..iCandPresName)
if type(modEUrn.handler.candidates.president[iCandPresName].voters[playername])~="nil" then
--modEUrn.debug("modEUrn.handler.candidates.president["..iCandPresName.."].voters = "..dump(modEUrn.handler.candidates.president[iCandPresName].voters))
modEUrn.handler.candidates.president[iCandPresName].voters[playername] = nil
end
end
return true, modEUrn.translate("You voted blank!")
else
return false, modEUrn.translate("You have not yet played the minimum number of hours to become a presidential voter. (Minimum %02d hours)"):format(modEUrn.MinPlayedHours)
end
end
--[[ ]]
modEUrn.doVote = function(playername, candidatename)
local voterTimePlayed = modEUrn.getVoterPlayedTime(playername)
--modEUrn.debug("modEUrn.doVote(): voterTimePlayed = "..dump(voterTimePlayed))
if type(voterTimePlayed)=="number" then
if voterTimePlayed >= modEUrn.MinPlayedHours * (60*60) then
if type(candidatename)=="string" and candidatename ~= "" then
if minetest.player_exists(candidatename) then
if type(modEUrn.handler.candidates.president[candidatename])=="table" then
modEUrn.doUnvote(playername)
modEUrn.handler.candidates.president[candidatename].voters[playername] = os.time() --Agora em milisegundos
return true, modEUrn.translate("You voted for the candidate: ")..core.colorize("#00FF00", candidatename)
else
return false, modEUrn.translate("Player '%s' is not registered as a candidate for president!"):format(candidatename)
end
else
return false, modEUrn.translate("The name '%s' is not the player name registered on the server!"):format(candidatename)
end
else
return false, modEUrn.translate("Please enter the name of the presidential candidate you wish to vote!").."\n"..core.colorize("#888888", "Syntaxe: ")..core.colorize("#00FFFF", "/vote <"..modEUrn.translate("candidate_name")..">")
end
else
return false, modEUrn.translate("You have not yet played the minimum number of hours to become a presidential voter. (Minimum %02d hours)"):format(modEUrn.MinPlayedHours)
end
else
return false, modEUrn.translate("Your name is not registered as a voter.")
end
end
--]]
modEUrn.doCheckPresident = function()
--Verifica registra quem será o presidente pela maioria de voto do candidato.
if modEUrn.sortTableLenght(modEUrn.handler.candidates.president) >= 1 then
local maxVotes = 0
local PresMaxVoted = ""
for iCandPresName, _ in pairs(modEUrn.handler.candidates.president) do
local numVotes = modEUrn.sortTableLenght(modEUrn.handler.candidates.president[iCandPresName].voters)
if numVotes >= 1 and maxVotes < numVotes then
maxVotes = numVotes
PresMaxVoted = iCandPresName
end
end
if maxVotes>=1 and PresMaxVoted~="" then
modEUrn.doCheckDataBase()
modEUrn.handler.elected.president.name = PresMaxVoted
modEUrn.handler.elected.president.when = os.time() --Agora em milisegundos
return true, modEUrn.translate("Player %s has been named the president of this server!"):format(dump(PresMaxVoted))
--[[
Falta:
* enviar email para todos os jogadores anunciando quem ganhou a eleição do mês.
* Faze o som de vitória
--]]
else
return false, modEUrn.translate("There are no votes registered!")
end
else
return false, modEUrn.translate("There are no candidates registered!")
end
end
minetest.register_on_leaveplayer(function(player)
modEUrn.on_leaveplayer(player)
modEUrn.doSave()
@ -228,4 +466,33 @@ 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.after(3.5, function()
local timecheck = 0
minetest.register_globalstep(function(dtime)
timecheck = timecheck + dtime
if timecheck >= 60 then
timecheck = 0
--local presname = modEUrn.handler.elected.president.name
local presname = modEUrn.getPresidentName()
if type(presname)=="string" and presname~="" then
local mesAtual = os.date("%m", os.time())
local mesChecked = os.date("%m", tonumber(modEUrn.handler.elected.president.when))
if mesChecked ~= mesAtual then
local result, cause = modEUrn.doCheckPresident()
local titlecolor = "#FF0000"
if result == true then
titlecolor = "#00FF00"
minetest.chat_send_all(
core.colorize(titlecolor, "[E-URN]").." "..cause
)
modEUrn.doSave()
end
end
end --Fim de if type(presname)=="string" and presname~="" then
end --Fim de if timecheck >= 60 then
end)
end)
--]]

View file

@ -75,16 +75,22 @@ modEUrn.getPropCommCandidateMe = function()
params = "[<".. modEUrn.translate("political campaign")..">]",
description = modEUrn.translate("Register your campaign to run for server president."),
func = function(playername, political_campaign)
local candidatename = playername
if modEUrn.doPresidentCandidate(playername, candidatename, political_campaign) then
modEUrn.doSave()
minetest.chat_send_player(
playername,
--os.date("%Y-%m-%d %Hh:%Mm:%Ss", now) ..
core.colorize("#00FF00", "[E-URN]").." "
..modEUrn.translate("Player %s has been registered to run as a candidate for president of this server!"):format(dump(candidatename))
)
end
local player = minetest.get_player_by_name(playername)
if player and player:is_player() then
--modEUrn.debug("playername='"..playername.."' | political_campaign='"..political_campaign.."'")
modEUrn.FormSpecs.showFormRegCampaign(playername, political_campaign)
else
local candidatename = playername
if modEUrn.doPresidentCandidate(playername, candidatename, political_campaign) then
modEUrn.doSave()
minetest.chat_send_player(
playername,
--os.date("%Y-%m-%d %Hh:%Mm:%Ss", now) ..
core.colorize("#00FF00", "[E-URN]").." "
..modEUrn.translate("Player @1 has been registered to run as a candidate for president of this server!", dump(playername))
)
end
end
end,
}
end
@ -96,6 +102,37 @@ minetest.register_chatcommand(
--############################################################################
modEUrn.getPropCommDiscandidateMe = function()
return {
--privs = {electoraljudge=true},
--params = "[<".. modEUrn.translate("political campaign")..">]",
description = modEUrn.translate("Unregister your campaign to run for server president."),
func = function(playername, param)
modEUrn.doCheckDataBase()
if modEUrn.handler.candidates.president[playername]~=nil then
modEUrn.handler.candidates.president[playername] = nil
end
modEUrn.handler.elected.president.name = ""
modEUrn.handler.elected.president.when = 0
modEUrn.doSave()
minetest.chat_send_player(
playername,
--os.date("%Y-%m-%d %Hh:%Mm:%Ss", now) ..
core.colorize("#00FF00", "[E-URN]").." "
..modEUrn.translate("Player @1 has been unregistered to run as a candidate for president of this server!", dump(playername))
)
end,
}
end
minetest.register_chatcommand(
"discandidateme",
modEUrn.getPropCommDiscandidateMe()
)
--############################################################################
modEUrn.getPropCommCandidates = function()
return {
--privs = {electoraljudge=true},
@ -117,28 +154,13 @@ modEUrn.getPropCommCandidates = function()
minetest.chat_send_player(
playername,
core.colorize("#00FF00", "[E-URN]").." "
..modEUrn.translate("Number of Candidates: %s"):format(candCount)
..modEUrn.translate("Number of Candidates: %02d"):format(candCount)
)
minetest.chat_send_player(
playername,
core.colorize("#00FF00", "[E-URN]").." "
..modEUrn.translate("Candidate List: %s"):format(candList)
)
--minetest.chat_send_all("Numero de Candidatos: "..candCount)
--minetest.chat_send_all("Lista de Candidatos: "..candList)
--]]
--[[
if then
minetest.chat_send_player(
playername,
--os.date("%Y-%m-%d %Hh:%Mm:%Ss", now) ..
core.colorize("#00FF00", "[E-URN]").." "
..modEUrn.translate("Player %s has been registered to run as a candidate for president of this server!"):format(dump(candidatename))
)
end
--]]
end,
}
end
@ -156,56 +178,7 @@ modEUrn.getPropCommCandCampaign = function()
params = "<".. modEUrn.translate("candidate_name")..">",
description = modEUrn.translate("Show the Campaign of candidate for president."),
func = function(playername, candidatename)
if type(candidatename)=="string" and candidatename ~= "" then
if minetest.player_exists(candidatename) then
if type(modEUrn.handler.candidates.president[candidatename])=="table" then
minetest.chat_send_player(
playername,
core.colorize("#00FF00", "[E-URN]").." "
..core.colorize("#888888",
modEUrn.translate("Candidate Name: ")
)
..core.colorize("#00FF00", candidatename)
)
local Campaign = modEUrn.getPresCandCampaign(candidatename)
if type(Campaign)=="string" and Campaign~="" then
minetest.chat_send_player(
playername,
core.colorize("#00FF00", "[E-URN]").." "
..core.colorize("#888888",
modEUrn.translate("Candidate Campaign: ")
)
..Campaign
)
end
else
minetest.chat_send_player(
playername,
core.colorize("#FF0000", "[E-URN]").." "
..modEUrn.translate("Player %s is not registered as a candidate for president!"):format(candidatename)
)
end
else
minetest.chat_send_player(
playername,
--os.date("%Y-%m-%d %Hh:%Mm:%Ss", now) ..
core.colorize("#FF0000", "[E-URN]").." "
..modEUrn.translate("The name '%s' is not the player name registered on the server!"):format(candidatename)
)
end
else
minetest.chat_send_player(
playername,
--os.date("%Y-%m-%d %Hh:%Mm:%Ss", now) ..
core.colorize("#FF0000", "[E-URN]").." "
..modEUrn.translate("Please enter the name of the candidate you wish to display the campaign!").."\n"
..core.colorize("#888888", "Syntaxe: ")
..core.colorize("#00FFFF",
"/campaign <"..modEUrn.translate("candidate_name")..">"
)
)
end
modEUrn.showPresCandCampaign(playername, candidatename)
end,
}
end
@ -214,9 +187,207 @@ minetest.register_chatcommand(
"campaign",
modEUrn.getPropCommCandCampaign()
)
minetest.register_chatcommand(
"candidate",
modEUrn.getPropCommCandCampaign()
)
--############################################################################
modEUrn.getPropCommVoter = function()
return {
--privs = {electoraljudge=true},
--params = "<".. modEUrn.translate("candidate_name")..">",
description = modEUrn.translate("Check if you're ready to vote for a presidential candidate!"),
func = function(playername, params)
local voterTimePlayed = modEUrn.getVoterPlayedTime(playername)
if type(voterTimePlayed)=="number" then
local hours = math.ceil(voterTimePlayed/(60*60))
local color, messege = ""
if voterTimePlayed >= modEUrn.MinPlayedHours * (60*60) then
messege = modEUrn.translate("Are you ready to vote!")
color = "#00FF00"
else
messege = modEUrn.translate(
"You only have @1 hours of the @2 minimum game hours to be eligible to vote!",
string.format("%02d", tonumber(hours)),
string.format("%02d", tonumber(modEUrn.MinPlayedHours))
)
color = "#FF0000"
end
minetest.chat_send_player(
playername,
core.colorize(color, "[E-URN]").." "..messege
)
end
end,
}
end
minetest.register_chatcommand(
"voter",
modEUrn.getPropCommVoter()
)
--############################################################################
modEUrn.getPropCommCandVote = function()
return {
--privs = {electoraljudge=true},
params = "<".. modEUrn.translate("candidate_name")..">",
description = modEUrn.translate("Vote for a specific candidate for president."),
func = function(playername, candidatename)
local resulte, cause = modEUrn.doVote(playername, candidatename)
local color = "#FF0000"
if resulte then
color = "#00FF00"
minetest.sound_play("sfx_eurn_confirm", {to_player=playername, max_hear_distance=5.0,})
else
minetest.sound_play("sfx_failure", {to_player=playername, max_hear_distance=5.0,})
end
minetest.chat_send_player(
playername,
core.colorize(color, "[E-URN]").." "..cause
)
end,
}
end
minetest.register_chatcommand(
"vote",
modEUrn.getPropCommCandVote()
)
--############################################################################
modEUrn.getPropCommUnvote = function()
return {
--privs = {electoraljudge=true},
--params = "<".. modEUrn.translate("candidate_name")..">",
description = modEUrn.translate("Apply Blank Vote."),
func = function(playername, param)
local resulte, cause = modEUrn.doUnvote(playername)
local color = "#FF0000"
if resulte then
color = "#00FF00"
minetest.sound_play("sfx_eurn_confirm", {to_player=playername, max_hear_distance=5.0,})
else
minetest.sound_play("sfx_failure", {to_player=playername, max_hear_distance=5.0,})
end
minetest.chat_send_player(
playername,
core.colorize(color, "[E-URN]").." "..cause
)
end,
}
end
minetest.register_chatcommand(
"unvote",
modEUrn.getPropCommUnvote()
)
minetest.register_chatcommand(
"whitevote",
modEUrn.getPropCommUnvote()
)
--############################################################################
modEUrn.getPropCommVotes = function()
return {
privs = {electoraljudge=true},
--params = "<".. modEUrn.translate("candidate_name")..">",
description = modEUrn.translate("Displays the number of votes for each candidate! (Need the 'electoraljudge' privilege!)"),
func = function(playername, candidatename)
--modEUrn.debug("modEUrn.handler.candidates.president = "..dump(modEUrn.handler.candidates.president))
--modEUrn.debug("modEUrn.sortTableLenght(modEUrn.handler.candidates.president) = "..modEUrn.sortTableLenght(modEUrn.handler.candidates.president))
if type(modEUrn.handler.candidates.president)=="table" then
local votes = {}
for iCandPresName, iCandPresTable in pairs(modEUrn.handler.candidates.president) do
local num = modEUrn.sortTableLenght(iCandPresTable.voters)
if type(iCandPresTable.voters)=="table" and num >= 1 then
votes[iCandPresName] = num
--modEUrn.debug("num = "..num)
end
end
if modEUrn.sortTableLenght(votes) >= 1 then
--modEUrn.debug(dump(votes))
votes = modEUrn.unsortTableByValue(votes)
--modEUrn.debug(dump(votes))
local strVotes = ""
for iCandPresName, iCandPresVotes in pairs(votes) do
--modEUrn.debug("modEUrn.getPropCommVotes(): iCandPresName = "..dump(iCandPresName).." | iCandPresVotes = "..dump(iCandPresVotes))
if strVotes=="" then
strVotes = modEUrn.translate(" * %s : %02d votes"):format(iCandPresName, iCandPresVotes)
else
strVotes = strVotes.."\n"..modEUrn.translate(" * %s : %02d votes"):format(iCandPresName, iCandPresVotes)
end
end
minetest.chat_send_player(
playername,
core.colorize("#00FF00", "[E-URN]").." "
..modEUrn.translate("Voting list for presidential election: ").."\n"..strVotes
)
--]]
else
minetest.chat_send_player(
playername,
core.colorize("#FF0000", "[E-URN]").." "
..modEUrn.translate("No one has voted in the presidential election yet!")
--..core.colorize("#00FF00", candidatename)
)
end
else
minetest.chat_send_player(
playername,
core.colorize("#FF0000", "[E-URN]").." "
..modEUrn.translate("There is no registered candidate for the presidential election!")
--..core.colorize("#00FF00", candidatename)
)
end
end,
}
end
minetest.register_chatcommand(
"votes",
modEUrn.getPropCommVotes()
)
--############################################################################
modEUrn.getPropCommElection = function()
return {
privs = {electoraljudge=true},
--params = "<".. modEUrn.translate("candidate_name")..">",
description = modEUrn.translate("Apply presidential selection vote counting! (Need the 'electoraljudge' privilege.)"),
func = function(playername, param)
--modEUrn.debug("modEUrn.handler.candidates.president = "..dump(modEUrn.handler.candidates.president))
--modEUrn.debug("modEUrn.sortTableLenght(modEUrn.handler.candidates.president) = "..modEUrn.sortTableLenght(modEUrn.handler.candidates.president))
local result, cause = modEUrn.doCheckPresident()
if result == true then
minetest.chat_send_all(
core.colorize("#00FF00", "[E-URN]").." "..cause
)
else
minetest.chat_send_player(
playername,
core.colorize("#FF0000", "[E-URN]").." "..cause
)
end
end,
}
end
minetest.register_chatcommand(
"election",
modEUrn.getPropCommElection()
)
--############################################################################
--[[
minetest.register_chatcommand(
"t",
@ -241,4 +412,4 @@ minetest.register_chatcommand(
end,
}
)
--]]
--]]

View file

@ -1,48 +1,286 @@
local body = [[
<center>
<img name=favicon.png float=center width=96 height=96>
<style font=mono color=#FF0000 size=24><b>OLÁ %s!</b></style>
</center>
Esse é um <action name=lnkExemplo1><item name=default:sword_wood valign=middle width=14 height=14> Exemplo de Link</action> em formato hyperlink. (Não é funcional!)
<center>
-= Fim =-
<bigger>=D</bigger>
</center>
]]
modEUrn.FormSpecs = {
showFormMain = function(playername)
local myFormSpec = ""
myFormSpec = myFormSpec
.."formspec_version[6]"
.."size[16,8,false]"
.."background[0,-8;16,16;text_eurn_front.png]"
.."box[2.05,1.50;7.75,5.00;#001100CC]"
.."button[2.15,1.65;7.55,1;btnPresElection;"..modEUrn.translate("PRESIDENTIAL ELECTION").."]"
.."button[2.15,2.65;7.55,1;btnElectoralCourt;"..modEUrn.translate("ELECTORAL COURT").."]"
.."style_type[button_exit;bgimg=;bgimg_pressed=;border=;bgcolor=red]"
.."button_exit[2.15,3.65;7.55,1;;"..modEUrn.translate("EXIT").."]"
minetest.sound_play("sfx_eurn_button", {to_player=playername, max_hear_distance=5.0,})
minetest.show_formspec(playername, "frmEUrnMain", myFormSpec)
end,
showFormPresElection = function(playername)
local myFormSpec = ""
myFormSpec = myFormSpec
.."formspec_version[6]"
.."size[16,8,false]"
.."background[0,-8;16,16;text_eurn_front.png]"
.."box[2.05,1.50;7.75,5.00;#001100CC]"
.."button[2.15,1.65;7.55,1;btnPresCandidates;"..modEUrn.translate("PRESIDENTIAL CANDIDATES").."]"
.."button[2.15,2.65;7.55,1;btnPresElect;"..modEUrn.translate("PRESIDENT ELECT").."]"
.."style[btnBack;bgimg=;bgimg_pressed=;border=;bgcolor=red]"
.."button[2.15,3.65;7.55,1;btnBack;"..modEUrn.translate("BACK").."]"
minetest.sound_play("sfx_eurn_button", {to_player=playername, max_hear_distance=5.0,})
minetest.show_formspec(playername, "frmEUrnPresElection", myFormSpec)
end,
showFormPresCands = function(playername, candidatename)
local voterTimePlayed = modEUrn.getVoterPlayedTime(playername)
local cands = modEUrn.getPresidentCandidates()
local candList = ""
local candCount = 0
local selected = 0
for _, iCandPresName in ipairs(cands) do
candCount = candCount + 1
if candList == "" then
candList = minetest.formspec_escape(iCandPresName)
else
candList = candList..","..minetest.formspec_escape(iCandPresName)
end
if type(candidatename)=="string" and candidatename==iCandPresName then
selected = candCount
end
end
local myFormSpec = ""
myFormSpec = myFormSpec
.."formspec_version[6]"
.."size[16,8,false]"
.."background[0,-8;16,16;text_eurn_front.png]"
--.."box[-0.5,-0.5;16.5,8.5;#001100CC]"
.."box[2.05,1.50;7.75,5.00;#001100CC]"
.."textlist[2.15,1.50;7.55,4;lstCands;"..candList..";"..selected..";true]"
if type(voterTimePlayed)=="number" and voterTimePlayed >= modEUrn.MinPlayedHours * (60*60) then
myFormSpec = myFormSpec
.."style[btnWhiteVote;bgcolor=white;color=black]"
.."button[2.10,5.50;2.25,1;btnWhiteVote;"..minetest.formspec_escape(modEUrn.translate("WHITE")).."]"
end
myFormSpec = myFormSpec
.."style[btnBack;bgimg=;bgimg_pressed=;border=;bgcolor=red]"
.."button[4.40,5.50;2.50,1;btnBack;"..minetest.formspec_escape(modEUrn.translate("CANCEL")).."]"
if selected >= 1 and type(voterTimePlayed)=="number" and voterTimePlayed >= modEUrn.MinPlayedHours * (60*60) then
myFormSpec = myFormSpec
.."style[btnPresCandSel;bgimg=;bgimg_pressed=;border=;bgcolor=green]"
.."button[6.95,5.50;2.75,1;btnPresCandSel;"..minetest.formspec_escape(modEUrn.translate("SELECT")).."]"
end
minetest.sound_play("sfx_eurn_button", {to_player=playername, max_hear_distance=5.0,})
minetest.show_formspec(playername, "frmEUrnPresCands", myFormSpec)
end,
showFormPresCands_deprecated = function(playername, candidatename)
local cands = modEUrn.getPresidentCandidates()
local candList = ""
local candCount = 0
local selected = 0
--minetest.chat_send_all("Numero de Candidatos: "..#modEUrn.handler.candidates.president)
for _, iCandPresName in ipairs(cands) do
candCount = candCount + 1
if candList == "" then
candList = minetest.formspec_escape(iCandPresName)
else
candList = candList..","..minetest.formspec_escape(iCandPresName)
end
if type(candidatename)=="string" and candidatename==iCandPresName then
selected = candCount
end
end
local myFormSpec = ""
myFormSpec = myFormSpec
.."formspec_version[6]"
.."size[16,8,false]"
.."background[0,-8;16,16;text_eurn_front.png]"
.."box[-0.5,-0.5;16.5,8.5;#001100CC]"
.."style[lstCands;bgcolor=red]"
.."style_type[textlist;bgcolor=red]"
.."textlist[0.5,0.5;3,7;lstCands;"..candList..";"..selected..";true]"
if selected >= 1 then
local Campaign = modEUrn.getPresCandCampaign(candidatename)
local body = [[
<center>
<img name=text_candidate_face.png width=128 height=128>
<bigger><b>%s</b></bigger>
</center>
<justify>%s</justify>
]]
myFormSpec = myFormSpec
--.."style[htmPanel;bgcolor=white;border=#008800CC;color=black]"
.."hypertext[4.0,0.5;11.25,6.00;htmPanel;"
--..minetest.formspec_escape("<global margin=10 valign=0 color=#FF00FF hovercolor=#00FFFF size=12 font=normal halign=center >")
.."<global valign=middle halign=center margin=30 background=#001100CC bordercolor=#008800CC color=#FFFFFF hovercolor=#00FF00 size=12 font=normal>"
.."<tag name=action color=#FF0000 hovercolor=#00FF00 font=normal size=12>"
.."<tag name=bigger color=#00CC00 font=normal size=28>"
.."<tag name=big color=#CCCC00 font=normal size=18>"
.."<tag name=b color=#00CC00 font=normal>"
..minetest.formspec_escape(body:format(cands[selected], Campaign))
.."]" -- Fim de hypertext[]
local voterTimePlayed = modEUrn.getVoterPlayedTime(playername)
if type(voterTimePlayed)=="number" and voterTimePlayed >= modEUrn.MinPlayedHours * (60*60) then
myFormSpec = myFormSpec
.."style[btnWhiteVote;bgcolor=white;color=black]"
.."button[4.0,6.75;3.00,1;btnWhiteVote;"..minetest.formspec_escape(modEUrn.translate("WHITE")).."]"
.."style[btnPresVote;bgimg=;bgimg_pressed=;border=;bgcolor=green]"
.."button[7.10,6.75;5.65,1;btnPresVote;"..minetest.formspec_escape(modEUrn.translate("CONFIRM")).."]"
end
end
myFormSpec = myFormSpec
.."style[btnBack;bgimg=;bgimg_pressed=;border=;bgcolor=red]"
.."button[12.85,6.75;2.55,1;btnBack;"..minetest.formspec_escape(modEUrn.translate("CANCEL")).."]"
minetest.sound_play("sfx_eurn_button", {to_player=playername, max_hear_distance=5.0,})
minetest.show_formspec(playername, "frmEUrnPresCands", myFormSpec)
end,
showFormAlert = function(playername, icon, title, titlecolor, message, buttonname, buttonsound)
local body = ""
body = [[
<center>
<img name=%s width=128 height=128>
<style color=%s><bigger><b>%s</b></bigger></style>
%s
</center>
]]
if type(titlecolor)=="nil" or titlecolor=="" then
titlecolor = "#00FF00"
end
body = body:format(icon, titlecolor, title, message)
local myFormSpec = ""
myFormSpec = myFormSpec
.."formspec_version[6]"
.."size[16,8,false]"
.."background[0,-8;16,16;text_eurn_front.png]"
.."box[2.05,1.50;7.75,5.00;#001100CC]"
.."hypertext[2.15,1.50;7.55,4.00;htmPanel;"
--..minetest.formspec_escape("<global margin=10 valign=0 color=#FF00FF hovercolor=#00FFFF size=12 font=normal halign=center >")
.."<global valign=middle halign=center margin=10 background=#001100CC color=#FFFFFF hovercolor=#00FF00 size=12 font=normal>"
.."<tag name=action color=#FF0000 hovercolor=#00FF00 font=normal size=12>"
.."<tag name=bigger font=normal size=28>"
.."<tag name=big color=#CCCC00 font=normal size=18>"
.."<tag name=b color=#00CC00 font=normal>"
..minetest.formspec_escape(body)
.."]" -- Fim de hypertext[]
--.."style[btnBack;bgimg=;bgimg_pressed=;border=;bgcolor=red]"
local button_type = "button"
if type(buttonname)=="nil" or buttonname=="" or buttonname=="btnExit" then
button_type = "button_exit"
end
myFormSpec = myFormSpec
..button_type.."[2.15,5.50;7.55,1;"..minetest.formspec_escape(buttonname)..";OK]"
if type(buttonsound)=="string" and buttonsound~="" then
minetest.sound_play(buttonsound, {to_player=playername, max_hear_distance=5.0,})
end
minetest.show_formspec(playername, "frmEUrnAlert", myFormSpec)
end,
showFormRegCampaign = function(playername, political_campaign)
local Campaign = modEUrn.getPresCandCampaign(playername)
if type(political_campaign)~="string" or political_campaign==""then
political_campaign = Campaign
end
local myFormSpec = ""
myFormSpec = myFormSpec
.."formspec_version[6]"
.."size[16,8,false]"
.."background[0,-8;16,16;text_eurn_front.png]"
.."box[0.5,0.75;15,5.75;#000000CC]"
.."textarea[0.5,0.75;15,5.75;txtCampaign;"
..minetest.formspec_escape(
modEUrn.translate("Political Campaign of")..": "..
core.colorize("#00FF00", playername)
)..";"
..minetest.formspec_escape(political_campaign)..
"]"
.."button_exit[0.5,6.75;12.25,1;btnSave;"..modEUrn.translate("REGISTER").."]"
.."button_exit[12.85,6.75;2.55,1;;"..modEUrn.translate("CANCEL").."]"
minetest.sound_play("sfx_eurn_button", {to_player=playername, max_hear_distance=5.0,})
minetest.show_formspec(playername, "frmEUrnRegCampaign", myFormSpec)
end,
showFormPresVote = function(playername, candidatename)
local myFormSpec = ""
myFormSpec = myFormSpec
.."formspec_version[6]"
.."size[16,8,false]"
.."background[0,-8;16,16;text_eurn_front.png]"
.."box[-0.5,-0.5;16.5,8.5;#001100CC]"
.."style[lstCands;bgcolor=red]"
--.."style_type[textlist;bgcolor=red]"
--.."textlist[0.5,0.5;3,7;lstCands;"..candList..";"..selected..";true]"
local Campaign = modEUrn.getPresCandCampaign(candidatename)
if type(modEUrn.handler.candidates.president[candidatename])=="nil" then
Campaign = ""
end
local body = [[
<center>
<img name=text_candidate_face.png width=128 height=128>
<bigger><b>%s</b></bigger>
</center>
<justify>%s</justify>
]]
myFormSpec = myFormSpec
--.."style[htmPanel;bgcolor=white;border=#008800CC;color=black]"
.."hypertext[4.0,0.5;11.25,6.00;htmPanel;"
--..minetest.formspec_escape("<global margin=10 valign=0 color=#FF00FF hovercolor=#00FFFF size=12 font=normal halign=center >")
.."<global valign=middle halign=center margin=30 background=#001100CC bordercolor=#008800CC color=#FFFFFF hovercolor=#00FF00 size=12 font=normal>"
.."<tag name=action color=#FF0000 hovercolor=#00FF00 font=normal size=12>"
.."<tag name=bigger color=#00CC00 font=normal size=28>"
.."<tag name=big color=#CCCC00 font=normal size=18>"
.."<tag name=b color=#00CC00 font=normal>"
..minetest.formspec_escape(body:format(candidatename, Campaign))
.."]" -- Fim de hypertext[]
local voterTimePlayed = modEUrn.getVoterPlayedTime(playername)
if type(voterTimePlayed)=="number" and voterTimePlayed >= modEUrn.MinPlayedHours * (60*60) then
myFormSpec = myFormSpec
.."style[btnWhiteVote;bgcolor=white;color=black]"
.."button[4.0,6.75;3.00,1;btnWhiteVote;"..minetest.formspec_escape(modEUrn.translate("WHITE")).."]"
.."style[btnPresVote;bgimg=;bgimg_pressed=;border=;bgcolor=green]"
.."button[7.10,6.75;5.65,1;btnPresVote;"..minetest.formspec_escape(modEUrn.translate("CONFIRM")).."]"
end
myFormSpec = myFormSpec
.."style[btnBack;bgimg=;bgimg_pressed=;border=;bgcolor=red]"
.."button[12.85,6.75;2.55,1;btnBack;"..minetest.formspec_escape(modEUrn.translate("CANCEL")).."]"
minetest.sound_play("sfx_eurn_button", {to_player=playername, max_hear_distance=5.0,})
minetest.show_formspec(playername, "frmEUrnPresVote", myFormSpec)
--[[
local Campaign = modEUrn.getPresCandCampaign(candidatename)
--if type(modEUrn.handler.candidates.president[candidatename])=="nil" then Campaign = "" end
local myFormSpec = ""
myFormSpec = myFormSpec
.."formspec_version[6]"
.."size[16,8,false]"
.."background[0,-8;16,16;text_eurn_front.png]"
.."box[0.5,0.75;15,5.75;#00000088]"
.."textarea[0.5,0.75;15,5.75;;"
..minetest.formspec_escape(
modEUrn.translate("Political Campaign of")..": "..
core.colorize("#00FF00", candidatename)
)..";"
..minetest.formspec_escape(Campaign)..
"]"
.."button_exit[0.5,6.75;12.25,1;btnVote;"..modEUrn.translate("VOTE").."]"
.."button_exit[13.25,6.75;2,1;;"..modEUrn.translate("CLOSE").."]"
minetest.log('action', modEUrn.translate("Player %s is listing campaign data..."):format(playername))
minetest.log('action',modEUrn.translate("Candidate Name")..candidatename)
minetest.log('action',modEUrn.translate("Candidate Campaign")..Campaign)
minetest.sound_play("sfx_eurn_button", {to_player=playername, max_hear_distance=5.0,})
minetest.show_formspec(playername, "frmEUrnInfoCampaign", myFormSpec)
--]]
end,
--[[
showHypertext = function(playername)
--Fonte:
-- * https://minetest.gitlab.io/minetest/formspec/
@ -76,4 +314,144 @@ modEUrn.FormSpecs = {
--"hypertext[<X>,<Y>;<W>,<H>;<name>;<text>]"
minetest.show_formspec(playername, "frmEUrnInit", myFormSpec)
end,
--]]
}
minetest.register_on_player_receive_fields(function(player, formname, fields)
local playername = player:get_player_name()
--modEUrn.debug("formname: "..formname.."\n".."fields: "..dump(fields), playername)
if type(formname)=="string" and formname == "frmEUrnAlert" then
if type(fields.btnEUrnMain) ~= "nil" then
modEUrn.FormSpecs.showFormMain(playername)
elseif type(fields.btnEUrnPresElection) ~= "nil" then
modEUrn.FormSpecs.showFormPresElection(playername)
elseif type(fields.btnEUrnPresCands) ~= "nil" then
modEUrn.FormSpecs.showFormPresCands(playername)
end
elseif type(formname)=="string" and formname == "frmEUrnMain" then
if type(fields.btnPresElection) ~= "nil" then
modEUrn.FormSpecs.showFormPresElection(playername)
elseif type(fields.quit) ~= "true" then
minetest.sound_play("sfx_eurn_button", {to_player=playername, max_hear_distance=5.0,})
end
elseif type(formname)=="string" and formname == "frmEUrnPresElection" then
if type(fields.btnPresCandidates) ~= "nil" then
modEUrn.FormSpecs.showFormPresCands(playername, nil)
elseif type(fields.btnPresElect) ~= "nil" then
local icon, title, message, buttonname = ""
local presidentname = modEUrn.getPresidentName()
if presidentname~="" then
icon = "text_candidate_face.png"
title = presidentname:upper()
titlecolor = "#00FF00"
message = modEUrn.translate("PRESIDENT ELECT")
buttonname = "btnEUrnMain"
else
icon = "favicon.png"
title = modEUrn.translate("E-URN")
titlecolor = "#FF0000"
message = modEUrn.translate("No presidential candidate has yet been elected!")
buttonname = "btnEUrnPresElection"
end
modEUrn.FormSpecs.showFormAlert(
playername,
icon,
title,
titlecolor,
message,
buttonname,
"sfx_eurn_button"
)
elseif type(fields.btnBack) ~= "nil" then
modEUrn.FormSpecs.showFormMain(playername)
end
elseif type(formname)=="string" and formname == "frmEUrnPresCands" then
if type(modEUrn.selCand)~="table" then
modEUrn.selCand = {}
end
if type(fields.lstCands) ~= "nil" then
local lstCands = minetest.explode_textlist_event(fields.lstCands)
if type(lstCands.index)=="number" and lstCands.index>=1 then
local cands = modEUrn.getPresidentCandidates()
modEUrn.selCand[playername] = cands[lstCands.index]
modEUrn.FormSpecs.showFormPresCands(playername, cands[lstCands.index])
end
elseif type(fields.btnPresCandSel) ~= "nil" then
if type(modEUrn.selCand[playername])=="string" and modEUrn.selCand[playername]~="" then
modEUrn.FormSpecs.showFormPresVote(playername, modEUrn.selCand[playername])
end
elseif type(fields.btnWhiteVote) ~= "nil" then
modEUrn.showWhiteVote(playername)
elseif type(fields.btnBack) ~= "nil" then
modEUrn.FormSpecs.showFormPresElection(playername)
end
elseif type(formname)=="string" and formname == "frmEUrnPresVote" then
if type(fields.btnPresVote) ~= "nil" then
if type(modEUrn.selCand[playername])=="string" and modEUrn.selCand[playername]~="" then
local resulte, cause = modEUrn.doVote(playername, modEUrn.selCand[playername])
local color = "#FF0000"
local icon = "favicon.png"
local title = modEUrn.translate("E-URN")
local message = cause
local buttonname = "btnEUrnPresCands"
local buttonsound = "sfx_failure"
if resulte then
color = "#00FF00"
icon = "text_candidate_face.png"
title = modEUrn.selCand[playername]:upper()
message = modEUrn.translate("Thanks for your vote!")
buttonname = "btnEUrnMain"
buttonsound = "sfx_eurn_confirm"
--minetest.sound_play("sfx_eurn_confirm", {to_player=playername, max_hear_distance=5.0,})
end
minetest.chat_send_player(
playername,
core.colorize(color, "[E-URN]").." "..cause
)
modEUrn.FormSpecs.showFormAlert(
playername,
icon,
title,
color,
message,
buttonname,
buttonsound
)
end
elseif type(fields.btnWhiteVote) ~= "nil" then
modEUrn.showWhiteVote(playername)
elseif type(fields.btnBack) ~= "nil" then
local candidatename = ""
if type(modEUrn.selCand)=="table"
and type(modEUrn.selCand[playername])=="string"
and modEUrn.selCand[playername]~=""
then
candidatename = modEUrn.selCand[playername]
end
modEUrn.FormSpecs.showFormPresCands(playername, candidatename)
end
elseif type(formname)=="string" and formname == "frmEUrnPresElect" then
if type(fields.btnBack) ~= "nil" then
modEUrn.FormSpecs.showFormPresElection(playername)
end
elseif type(formname)=="string" and formname == "frmEUrnRegCampaign" then
if type(fields.txtCampaign)~= "nil" and type(fields.btnSave) ~= "nil" then
--modEUrn.debug("modEUrn.doPresidentCandidate(playername='"..playername.."', playername='"..playername.."', fields.txtCampaign="..dump(fields.txtCampaign)..")")
if modEUrn.doPresidentCandidate(playername, playername, fields.txtCampaign) then
modEUrn.doSave()
minetest.chat_send_player(
playername,
--os.date("%Y-%m-%d %Hh:%Mm:%Ss", now) ..
core.colorize("#00FF00", "[E-URN]").." "
..modEUrn.translate("Player @1 has been registered to run as a candidate for president of this server!", dump(playername))
)
minetest.sound_play("sfx_eurn_confirm", {to_player=playername, max_hear_distance=5.0,})
end
elseif type(fields.quit) ~= "true" then
minetest.sound_play("sfx_eurn_button", {to_player=playername, max_hear_distance=5.0,})
end
end
end)

View file

@ -10,19 +10,40 @@
## Menu "Eleição Presidencial"
* Botão "Cadidatos Presidenciais" [toMenu: "Lista de Cadidatos Presidenciais"]
* Botão "Presidente Eleito" [toMenu: "Dados do Presidente Eleito"]
* Botão "Regras da Eleição Presidencial" [toMenu: "Regras da Eleição Presidencial"]
* Botão "Escolha seu Presidente" [VisibleIf: "Acessado Por Urna + Maioridade de 72 horas de gameplay"; InVisibleIf: "InternetDevice"; toMenu: "Escolha seu Presidente"]
* Botão "Eleja Agora" [VisibleIf: "Acessado Por Urna + Maioridade de 72 horas de gameplay"; InVisibleIf: "InternetDevice"; toMenu: "Escolha seu Presidente"]
* Botão "Presidente Atual" [toMenu: "Dados do Presidente Eleito"]
* Botão "Cadidatos Presidenciais" [toMenu: "Cadidatos Presidenciais"]
* Botão "Voltar" [toMenu: "Inicial"; VisibleIf: Acessado Por Urna; InVisibleIf: InternetDevice;]
* Botão "Sair" [tecla "ESC"]
### Menu "Cadidatos Presidenciais"
* Lista "Candidatos Presidenciais" (Selecionável)
* Textarea "Propaganda do Candidato Selecionado"
* Botão "Branco" [toMenu: "Painel de Aviso", toMensagem: "Você anulou seu voto!"]
* Botão "Confirmar" [toMenu: "Voto Confirmado"]
* Botão "Cancelar" [toMenu: "Eleição Presidencial"]
#### Menu "Painel de Aviso"
* Imagem "Logotipo da Urna Eketrônics"
* Etiqueta Titulo "URNA ELETRÔNICA"
* Etiqueta "<Mensagem>"
* Botão "Voltar" [toMenu: "Eleição Presidencial"]
#### Menu "Voto Confirmado"
* Imagem "Rosto do Candidato"
* Etiqueta Titulo "<Nome do Cadidato>"
* Etiqueta Mensagem: "Seu voto foi contabilizado. Obrigado!"
* Botão "Voltar" [toMenu: "Eleição Presidencial"]
## Menu "Tribunal Eleitoral"
* Botão "Regras da Eleição" [toMenu: "Regras da Eleição Presidencial"]
* Botão "Candidatar-se a President" [VisibleIf: "Acessed per UrnDevice + Maioridade de 72 horas de gameplay"; InVisibleIf:"Acessed per InternetDevice"; toMenu: "Ficha do Candidato"]
* Botão "Cancelar Candidatura" [VisibleIf: "Acessed per UrnDevice + Maioridade de 72 horas de gameplay"; InVisibleIf:"Acessed per InternetDevice"; toMenu: "Ficha do Candidato"]
* Botão "Configurações da Eleições" [toMenu:"Eleição Presidencial"; VisibleIf: "Acessed per UrnDevice and WithPriv:ElectoralJudge" ; InVisibleIf: "Acessed per InternetDevice or WithOutPriv:ElectoralJudge";]
* Botão "Inscrever-se como Candidato" [VisibleIf: "Acessed per UrnDevice + Maioridade de 72 horas de gameplay"; InVisibleIf:"Acessed per InternetDevice"; toMenu: "Ficha do Candidato"]
* Botão "Voltar" [toMenu: "Inicial"; VisibleIf: "Acessed per UrnDevice"; InVisibleIf:"Acessed per InternetDevice"; ]
* Botão "Sair" [tecla "ESC"]
## Menu "Configurações da Eleições"
@ -30,11 +51,10 @@ Etiqueta "Maioridade Eleitoral"
* Campo: Maioridade dos Eleitores [Padrão: 72 horas reais de gameplay] : Seleciona quantas horas o jogador terá que ter jogado para poder ser um eleitor.
* Campo: Maioridade dos Candidatos [Padrão: 168 horas reais de gameplay] : Seleciona quantas horas o jogador terá que ter jogado para poder ser um candidato a presidente.
* Campo "Perído Probatório" [Padrão: 1 mês real de empoderamento] : Seleciona o tempo máximo que o Presidente terá o poder em suas mãos. Antes de provar que ainda possui a maioria do apoio polular.
* Campo "Prescrição do Voto" [Padrão: 6 meses reais de Prescrição de Voto] : Seleciona o tempo máximo que o voto de um jogador ficará em posse do presidente escolhido individualmente pelo eleito. O eleitor pode deve renovar seu voto antes de acabar o seu tempo individual de prescrição de voto.
* Botão "Salvar e Voltar" [toMenu: "Confirm Settings"]
* Botão "Voltar sem salvar" [toMenu: "Tribunal Eleitoral"]
* Botão "Sair" [tecla "ESC"]
* Campo "Período Probatório" [Padrão: 1 mês real de empoderamento] : Seleciona o tempo máximo que o Presidente terá o poder em suas mãos. Antes de provar que ainda possui a maioria do apoio polular.
* Campo "Vencimento do Voto" [Padrão: 6 meses reais de Prescrição de Voto] : Seleciona o tempo máximo que o voto de um jogador ficará em posse do presidente escolhido individualmente pelo eleito. O eleitor pode deve renovar seu voto antes de acabar o seu tempo individual de prescrição de voto.
* Botão "Salvar e Voltar" [toMenu: "Confirm Settings"]
* Botão "Voltar sem salvar" [toMenu: "Tribunal Eleitoral"]
--------------------------------------------------------

View file

@ -7,7 +7,7 @@ modEUrn.nodeformat = {
minetest.register_node("eurn:eurn", {
description = core.colorize("#00FF00",
modEUrn.translate("E-URN")
).."\n\t* "..modEUrn.translate("Colect opinion of player with electronic urn."),
).."\n\t* "..modEUrn.translate("Item that helps collect votes."),
--inventory_image = minetest.inventorycube("text_eurn_front_1.png"),
--inventory_image = "text_eurn_front_1.png",
paramtype = "light",
@ -37,6 +37,9 @@ minetest.register_node("eurn:eurn", {
meta:set_string("owner",ownername)
end,
on_rightclick = function(pos, node, clicker)
local clickername = clicker:get_player_name()
modEUrn.FormSpecs.showFormMain(clickername)
--[[
local clickername = clicker:get_player_name()
local meta = minetest.get_meta(pos)
@ -128,16 +131,18 @@ minetest.register_node("eurn:eurn", {
--]]
})
--[[
minetest.register_craft({
output = 'eurn:eurn',
recipe = {
{"default:steel_ingot" ,"default:steel_ingot" ,"default:steel_ingot"},
{"default:steel_ingot" ,"default:obsidian_glass" ,"default:steel_ingot"},
{"default:steel_ingot" ,"default:mese" ,"default:steel_ingot"},
}
})
--]]
minetest.register_alias("eurn", "eurn:eurn")
if minetest.settings:get_bool("eurn.crafting_recipe") then --Activate crafting recipe for all players got their own Electronic Urn.
minetest.register_craft({
output = 'eurn:eurn',
recipe = {
{"default:steel_ingot" ,"default:steel_ingot" ,"default:steel_ingot"},
{"default:steel_ingot" ,"default:obsidian_glass" ,"default:steel_ingot"},
{"default:steel_ingot" ,"default:mese" ,"default:steel_ingot"},
}
})
minetest.register_alias("eurn", "eurn:eurn")
end

View file

@ -69,10 +69,10 @@ sudo apt-get install poedit
Translate Sample: [locale/eurn.pt_BR.tr]
```bash
$ cd ./locale/
$ lua5.3 po2tr.lua "eurn" "pt_BR.po"
$ mv "pt_BR.tr" "eurn.pt_BR.tr"
$ cat eurn.pt_BR.tr | less
cd ./locale/
lua5.3 po2tr.lua "eurn" "pt_BR.po"
mv "pt_BR.tr" "eurn.pt_BR.tr"
cat eurn.pt_BR.tr | less
```
-----

64
locale/eurn.pt.tr Normal file
View file

@ -0,0 +1,64 @@
# textdomain: eurn
* %s : %02d votes= * %s : %02d votos
Allows you to configure the Electronic Urn.=Permite configurar a Urna Eletrônica.
Apply Blank Vote.=Aplicar voto em branco.
Apply presidential selection vote counting! (Need the 'electoraljudge' privilege.)=Aplicar a contagem de votos nas eleições presidenciais! (Precisa do privilégio de 'electoraljudge'.)
Are you ready to vote!=Você está pronto para votar!
BACK=VOLTAR
CANCEL=CANCELAR
CONFIRM=CONFIRMAR
Candidate Campaign=Campanha do Candidato
Candidate List: %s=Lista de Candidatos: %s
Candidate Name=Nome do Candidato
Check if you're ready to vote for a presidential candidate!=Verificar se você está pronto para votar em um candidato à presidência!
Database '%s' loaded!=Banco de dados '%s' carregado!
Database saved in file '%s'!=Banco de dados salvo no arquivo '%s'!
Displays the number of votes for each candidate! (Need the 'electoraljudge' privilege!)=Exibe o número de votos para cada candidato! (Precisa do privilégio de 'electoraljudge'!)
E-URN=URNA ELETRÔNICA
ELECTORAL COURT=TRIBUNAL ELEITORAL
EXIT=SAÍDA
Electronic Urn=Urna Eletrônica
Impossible to register login for player '%s' !=Impossível registrar login do jogador '%s'!
Impossible to register logout for player '%s' !=Impossível registrar logout do jogador '%s' !
Item that helps collect votes.=Item que ajuda a arrecadar votos.
No one has voted in the presidential election yet!=Ninguém votou nas eleições presidenciais ainda!
No presidential candidate has yet been elected!=Nenhum candidato presidencial foi eleito ainda!
Number of Candidates: %02d=Número de candidatos: %02d
PRESIDENT ELECT=PRESIDENTE ATUAL
PRESIDENTIAL CANDIDATES=CANDIDATOS PRESIDENCIAIS
PRESIDENTIAL ELECTION=ELEIÇÃO PRESIDENCIAL
Player %s has been named the president of this server!=O jogador %s foi nomeado presidente deste servidor!
Player %s is not registered as a candidate for president!=O jogador %s não está registrado como candidato a presidente!
Player '%s' is not registered as a candidate for president!=O jogador %s não está registrado como candidato a presidente!
Player @1 has been registered to run as a candidate for president of this server!=O jogador @1 foi registrado para concorrer como candidato a presidente deste servidor!
Player @1 has been unregistered to run as a candidate for president of this server!=O jogador @1 foi desinscrito para concorrer como candidato a presidente deste servidor!
Please enter the name of the candidate you wish to display the campaign!=Por favor, insira o nome do candidato que deseja exibir na campanha!
Please enter the name of the presidential candidate you wish to vote!=Por favor, digite o nome do candidato presidencial que você deseja votar!
Political Campaign of=Campanha Política de
REGISTER=REGISTRAR
Register your campaign to run for server president.=Registre sua campanha para concorrer à presidência do servidor.
SELECT=SELECIONAR
Show or Select the presidente of the server.=Exibe ou Seleciona o presidente do servidor.
Show the Campaign of candidate for president.=Exibe a Campanha do candidato a presidente.
Show the name of all candidates for president.=Exibe o nome de todos os candidatos a presidente.
Thanks for your vote!=Obrigado pelo seu voto!
The file '%s' is not in table format!=O arquivo '%s' não está em formato de tabela!
The name '%s' is not the player name registered on the server!=O nome '%s' não é o nome do jogador registrado no servidor!
The president of this server is %s!=O presidente deste servidor é %s!
There are no campaign data about this political candidate.=Não existem dados de campanha sobre este candidato político.
There are no candidates registered!=Não há candidatos cadastrados!
There are no votes registered!=Não há votos registrados!
There is no registered candidate for the presidential election!=Não há candidato registrado para as eleições presidenciais!
Unable to address debug for player '%s'.=Não foi possível resolver a depuração do jogador '%s'.
Unregister your campaign to run for server president.=Cancela o registro de sua campanha para concorrer à presidência do servidor.
Vote for a specific candidate for president.=Vote em um candidato específico para presidente.
Voting list for presidential election: =Lista de votação para as eleições presidenciais:
WHITE=BRANCO
You do not have the 'electoraljudge' privilege to define who will be the president of the server!=Você não tem o privilégio de 'juiz eleitoral' para definir quem será o presidente do servidor!
You have not yet played the minimum number of hours to become a presidential voter. (Minimum %02d hours)=Você ainda não jogou o número mínimo de horas para se tornar um eleitor presidencial. (Mínimo %02d horas)
You only have @1 hours of the @2 minimum game hours to be eligible to vote!=Você só tem @1 horas do mínimo de @2 horas de jogo para poder votar!
You voted blank!=Você votou em Branco!
You voted for the candidate: =Você votou no candidato:
Your name is not registered as a voter.=Seu nome não está registrado como eleitor.
candidate_name=nome_do_candidato
political campaign=campanha política

View file

@ -1,4 +1,64 @@
# textdomain: eurn
* %s : %02d votes= * %s : %02d votos
Allows you to configure the Electronic Urn.=Permite configurar a Urna Eletrônica.
Apply Blank Vote.=Aplicar voto em branco.
Apply presidential selection vote counting! (Need the 'electoraljudge' privilege.)=Aplicar a contagem de votos nas eleições presidenciais! (Precisa do privilégio de 'electoraljudge'.)
Are you ready to vote!=Você está pronto para votar!
BACK=VOLTAR
CANCEL=CANCELAR
CONFIRM=CONFIRMAR
Candidate Campaign=Campanha do Candidato
Candidate List: %s=Lista de Candidatos: %s
Candidate Name=Nome do Candidato
Check if you're ready to vote for a presidential candidate!=Verificar se você está pronto para votar em um candidato à presidência!
Database '%s' loaded!=Banco de dados '%s' carregado!
Database saved in file '%s'!=Banco de dados salvo no arquivo '%s'!
Displays the number of votes for each candidate! (Need the 'electoraljudge' privilege!)=Exibe o número de votos para cada candidato! (Precisa do privilégio de 'electoraljudge'!)
E-URN=URNA ELETRÔNICA
Colect opinion of player with electronic urn.=Colete a opinião do jogador com uma Urna Eletrônica.
ELECTORAL COURT=TRIBUNAL ELEITORAL
EXIT=SAÍDA
Electronic Urn=Urna Eletrônica
Impossible to register login for player '%s' !=Impossível registrar login do jogador '%s'!
Impossible to register logout for player '%s' !=Impossível registrar logout do jogador '%s' !
Item that helps collect votes.=Item que ajuda a arrecadar votos.
No one has voted in the presidential election yet!=Ninguém votou nas eleições presidenciais ainda!
No presidential candidate has yet been elected!=Nenhum candidato presidencial foi eleito ainda!
Number of Candidates: %02d=Número de candidatos: %02d
PRESIDENT ELECT=PRESIDENTE ATUAL
PRESIDENTIAL CANDIDATES=CANDIDATOS PRESIDENCIAIS
PRESIDENTIAL ELECTION=ELEIÇÃO PRESIDENCIAL
Player %s has been named the president of this server!=O jogador %s foi nomeado presidente deste servidor!
Player %s is not registered as a candidate for president!=O jogador %s não está registrado como candidato a presidente!
Player '%s' is not registered as a candidate for president!=O jogador %s não está registrado como candidato a presidente!
Player @1 has been registered to run as a candidate for president of this server!=O jogador @1 foi registrado para concorrer como candidato a presidente deste servidor!
Player @1 has been unregistered to run as a candidate for president of this server!=O jogador @1 foi desinscrito para concorrer como candidato a presidente deste servidor!
Please enter the name of the candidate you wish to display the campaign!=Por favor, insira o nome do candidato que deseja exibir na campanha!
Please enter the name of the presidential candidate you wish to vote!=Por favor, digite o nome do candidato presidencial que você deseja votar!
Political Campaign of=Campanha Política de
REGISTER=REGISTRAR
Register your campaign to run for server president.=Registre sua campanha para concorrer à presidência do servidor.
SELECT=SELECIONAR
Show or Select the presidente of the server.=Exibe ou Seleciona o presidente do servidor.
Show the Campaign of candidate for president.=Exibe a Campanha do candidato a presidente.
Show the name of all candidates for president.=Exibe o nome de todos os candidatos a presidente.
Thanks for your vote!=Obrigado pelo seu voto!
The file '%s' is not in table format!=O arquivo '%s' não está em formato de tabela!
The name '%s' is not the player name registered on the server!=O nome '%s' não é o nome do jogador registrado no servidor!
The president of this server is %s!=O presidente deste servidor é %s!
There are no campaign data about this political candidate.=Não existem dados de campanha sobre este candidato político.
There are no candidates registered!=Não há candidatos cadastrados!
There are no votes registered!=Não há votos registrados!
There is no registered candidate for the presidential election!=Não há candidato registrado para as eleições presidenciais!
Unable to address debug for player '%s'.=Não foi possível resolver a depuração do jogador '%s'.
Unregister your campaign to run for server president.=Cancela o registro de sua campanha para concorrer à presidência do servidor.
Vote for a specific candidate for president.=Vote em um candidato específico para presidente.
Voting list for presidential election: =Lista de votação para as eleições presidenciais:
WHITE=BRANCO
You do not have the 'electoraljudge' privilege to define who will be the president of the server!=Você não tem o privilégio de 'juiz eleitoral' para definir quem será o presidente do servidor!
You have not yet played the minimum number of hours to become a presidential voter. (Minimum %02d hours)=Você ainda não jogou o número mínimo de horas para se tornar um eleitor presidencial. (Mínimo %02d horas)
You only have @1 hours of the @2 minimum game hours to be eligible to vote!=Você só tem @1 horas do mínimo de @2 horas de jogo para poder votar!
You voted blank!=Você votou em Branco!
You voted for the candidate: =Você votou no candidato:
Your name is not registered as a voter.=Seu nome não está registrado como eleitor.
candidate_name=nome_do_candidato
political campaign=campanha política

View file

@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: pt_BR 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-20 19:44-0300\n"
"PO-Revision-Date: 2023-07-20 19:59-0300\n"
"POT-Creation-Date: 2024-03-03 00:41-0300\n"
"PO-Revision-Date: 2024-02-28 11:19-0300\n"
"Last-Translator: Lunovox Heavenfinder <lunovox@disroot.org>\n"
"Language-Team: Lunovox Heavenfinder\n"
"Language: pt_BR\n"
@ -17,16 +17,295 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 3.3.1\n"
"X-Generator: Poedit 3.4\n"
#: item_eurn.lua:9
#: commands.lua:322 commands.lua:324
#, lua-format
msgid " * %s : %02d votes"
msgstr " * %s : %02d votos"
#: api.lua:6
msgid "Allows you to configure the Electronic Urn."
msgstr "Permite configurar a Urna Eletrônica."
#: commands.lua:267
msgid "Apply Blank Vote."
msgstr "Aplicar voto em branco."
#: commands.lua:366
msgid "Apply presidential selection vote counting! (Need the 'electoraljudge' privilege.)"
msgstr "Aplicar a contagem de votos nas eleições presidenciais! (Precisa do privilégio de 'electoraljudge'.)"
#: commands.lua:208
msgid "Are you ready to vote!"
msgstr "Você está pronto para votar!"
#: formspecs.lua:28
msgid "BACK"
msgstr "VOLTAR"
#: formspecs.lua:64 formspecs.lua:135 formspecs.lua:201 formspecs.lua:251
msgid "CANCEL"
msgstr "CANCELAR"
#: formspecs.lua:129 formspecs.lua:247
msgid "CONFIRM"
msgstr "CONFIRMAR"
#: api.lua:304
msgid "Candidate Campaign"
msgstr "Campanha do Candidato"
#: commands.lua:162
#, lua-format
msgid "Candidate List: %s"
msgstr "Lista de Candidatos: %s"
#: api.lua:294
msgid "Candidate Name"
msgstr "Nome do Candidato"
#: commands.lua:201
msgid "Check if you're ready to vote for a presidential candidate!"
msgstr "Verificar se você está pronto para votar em um candidato à presidência!"
#: api.lua:114
#, lua-format
msgid "Database '%s' loaded!"
msgstr "Banco de dados '%s' carregado!"
#: api.lua:94
#, lua-format
msgid "Database saved in file '%s'!"
msgstr "Banco de dados salvo no arquivo '%s'!"
#: commands.lua:300
msgid "Displays the number of votes for each candidate! (Need the 'electoraljudge' privilege!)"
msgstr "Exibe o número de votos para cada candidato! (Precisa do privilégio de 'electoraljudge'!)"
#: api.lua:273 formspecs.lua:352 formspecs.lua:395 item_eurn.lua:9
msgid "E-URN"
msgstr "URNA ELETRÔNICA"
#: item_eurn.lua:10
msgid "Colect opinion of player with electronic urn."
msgstr "Colete a opinião do jogador com uma Urna Eletrônica."
#: formspecs.lua:12
msgid "ELECTORAL COURT"
msgstr "TRIBUNAL ELEITORAL"
#: formspecs.lua:14
msgid "EXIT"
msgstr "SAÍDA"
#: item_eurn.lua:36
msgid "Electronic Urn"
msgstr "Urna Eletrônica"
#: api.lua:451
#, lua-format
msgid "Impossible to register login for player '%s' !"
msgstr "Impossível registrar login do jogador '%s'!"
#: api.lua:133
#, lua-format
msgid "Impossible to register logout for player '%s' !"
msgstr "Impossível registrar logout do jogador '%s' !"
#: item_eurn.lua:10
msgid "Item that helps collect votes."
msgstr "Item que ajuda a arrecadar votos."
#: commands.lua:339
msgid "No one has voted in the presidential election yet!"
msgstr "Ninguém votou nas eleições presidenciais ainda!"
#: formspecs.lua:354
msgid "No presidential candidate has yet been elected!"
msgstr "Nenhum candidato presidencial foi eleito ainda!"
#: commands.lua:157
#, lua-format
msgid "Number of Candidates: %02d"
msgstr "Número de candidatos: %02d"
#: formspecs.lua:26 formspecs.lua:348
msgid "PRESIDENT ELECT"
msgstr "PRESIDENTE ATUAL"
#: formspecs.lua:25
msgid "PRESIDENTIAL CANDIDATES"
msgstr "CANDIDATOS PRESIDENCIAIS"
#: formspecs.lua:11
msgid "PRESIDENTIAL ELECTION"
msgstr "ELEIÇÃO PRESIDENCIAL"
#: api.lua:403 commands.lua:36
#, lua-format
msgid "Player %s has been named the president of this server!"
msgstr "O jogador %s foi nomeado presidente deste servidor!"
#: api.lua:314
#, lua-format
msgid "Player %s is not registered as a candidate for president!"
msgstr "O jogador %s não está registrado como candidato a presidente!"
#: api.lua:369
#, lua-format
msgid "Player '%s' is not registered as a candidate for president!"
msgstr "O jogador %s não está registrado como candidato a presidente!"
#: commands.lua:90 formspecs.lua:448
msgid "Player @1 has been registered to run as a candidate for president of this server!"
msgstr "O jogador @1 foi registrado para concorrer como candidato a presidente deste servidor!"
#: commands.lua:124
msgid "Player @1 has been unregistered to run as a candidate for president of this server!"
msgstr "O jogador @1 foi desinscrito para concorrer como candidato a presidente deste servidor!"
#: api.lua:330
msgid "Please enter the name of the candidate you wish to display the campaign!"
msgstr "Por favor, insira o nome do candidato que deseja exibir na campanha!"
#: api.lua:375
msgid "Please enter the name of the presidential candidate you wish to vote!"
msgstr "Por favor, digite o nome do candidato presidencial que você deseja votar!"
#: formspecs.lua:195
msgid "Political Campaign of"
msgstr "Campanha Política de"
#: formspecs.lua:200
msgid "REGISTER"
msgstr "REGISTRAR"
#: commands.lua:76
msgid "Register your campaign to run for server president."
msgstr "Registre sua campanha para concorrer à presidência do servidor."
#: formspecs.lua:68
msgid "SELECT"
msgstr "SELECIONAR"
#: commands.lua:26
msgid "Show or Select the presidente of the server."
msgstr "Exibe ou Seleciona o presidente do servidor."
#: commands.lua:179
msgid "Show the Campaign of candidate for president."
msgstr "Exibe a Campanha do candidato a presidente."
#: commands.lua:140
msgid "Show the name of all candidates for president."
msgstr "Exibe o nome de todos os candidatos a presidente."
#: formspecs.lua:404
msgid "Thanks for your vote!"
msgstr "Obrigado pelo seu voto!"
#: api.lua:96 api.lua:110
#, lua-format
msgid "The file '%s' is not in table format!"
msgstr "O arquivo '%s' não está em formato de tabela!"
#: api.lua:195 api.lua:218 api.lua:322 api.lua:372
#, lua-format
msgid "The name '%s' is not the player name registered on the server!"
msgstr "O nome '%s' não é o nome do jogador registrado no servidor!"
#: commands.lua:52
#, lua-format
msgid "The president of this server is %s!"
msgstr "O presidente deste servidor é %s!"
#: api.lua:225
msgid "There are no campaign data about this political candidate."
msgstr "Não existem dados de campanha sobre este candidato político."
#: api.lua:413
msgid "There are no candidates registered!"
msgstr "Não há candidatos cadastrados!"
#: api.lua:410
msgid "There are no votes registered!"
msgstr "Não há votos registrados!"
#: commands.lua:347
msgid "There is no registered candidate for the presidential election!"
msgstr "Não há candidato registrado para as eleições presidenciais!"
#: api.lua:30
#, lua-format
msgid "Unable to address debug for player '%s'."
msgstr "Não foi possível resolver a depuração do jogador '%s'."
#: commands.lua:109
msgid "Unregister your campaign to run for server president."
msgstr "Cancela o registro de sua campanha para concorrer à presidência do servidor."
#: commands.lua:238
msgid "Vote for a specific candidate for president."
msgstr "Vote em um candidato específico para presidente."
#: commands.lua:330
msgid "Voting list for presidential election: "
msgstr "Lista de votação para as eleições presidenciais: "
#: formspecs.lua:60 formspecs.lua:127 formspecs.lua:245
msgid "WHITE"
msgstr "BRANCO"
#: commands.lua:44
msgid "You do not have the 'electoraljudge' privilege to define who will be the president of the server!"
msgstr "Você não tem o privilégio de 'juiz eleitoral' para definir quem será o presidente do servidor!"
#: api.lua:352 api.lua:378
#, lua-format
msgid "You have not yet played the minimum number of hours to become a presidential voter. (Minimum %02d hours)"
msgstr "Você ainda não jogou o número mínimo de horas para se tornar um eleitor presidencial. (Mínimo %02d horas)"
#: commands.lua:212
msgid "You only have @1 hours of the @2 minimum game hours to be eligible to vote!"
msgstr "Você só tem @1 horas do mínimo de @2 horas de jogo para poder votar!"
#: api.lua:350
msgid "You voted blank!"
msgstr "Você votou em Branco!"
#: api.lua:367
msgid "You voted for the candidate: "
msgstr "Você votou no candidato: "
#: api.lua:381
msgid "Your name is not registered as a voter."
msgstr "Seu nome não está registrado como eleitor."
#: api.lua:333 api.lua:375 commands.lua:25 commands.lua:178 commands.lua:237
msgid "candidate_name"
msgstr "nome_do_candidato"
#: commands.lua:75
msgid "political campaign"
msgstr "campanha política"
#~ msgid "CLOSE"
#~ msgstr "FECHAR"
#~ msgid "Colect opinion of player with electronic urn."
#~ msgstr "Colete a opinião do jogador com uma Urna Eletrônica."
#, lua-format
#~ msgid "Player %s has been registered to run as a candidate for president of this server!"
#~ msgstr "O jogador %s foi registrado para concorrer como candidato a presidente deste servidor!"
#, lua-format
#~ msgid "Player %s has been unregistered to run as a candidate for president of this server!"
#~ msgstr "O jogador %s teve seu registro cancelado para concorrer como candidato a presidente deste servidor!"
#, lua-format
#~ msgid "Player %s is listing campaign data..."
#~ msgstr "O jogador %s está listando dados da campanha..."
#~ msgid "VOTE"
#~ msgstr "VOTAR"
#~ msgid "You can't have registered vote!"
#~ msgstr "Você não pode ter voto registrado!"

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-20 19:44-0300\n"
"POT-Creation-Date: 2024-03-03 00:41-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,12 +17,281 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: item_eurn.lua:9
#: api.lua:6
msgid "Allows you to configure the Electronic Urn."
msgstr ""
#: api.lua:30
#, lua-format
msgid "Unable to address debug for player '%s'."
msgstr ""
#: api.lua:94
#, lua-format
msgid "Database saved in file '%s'!"
msgstr ""
#: api.lua:96 api.lua:110
#, lua-format
msgid "The file '%s' is not in table format!"
msgstr ""
#: api.lua:114
#, lua-format
msgid "Database '%s' loaded!"
msgstr ""
#: api.lua:133
#, lua-format
msgid "Impossible to register logout for player '%s' !"
msgstr ""
#: api.lua:195 api.lua:218 api.lua:322 api.lua:372
#, lua-format
msgid "The name '%s' is not the player name registered on the server!"
msgstr ""
#: api.lua:225
msgid "There are no campaign data about this political candidate."
msgstr ""
#: api.lua:273 formspecs.lua:352 formspecs.lua:395 item_eurn.lua:9
msgid "E-URN"
msgstr ""
#: api.lua:294
msgid "Candidate Name"
msgstr ""
#: api.lua:304
msgid "Candidate Campaign"
msgstr ""
#: api.lua:314
#, lua-format
msgid "Player %s is not registered as a candidate for president!"
msgstr ""
#: api.lua:330
msgid ""
"Please enter the name of the candidate you wish to display the campaign!"
msgstr ""
#: api.lua:333 api.lua:375 commands.lua:25 commands.lua:178 commands.lua:237
msgid "candidate_name"
msgstr ""
#: api.lua:350
msgid "You voted blank!"
msgstr ""
#: api.lua:352 api.lua:378
#, lua-format
msgid ""
"You have not yet played the minimum number of hours to become a presidential "
"voter. (Minimum %02d hours)"
msgstr ""
#: api.lua:367
msgid "You voted for the candidate: "
msgstr ""
#: api.lua:369
#, lua-format
msgid "Player '%s' is not registered as a candidate for president!"
msgstr ""
#: api.lua:375
msgid "Please enter the name of the presidential candidate you wish to vote!"
msgstr ""
#: api.lua:381
msgid "Your name is not registered as a voter."
msgstr ""
#: api.lua:403 commands.lua:36
#, lua-format
msgid "Player %s has been named the president of this server!"
msgstr ""
#: api.lua:410
msgid "There are no votes registered!"
msgstr ""
#: api.lua:413
msgid "There are no candidates registered!"
msgstr ""
#: api.lua:451
#, lua-format
msgid "Impossible to register login for player '%s' !"
msgstr ""
#: commands.lua:26
msgid "Show or Select the presidente of the server."
msgstr ""
#: commands.lua:44
msgid ""
"You do not have the 'electoraljudge' privilege to define who will be the "
"president of the server!"
msgstr ""
#: commands.lua:52
#, lua-format
msgid "The president of this server is %s!"
msgstr ""
#: commands.lua:75
msgid "political campaign"
msgstr ""
#: commands.lua:76
msgid "Register your campaign to run for server president."
msgstr ""
#: commands.lua:90 formspecs.lua:448
msgid ""
"Player @1 has been registered to run as a candidate for president of this "
"server!"
msgstr ""
#: commands.lua:109
msgid "Unregister your campaign to run for server president."
msgstr ""
#: commands.lua:124
msgid ""
"Player @1 has been unregistered to run as a candidate for president of this "
"server!"
msgstr ""
#: commands.lua:140
msgid "Show the name of all candidates for president."
msgstr ""
#: commands.lua:157
#, lua-format
msgid "Number of Candidates: %02d"
msgstr ""
#: commands.lua:162
#, lua-format
msgid "Candidate List: %s"
msgstr ""
#: commands.lua:179
msgid "Show the Campaign of candidate for president."
msgstr ""
#: commands.lua:201
msgid "Check if you're ready to vote for a presidential candidate!"
msgstr ""
#: commands.lua:208
msgid "Are you ready to vote!"
msgstr ""
#: commands.lua:212
msgid ""
"You only have @1 hours of the @2 minimum game hours to be eligible to vote!"
msgstr ""
#: commands.lua:238
msgid "Vote for a specific candidate for president."
msgstr ""
#: commands.lua:267
msgid "Apply Blank Vote."
msgstr ""
#: commands.lua:300
msgid ""
"Displays the number of votes for each candidate! (Need the 'electoraljudge' "
"privilege!)"
msgstr ""
#: commands.lua:322 commands.lua:324
#, lua-format
msgid " * %s : %02d votes"
msgstr ""
#: commands.lua:330
msgid "Voting list for presidential election: "
msgstr ""
#: commands.lua:339
msgid "No one has voted in the presidential election yet!"
msgstr ""
#: commands.lua:347
msgid "There is no registered candidate for the presidential election!"
msgstr ""
#: commands.lua:366
msgid ""
"Apply presidential selection vote counting! (Need the 'electoraljudge' "
"privilege.)"
msgstr ""
#: formspecs.lua:11
msgid "PRESIDENTIAL ELECTION"
msgstr ""
#: formspecs.lua:12
msgid "ELECTORAL COURT"
msgstr ""
#: formspecs.lua:14
msgid "EXIT"
msgstr ""
#: formspecs.lua:25
msgid "PRESIDENTIAL CANDIDATES"
msgstr ""
#: formspecs.lua:26 formspecs.lua:348
msgid "PRESIDENT ELECT"
msgstr ""
#: formspecs.lua:28
msgid "BACK"
msgstr ""
#: formspecs.lua:60 formspecs.lua:127 formspecs.lua:245
msgid "WHITE"
msgstr ""
#: formspecs.lua:64 formspecs.lua:135 formspecs.lua:201 formspecs.lua:251
msgid "CANCEL"
msgstr ""
#: formspecs.lua:68
msgid "SELECT"
msgstr ""
#: formspecs.lua:129 formspecs.lua:247
msgid "CONFIRM"
msgstr ""
#: formspecs.lua:195
msgid "Political Campaign of"
msgstr ""
#: formspecs.lua:200
msgid "REGISTER"
msgstr ""
#: formspecs.lua:354
msgid "No presidential candidate has yet been elected!"
msgstr ""
#: formspecs.lua:404
msgid "Thanks for your vote!"
msgstr ""
#: item_eurn.lua:10
msgid "Colect opinion of player with electronic urn."
msgid "Item that helps collect votes."
msgstr ""
#: item_eurn.lua:36

View file

@ -1,10 +1,17 @@
# suggestion over this file: http://dev.minetest.net/Modding_Intro
name = eurn
description = Colect opinion of player with electronic urn.
release = 0.1.0
author = Lunovox Heavenfinder
title = Electronic Urn
description = Adds a presidential election system and an Electronic Urn as an item that helps collect votes.
release = 0.3.3
author = Lunovox Heavenfinder: [email](mailto:lunovox@disroot.org), [social web](http:qoto.org/@lunovox), [webchat](https://cloud.disroot.org/call/9aa2t7ib), [xmpp](xmpp:lunovox@disroot.org?join), [Mumble](mumble:mumble.disroot.org), [more contacts](https:libreplanet.org/wiki/User:Lunovox)
license = GNU AGPL-3.0
depends = default
optional_depends = intllib,tradelands,correio
optional_depends =
min_minetest_version = 5.7
max_minetest_version =
created = 2017-03-13 00:00
update = 2024-03-03 00:00
repository = https://gitlab.com/lunovox/e-urn

21
settingtypes.txt Normal file
View file

@ -0,0 +1,21 @@
# E-URN:
# Allows you to print the debug information of this mod on the screen.
# Default: false
eurn.debug (Show E-Urn Debug) bool false
# E-URN:
# Whether the database will be BASE64 compressed.
# If enabled will save database bank without compression in file '.db'.
# Default: true
eurn.save_compressed (Database Compressed) bool true
# E-URN:
# Minimum game time in hours to become a voter.
# Default: 72 | Min: 0 | Max: 8760
eurn.voter.min_played_hours (Minimum Game Hours) int 72 0 8760
# E-URN:
# Activate crafting recipe for all players got their own Electronic Urn.
# Default: false
eurn.crafting_recipe (E-Urn Crafting Recipe) bool false

BIN
sounds/sfx_failure.ogg Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB