diff --git a/.rascunhos/Som da Urna Eletrônica - Efeitos Sonoros.mp4 b/.rascunhos/Som da Urna Eletrônica - Efeitos Sonoros.mp4 new file mode 100644 index 0000000..d4b0558 Binary files /dev/null and b/.rascunhos/Som da Urna Eletrônica - Efeitos Sonoros.mp4 differ diff --git a/.rascunhos/sfx_eurn_unedited.ogg b/.rascunhos/sfx_eurn_unedited.ogg new file mode 100644 index 0000000..60b6be1 Binary files /dev/null and b/.rascunhos/sfx_eurn_unedited.ogg differ diff --git a/api.lua b/api.lua new file mode 100644 index 0000000..4296f1e --- /dev/null +++ b/api.lua @@ -0,0 +1,115 @@ +minetest.register_privilege("electoraljudge", { + description=modEUrn.translate("Allows you to configure the Electronic Urn."), + give_to_singleplayer=false, +}) + +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. + }, + }, + candidates = { + president = { }, --modEUrn.handler.candidates.president[] = | If the candidate has not updated his candidacy for more than 6 months, he loses his candidacy application. + }, + --]] + voters = { }, --modEUrn.handler.voters[playername] +} + +modEUrn.doSave = function() + local file = io.open(modEUrn.urlTabela, "w") + if file then + file:write(minetest.serialize(modEUrn.handler)) + file:close() + minetest.log('action',"[E-URN] "..modEUrn.translate("Database saved in file '%s'!"):format(modEUrn.urlTabela)) + else + minetest.log('error',"[E-URN:ERRO] "..modEUrn.translate("The file '%s' is not in table format!"):format(modEUrn.urlTabela)) + end +end + +modEUrn.doLoad = function() + local file = io.open(modEUrn.urlTabela, "r") + if file then + local handler = minetest.deserialize(file:read("*all")) + 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)) + return { } + else + modEUrn.handler = handler + minetest.log('action',"[E-URN] "..modEUrn.translate("Database '%s' loaded!"):format(modEUrn.urlTabela)) + end + end +end + +modEUrn.on_leaveplayer = function(player) + local playername = player:get_player_name() + local now = os.time() --Em milisegundos + if modEUrn.handler.voters[playername]~=nil and type(modEUrn.handler.voters[playername]) == "table" then + if modEUrn.handler.voters[playername].times.login~=nil and type(modEUrn.handler.voters[playername].times.login) == "number" and modEUrn.handler.voters[playername].times.login > 0 then + if modEUrn.handler.voters[playername].times.played~=nil and type(modEUrn.handler.voters[playername].times.played) == "number" and modEUrn.handler.voters[playername].times.played > 0 then + modEUrn.handler.voters[playername].times.played = modEUrn.handler.voters[playername].times.played + (now - modEUrn.handler.voters[playername].times.login) + else + modEUrn.handler.voters[playername].times.played = (now - modEUrn.handler.voters[playername].times.login) + end + modEUrn.handler.voters[playername].times.login = 0 + modEUrn.handler.voters[playername].times.logout = now + end + else + minetest.log('error',"[E-URN:ERROR:ONLEAVEPLAYER] "..modEUrn.translate("Impossible to register logout for player '%s' !"):format(dump(player))) + end +end + +minetest.register_on_leaveplayer(function(player) + modEUrn.on_leaveplayer(player) + modEUrn.doSave() +end) + +--[[ +minetest.register_on_newplayer(function(player) + +end) +--]] + +--[[ +minetest.register_on_prejoinplayer(function(name, ip) + +end) +--]] + +minetest.register_on_joinplayer(function(player) + local playername = player:get_player_name() + local now = os.time() --Em milisegundos + if playername~=nil and type(playername)=="string" and playername~="" then + if modEUrn.handler.voters[playername]==nil then + modEUrn.handler.voters[playername] = { + times ={ + register = now, + played = 0, + login = now, + logout = 0, + }, + } + end + modEUrn.handler.voters[playername].times.login = now + modEUrn.handler.voters[playername].times.logout = 0 + else + minetest.log('error',"[E-URN:ERROR:ONJOINPLAYER] "..modEUrn.translate("Impossible to register login for player '%s' !"):format(dump(player))) + end +end) + +minetest.register_on_shutdown(function() + local players = minetest.get_connected_players() + if #players >= 1 then + for _, player in ipairs(players) do + modEUrn.on_leaveplayer(player) + end + end + modEUrn.doSave() + minetest.log('action',"[E-URN] "..modEUrn.translate("Saving strongbox from all players in the file '%s'!"):format(modEUrn.urlTabela)) +end) + + diff --git a/commands.lua b/commands.lua new file mode 100644 index 0000000..f5f0a0b --- /dev/null +++ b/commands.lua @@ -0,0 +1,60 @@ +--[[ +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. + }, + }, +candidates = { + president = { }, + }, +--]] + +modEUrn.getPropCommPresident = function() + local now = os.time() --Em milisegundos + return { + privs = {server=true}, + --params = "<".. modCorreio.translate("message")..">", + description = modEUrn.translate("Select the presidente of the server."), + func = function(playername, param) + local who = param + if modEUrn.handler.elected==nil then + modEUrn.handler.elected = { } + end + if modEUrn.handler.elected.president==nil then + modEUrn.handler.elected.president = { } + end + modEUrn.handler.elected.president.name = who + modEUrn.handler.elected.president.when = now + if modEUrn.handler.elected.president.voters==nil then + modEUrn.handler.elected.president.voters = { } + end + modEUrn.handler.elected.president.voters[playername] = now + + if modEUrn.handler.candidates==nil then + modEUrn.handler.candidates = { } + end + if modEUrn.handler.candidates.president==nil then + modEUrn.handler.candidates.president = { } + end + modEUrn.handler.candidates.president[who] = now + + minetest.chat_send_player( + playername, + --os.date("%Y-%m-%d %Hh:%Mm:%Ss", now) .. + "[E-URN] "..modEUrn.translate("Player '%s' has been named the president of this server!"):format(who) + ) + end, + } +end + +minetest.register_chatcommand( + "president", + modEUrn.getPropCommPresident() +) + +minetest.register_chatcommand( + modEUrn.translate("president"), + modEUrn.getPropCommPresident() +) diff --git a/init.lua b/init.lua index fca6ec9..c65475d 100644 --- a/init.lua +++ b/init.lua @@ -1,8 +1,14 @@ -modEUrn = {} -modEUrn.modname = minetest.get_current_modname() -modEUrn.modpath = minetest.get_modpath(modEUrn.modname) +modEUrn = { + modname = minetest.get_current_modname(), + modpath = minetest.get_modpath(minetest.get_current_modname()), + urlTabela = minetest.get_worldpath().."/e-urn.db", --Extensao '.tbl' ou '.db' +} dofile(modEUrn.modpath.."/translate.lua") -- <== Antes de 'api.lua'! +dofile(modEUrn.modpath.."/api.lua") +dofile(modEUrn.modpath.."/commands.lua") dofile(modEUrn.modpath.."/item_eurn.lua") -minetest.log('action',"["..modEUrn.modname:upper().."] Loaded!") \ No newline at end of file +modEUrn.doLoad() + +minetest.log('action',"["..modEUrn.modname:upper().."] Loaded!") diff --git a/item_eurn.lua b/item_eurn.lua index 8559830..cc107da 100644 --- a/item_eurn.lua +++ b/item_eurn.lua @@ -36,7 +36,16 @@ minetest.register_node("eurn:eurn", { meta:set_string("infotext", modEUrn.translate("Electronic Urn")) meta:set_string("owner",ownername) end, - + on_rightclick = function(pos, node, clicker) + local clickername = clicker:get_player_name() + local meta = minetest.get_meta(pos) + local ownername = meta:get_string("owner") + if ownername == clickername then + minetest.sound_play("sfx_eurn_button", {object=clicker, max_hear_distance=5.0,}) + end + end, + + --[[ on_rightclick = function(pos, node, clicker) local clickername = clicker:get_player_name() @@ -112,3 +121,17 @@ minetest.register_node("eurn:eurn", { end, --]] }) + +--[[ +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") + diff --git a/locale/.xdp-pt_BRtmpd.mo.UnffAq-oaoY1Y b/locale/.xdp-pt_BRtmpd.mo.UnffAq-oaoY1Y new file mode 100644 index 0000000..86a1d5a Binary files /dev/null and b/locale/.xdp-pt_BRtmpd.mo.UnffAq-oaoY1Y differ diff --git a/locale/README.md b/locale/README.md index 1ff6702..d2d63ca 100644 --- a/locale/README.md +++ b/locale/README.md @@ -1,15 +1,15 @@ # TRANSLATES -Update: 2023-03-19 -version of Readme: 1.5 +Update: 2023-07-20 +version of Readme: 1.6 ----- To generate file [template.pot], did use terminal command: ```bash -cd soundchat -xgettext -n *.lua -L Lua --force-po --keyword=modSoundChat.translate --from-code=UTF-8 -o ./locale/template.pot +cd eurn +xgettext -n *.lua -L Lua --force-po --keyword=modEUrn.translate --from-code=UTF-8 -o ./locale/template.pot ``` ----- @@ -67,12 +67,12 @@ sudo apt-get install poedit ### Convert '.po' file to '.tr' file. -Translate Sample: [locale/soundchat.pt_BR.tr] +Translate Sample: [locale/eurn.pt_BR.tr] ```bash $ cd ./locale/ -$ lua5.3 po2tr.lua "soundchat" "pt_BR.po" -$ mv "pt_BR.tr" "soundchat.pt_BR.tr" -$ cat soundchat.pt_BR.tr | less +$ lua5.3 po2tr.lua "eurn" "pt_BR.po" +$ mv "pt_BR.tr" "eurn.pt_BR.tr" +$ cat eurn.pt_BR.tr | less ``` ----- @@ -80,7 +80,7 @@ $ cat soundchat.pt_BR.tr | less ### Exemple of enable the brazilian portuguese language in minetest: -Translate Sample: `locale/soundchat.pt_BR.tr` +Translate Sample: `locale/eurn.pt_BR.tr` To enable the translate to brazilian portuguese language, write "language = pt_BR" in file "minetest.conf". Or write the command ```/set -n language pt_BR``` in game chat, and run again the minetest game. @@ -88,7 +88,7 @@ To enable the translate to brazilian portuguese language, write "language = pt_B ### PLEASE SUBMIT YOUR NEW TRANSLATION TO THE DEVELOPERS OF THIS MOD THROUGH THE GIT PROJECT BELOW: -* `https://gitlab.com/lunovox/soundchat` +* `https://gitlab.com/lunovox/eurn` ---- @@ -98,8 +98,8 @@ To enable the translate to brazilian portuguese language, write "language = pt_B * https://gist.githubusercontent.com/mamchenkov/3690981/raw/8ebd48c2af20c893c164e8d5245d9450ad682104/update_translations.sh * https://gitlab.com/4w/xtend/-/blob/master/xtend_default/tools/convert_po_file_to_tr_file/convert_po_file_to_tr_file.lua -[locale/pt_BR.po]:https://gitlab.com/lunovox/soundchat/-/raw/master/locale/pt_BR.po -[locale/soundchat.pt_BR.tr]:https://gitlab.com/lunovox/soundchat/-/raw/master/locale/soundchat.pt_BR.tr +[locale/pt_BR.po]:https://gitlab.com/lunovox/eurn/-/raw/master/locale/pt_BR.po +[locale/eurn.pt_BR.tr]:https://gitlab.com/lunovox/eurn/-/raw/master/locale/eurn.pt_BR.tr [PoEdit]:https://poedit.net -[template.pot]:https://gitlab.com/lunovox/soundchat/-/raw/master/locale/template.pot +[template.pot]:https://gitlab.com/lunovox/eurn/-/raw/master/locale/template.pot diff --git a/locale/eurn.pt_BR.tr b/locale/eurn.pt_BR.tr new file mode 100644 index 0000000..aea02c8 --- /dev/null +++ b/locale/eurn.pt_BR.tr @@ -0,0 +1,4 @@ +# textdomain: eurn +E-URN=URNA ELETRÔNICA +Colect opinion of player with electronic urn.=Colete a opinião do jogador com uma Urna Eletrônica. +Electronic Urn=Urna Eletrônica diff --git a/locale/pt_BR.po b/locale/pt_BR.po new file mode 100644 index 0000000..cc443a5 --- /dev/null +++ b/locale/pt_BR.po @@ -0,0 +1,32 @@ +# Portuguese translations for PACKAGE package +# Traduções em português brasileiro para o pacote PACKAGE. +# Copyright (C) 2023 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Automatically generated, 2023. +# +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" +"Last-Translator: Lunovox Heavenfinder \n" +"Language-Team: Lunovox Heavenfinder\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"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" + +#: 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." + +#: item_eurn.lua:36 +msgid "Electronic Urn" +msgstr "Urna Eletrônica" diff --git a/locale/template.pot b/locale/template.pot new file mode 100644 index 0000000..bf1511c --- /dev/null +++ b/locale/template.pot @@ -0,0 +1,30 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-07-20 19:44-0300\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: item_eurn.lua:9 +msgid "E-URN" +msgstr "" + +#: item_eurn.lua:10 +msgid "Colect opinion of player with electronic urn." +msgstr "" + +#: item_eurn.lua:36 +msgid "Electronic Urn" +msgstr "" diff --git a/sounds/sfx_eurn_button.1.ogg b/sounds/sfx_eurn_button.1.ogg new file mode 100644 index 0000000..1062b23 Binary files /dev/null and b/sounds/sfx_eurn_button.1.ogg differ diff --git a/sounds/sfx_eurn_button.2.ogg b/sounds/sfx_eurn_button.2.ogg new file mode 100644 index 0000000..35aa4ad Binary files /dev/null and b/sounds/sfx_eurn_button.2.ogg differ diff --git a/sounds/sfx_eurn_button.3.ogg b/sounds/sfx_eurn_button.3.ogg new file mode 100644 index 0000000..f7bb246 Binary files /dev/null and b/sounds/sfx_eurn_button.3.ogg differ diff --git a/sounds/sfx_eurn_button.4.ogg b/sounds/sfx_eurn_button.4.ogg new file mode 100644 index 0000000..787c525 Binary files /dev/null and b/sounds/sfx_eurn_button.4.ogg differ diff --git a/sounds/sfx_eurn_button.5.ogg b/sounds/sfx_eurn_button.5.ogg new file mode 100644 index 0000000..67d5f3f Binary files /dev/null and b/sounds/sfx_eurn_button.5.ogg differ diff --git a/sounds/sfx_eurn_confirm.ogg b/sounds/sfx_eurn_confirm.ogg new file mode 100644 index 0000000..beee454 Binary files /dev/null and b/sounds/sfx_eurn_confirm.ogg differ