From 169d86e448e69c884dd6eace628ee6102f6b5549 Mon Sep 17 00:00:00 2001 From: Lunovox Heavenfinder Date: Thu, 16 Apr 2020 18:08:31 -0300 Subject: [PATCH] =?UTF-8?q?BOTOES=20'DEPOSITAR=20TODO'=20e=20'SACAR=20TUDO?= =?UTF-8?q?'=20est=C3=A3o=20funcionando!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api.lua | 140 ++++++++++++++++++++++++++++++++++++++++---- locale/pt.po | 100 ++++++++++++++++++++++--------- locale/template.pot | 96 +++++++++++++++++++++--------- 3 files changed, 269 insertions(+), 67 deletions(-) diff --git a/api.lua b/api.lua index 846736a..2529bdf 100644 --- a/api.lua +++ b/api.lua @@ -74,7 +74,7 @@ modMinerTrade.getSafeInventory = function(playername) end -modMinerTrade.getFormspec = function(playername, title) +modMinerTrade.getFormspec = function(playername, ownername, title) if not title then title = "" end local formspec = "size[9.5,10.5]" --.."bgcolor[#636D76FF;false]" @@ -85,8 +85,10 @@ modMinerTrade.getFormspec = function(playername, title) --.."bgcolor[#636D76FF;false]" .."background[-0.25,-0.25;10,11;safe_inside.png]" --listcolors[slot_bg_normal;slot_bg_hover;slot_border;tooltip_bgcolor;tooltip_fontcolor] - .."listcolors[#3a4044CC;#636e7533;#74acd288;#CCCC00;#FFFFFF]" + .."listcolors[#3a4044CC;#636e7533;#74acd288;#CCCC00;#000000]" + .."field[0,0;0,0;txtOwnerName;;"..minetest.formspec_escape(ownername).."]" + --.."hidden[ownername;"..minetest.formspec_escape(ownername)..";string]" .."label[0,0;"..minetest.formspec_escape(title).."]" .."list[detached:safe_"..playername .. ";safe;" @@ -95,10 +97,10 @@ modMinerTrade.getFormspec = function(playername, title) ..";]" -- <= ATENCAO: Nao pode esquecer o prefixo 'detached:xxxxxxx' .."list[current_player;main;0.75,6.25;8,4;]" - .."button[0.75,5.25;3,1;btnRemoveAll;"..minetest.formspec_escape(modMinerTrade.translate("REMOVE ALL")).."]" - .."tooltip[btnRemoveAll;"..minetest.formspec_escape(modMinerTrade.translate("Button under development (still not working)"))..";#CCCC00;#000000]" - .."button[5.75,5.25;3,1;btnDepositAll;"..minetest.formspec_escape(modMinerTrade.translate("DEPOSIT ALL")).."]" - .."tooltip[btnDepositAll;"..minetest.formspec_escape(modMinerTrade.translate("Button under development (still not working)"))..";#CCCC00;#000000]" + .."button[0.75,5.25;4,1;btnLootAll;"..minetest.formspec_escape(modMinerTrade.translate("LOOT ALL")).."]" + --.."tooltip[btnLootAll;"..minetest.formspec_escape(modMinerTrade.translate("Button under development (still not working)"))..";#CCCC00;#000000]" + .."button[4.75,5.25;4,1;btnDepositAll;"..minetest.formspec_escape(modMinerTrade.translate("DEPOSIT ALL")).."]" + --.."tooltip[btnDepositAll;"..minetest.formspec_escape(modMinerTrade.translate("Button under development (still not working)"))..";#CCCC00;#000000]" .."listring[detached:safe_"..playername .. ";safe]" .."listring[current_player;main]" @@ -163,12 +165,12 @@ end modMinerTrade.showInventory = function(player, ownername, title) local playername = player:get_player_name() - local inv = modMinerTrade.getDetachedInventory(ownername) + local inv = modMinerTrade.getDetachedInventory(ownername) minetest.sound_play("sfx_alert", {object=player, max_hear_distance=5.0,}) minetest.show_formspec( playername, "safe_"..ownername, - modMinerTrade.getFormspec(ownername, title) + modMinerTrade.getFormspec(ownername, ownername, title) ) end @@ -178,13 +180,131 @@ modMinerTrade.delSafeInventory = function(ownername) --return minetest.remove_detached_inventory_raw("safe_"..ownername) end +modMinerTrade.doRemoveAll = function(player, ownername) + if player and player:is_player() then + local playername = player:get_player_name() + local invPlayer = player:get_inventory() + minetest.log('action',"[STRONGBOX] "..modMinerTrade.translate("The player '%s' pressed the button'%s'!"):format(playername, modMinerTrade.translate("DEPOSIT ALL"))) + if ownername and ownername:trim()~="" then + ownername = ownername:trim() + local invOwner = modMinerTrade.getDetachedInventory(ownername) + if not invOwner:is_empty("safe") then + local safe = invOwner:get_list("safe") + for i, item in pairs(safe) do + if invPlayer:room_for_item("main",item) then + invOwner:remove_item("safe",item) + invPlayer:add_item("main",item) + if invOwner:is_empty("safe") then + minetest.chat_send_player(playername, + core.colorize("#00ff00", "["..modMinerTrade.translate("STRONGBOX").."]: ") + ..modMinerTrade.translate("Loot completed!") + ) + minetest.sound_play("sfx_alert", {object=player, max_hear_distance=5.0,}) + break + end + else + minetest.chat_send_player( + playername, + core.colorize("#FF0000", "["..modMinerTrade.translate("STRONGBOX").."]: ") + ..modMinerTrade.translate("The Inventory of '%s' is full!"):format(playername) + ) + minetest.sound_play("sfx_failure", {object=player, max_hear_distance=5.0,}) + break + end + --]] + end --for i, item in pairs(safe) do + modMinerTrade.setSafeInventory(ownername, invOwner:get_list("safe")) + else + minetest.chat_send_player( + playername, + core.colorize("#FF0000", "["..modMinerTrade.translate("STRONGBOX").."]: ") + ..modMinerTrade.translate("Everything has been withdrawn!") + ) + minetest.sound_play("sfx_failure", {object=player, max_hear_distance=5.0,}) + end + else + minetest.log( + "error",("[modMinerTrade.doRemoveAll(player='%s', ownername='%s')] "):format(dump(player), dump(ownername)) + ..modMinerTrade.translate("The '%s' parameter must be of the non-empty string type!"):format("ownername") + ) + end + else + minetest.log( + "error",("[modMinerTrade.doRemoveAll(player='%s', ownername='%s')] "):format(dump(player), dump(ownername)) + ..modMinerTrade.translate("The '%s' parameter must be of the player object type!"):format("player") + ) + end +end + +modMinerTrade.doDepositAll = function(player, ownername) + if player and player:is_player() then + local playername = player:get_player_name() + local invPlayer = player:get_inventory() + --minetest.chat_send_player(playername, ">>>"..dump(ownername)) + minetest.log('action',"[STRONGBOX] "..modMinerTrade.translate("The player '%s' pressed the button'%s'!"):format(playername, modMinerTrade.translate("REMOVE ALL"))) + if ownername and ownername:trim()~="" then + ownername = ownername:trim() + local invOwner = modMinerTrade.getDetachedInventory(ownername) + if not invPlayer:is_empty("main") then + local main = invPlayer:get_list("main") + for i, item in pairs(main) do + if invOwner:room_for_item("safe",item) then + invPlayer:remove_item("main",item) + invOwner:add_item("safe",item) + if invPlayer:is_empty("main") then + minetest.chat_send_player(playername, + core.colorize("#00ff00", "["..modMinerTrade.translate("STRONGBOX").."]: ") + ..modMinerTrade.translate("Deposit completed!") + ) + minetest.sound_play("sfx_alert", {object=player, max_hear_distance=5.0,}) + break + end + else + minetest.chat_send_player( + playername, + core.colorize("#FF0000", "["..modMinerTrade.translate("STRONGBOX").."]: ") + ..modMinerTrade.translate("The Safe of '%s' is full!"):format(playername) + ) + minetest.sound_play("sfx_failure", {object=player, max_hear_distance=5.0,}) + break + end + --]] + end --for i, item in pairs(safe) do + modMinerTrade.setSafeInventory(ownername, invOwner:get_list("safe")) + else + minetest.chat_send_player( + playername, + core.colorize("#FF0000", "["..modMinerTrade.translate("STRONGBOX").."]: ") + ..modMinerTrade.translate("The inventory of '%s' is empty!"):format(playername) + ) + minetest.sound_play("sfx_failure", {object=player, max_hear_distance=5.0,}) + end + else + minetest.log( + "error",("[modMinerTrade.doDepositAll(player='%s', ownername='%s')] "):format(dump(player), dump(ownername)) + ..modMinerTrade.translate("The '%s' parameter must be of the non-empty string type!"):format("ownername") + ) + end + else + minetest.log( + "error",("[modMinerTrade.doDepositAll(player='%s', ownername='%s')] "):format(dump(player), dump(ownername)) + ..modMinerTrade.translate("The '%s' parameter must be of the player object type!"):format("player") + ) + end +end + + minetest.register_on_player_receive_fields(function(sender, formname, fields) local sendername = sender:get_player_name() --minetest.chat_send_player(sendername, "formname="..formname.." fields="..dump(fields)) if formname == "safe_"..sendername then -- This is your form name - if fields.quit then + if fields.txtOwnerName and fields.txtOwnerName:trim()~="" and fields.btnLootAll then + modMinerTrade.doRemoveAll(sender, fields.txtOwnerName:trim()) + elseif fields.btnDepositAll then + modMinerTrade.doDepositAll(sender, fields.txtOwnerName:trim()) + elseif fields.quit then modMinerTrade.doSave() - modMinerTrade.delSafeInventory(sendername) + modMinerTrade.delSafeInventory(sendername) minetest.log('action',"[STRONGBOX] "..modMinerTrade.translate("Saving strongbox from all players in the file '%s'!"):format(modMinerTrade.urlTabela)) end end diff --git a/locale/pt.po b/locale/pt.po index 2fcc96a..efc4914 100644 --- a/locale/pt.po +++ b/locale/pt.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-15 20:34-0300\n" -"PO-Revision-Date: 2020-04-15 20:36-0300\n" +"POT-Creation-Date: 2020-04-16 17:54-0300\n" +"PO-Revision-Date: 2020-04-16 17:55-0300\n" "Last-Translator: Lunovox Heavenfinder \n" "Language-Team: \n" "Language: pt\n" @@ -32,45 +32,92 @@ msgstr "O arquivo '%s' não esta no formato de tabela!" msgid "Opening '%s'!" msgstr "Abrindo '%s'!" -#: api.lua:96 -msgid "REMOVE ALL" +#: api.lua:100 +msgid "LOOT ALL" msgstr "SACAR TUDO" -#: api.lua:97 api.lua:99 -msgid "Button under development (still not working)" -msgstr "Botão em desenvolvimento (ainda não está funcionando)" - -#: api.lua:98 +#: api.lua:102 api.lua:187 msgid "DEPOSIT ALL" msgstr "DEPOSITAR TUDO" -#: api.lua:144 +#: api.lua:148 #, lua-format msgid "Player '%s' has placed %02d '%s' in his safe!" msgstr "O jogador '%s' colocou %02d '%s' em seu cofre!" -#: api.lua:148 +#: api.lua:152 #, lua-format msgid "Player '%s' has removed %02d '%s' in his safe!" msgstr "O jogador '%s' retirou %02d '%s' em seu cofre!" -#: api.lua:188 api.lua:210 api.lua:225 api.lua:272 +#: api.lua:187 api.lua:244 #, lua-format -msgid "The '%s' parameter must be of the position type (x,y,z)!" -msgstr "O parâmetro '%s' deve ser do tipo de POSITION (x,y,z)!" +msgid "The player '%s' pressed the button'%s'!" +msgstr "O jogador '%s' pressionou o botão '%s'!" -#: api.lua:204 api.lua:260 api.lua:266 api.lua:291 +#: api.lua:199 api.lua:208 api.lua:220 api.lua:256 api.lua:265 api.lua:277 +#: item_strongbox.lua:53 item_strongbox.lua:60 +msgid "STRONGBOX" +msgstr "COFRE" + +#: api.lua:200 +msgid "Loot completed!" +msgstr "Saque completo!" + +#: api.lua:209 +#, lua-format +msgid "The Inventory of '%s' is full!" +msgstr "O inventário de '%s' está cheio!" + +#: api.lua:221 +msgid "Everything has been withdrawn!" +msgstr "Tudo foi retirado!" + +#: api.lua:228 api.lua:285 api.lua:344 api.lua:400 api.lua:406 api.lua:431 #, lua-format msgid "The '%s' parameter must be of the non-empty string type!" msgstr "O parâmetro '%s' deve ser do tipo de STRING não vazia!" -#: api.lua:240 api.lua:282 item_dispensing_machine.lua:13 +#: api.lua:234 api.lua:291 +#, lua-format +msgid "The '%s' parameter must be of the player object type!" +msgstr "O parâmetro '%s' deve ser do tipo objeto PLAYER!" + +#: api.lua:244 +msgid "REMOVE ALL" +msgstr "SACAR TUDO" + +#: api.lua:257 +msgid "Deposit completed!" +msgstr "Depósito completo!" + +#: api.lua:266 +#, lua-format +msgid "The Safe of '%s' is full!" +msgstr "O Cofre de '%s' está cheio!" + +#: api.lua:278 +#, lua-format +msgid "The inventory of '%s' is empty!" +msgstr "O inventário de '%s' está vazio!" + +#: api.lua:308 on_final.lua:9 +#, lua-format +msgid "Saving strongbox from all players in the file '%s'!" +msgstr "Salvando cofre de todos os jogadores no arquivo '%s'!" + +#: api.lua:328 api.lua:350 api.lua:365 api.lua:412 +#, lua-format +msgid "The '%s' parameter must be of the position type (x,y,z)!" +msgstr "O parâmetro '%s' deve ser do tipo de POSITION (x,y,z)!" + +#: api.lua:380 api.lua:422 item_dispensing_machine.lua:13 #: item_dispensing_machine.lua:204 item_dispensing_machine.lua:224 #: item_dispensing_machine.lua:296 msgid "DISPENSING MACHINE" msgstr "MÁQUINA DE DISPENSADORA" -#: api.lua:246 +#: api.lua:386 #, lua-format msgid "" "A letter was sent by the dispensing machine '%s' to '%s' advising about '%s'!" @@ -78,7 +125,7 @@ msgstr "" "Uma carta foi enviada pela Máquina Dispensadora '%s' para '%s' informando " "sobre '%s'!" -#: api.lua:252 +#: api.lua:392 msgid "" "Due to an unknown error, it was not possible to send an email through the " "dispensing machine!" @@ -412,10 +459,6 @@ msgstr "" msgid "STRONGBOX owned by '%s':" msgstr "COFRE FORTE de '%s':" -#: item_strongbox.lua:53 item_strongbox.lua:60 -msgid "STRONGBOX" -msgstr "COFRE" - #: item_strongbox.lua:54 #, lua-format msgid "The safe is going to work %02d seconds after it is installed!" @@ -426,12 +469,7 @@ msgstr "O cofre só vai funcionar %02d segundos depois de instalado!" msgid "You do not have access to the safe belonging to '%s'!" msgstr "Você não tem acesso ao cofre pertencente a '%s'!" -#: item_strongbox.lua:73 on_final.lua:9 -#, lua-format -msgid "Saving strongbox from all players in the file '%s'!" -msgstr "Salvando cofre de todos os jogadores no arquivo '%s'!" - -#: item_strongbox.lua:88 +#: item_strongbox.lua:77 msgid "strongbox" msgstr "caixaforte" @@ -454,6 +492,12 @@ msgstr "" msgid "The city hall deposited the %2d° salary in your bank account!" msgstr "A prefeitura depositou o %2d° salário em sua conta bancária!" +#~ msgid "The Player Inventory is empty!" +#~ msgstr "O inventário do jogador está vazio!" + +#~ msgid "Button under development (still not working)" +#~ msgstr "Botão em desenvolvimento (ainda não está funcionando)" + #~ msgid "Save Machine Name" #~ msgstr "Salva o nome da máquina" diff --git a/locale/template.pot b/locale/template.pot index cfcda29..438a1e3 100644 --- a/locale/template.pot +++ b/locale/template.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-15 20:34-0300\n" +"POT-Creation-Date: 2020-04-16 17:54-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -31,51 +31,98 @@ msgstr "" msgid "Opening '%s'!" msgstr "" -#: api.lua:96 -msgid "REMOVE ALL" +#: api.lua:100 +msgid "LOOT ALL" msgstr "" -#: api.lua:97 api.lua:99 -msgid "Button under development (still not working)" -msgstr "" - -#: api.lua:98 +#: api.lua:102 api.lua:187 msgid "DEPOSIT ALL" msgstr "" -#: api.lua:144 -#, lua-format -msgid "Player '%s' has placed %02d '%s' in his safe!" -msgstr "" - #: api.lua:148 #, lua-format +msgid "Player '%s' has placed %02d '%s' in his safe!" +msgstr "" + +#: api.lua:152 +#, lua-format msgid "Player '%s' has removed %02d '%s' in his safe!" msgstr "" -#: api.lua:188 api.lua:210 api.lua:225 api.lua:272 +#: api.lua:187 api.lua:244 #, lua-format -msgid "The '%s' parameter must be of the position type (x,y,z)!" +msgid "The player '%s' pressed the button'%s'!" msgstr "" -#: api.lua:204 api.lua:260 api.lua:266 api.lua:291 +#: api.lua:199 api.lua:208 api.lua:220 api.lua:256 api.lua:265 api.lua:277 +#: item_strongbox.lua:53 item_strongbox.lua:60 +msgid "STRONGBOX" +msgstr "" + +#: api.lua:200 +msgid "Loot completed!" +msgstr "" + +#: api.lua:209 +#, lua-format +msgid "The Inventory of '%s' is full!" +msgstr "" + +#: api.lua:221 +msgid "Everything has been withdrawn!" +msgstr "" + +#: api.lua:228 api.lua:285 api.lua:344 api.lua:400 api.lua:406 api.lua:431 #, lua-format msgid "The '%s' parameter must be of the non-empty string type!" msgstr "" -#: api.lua:240 api.lua:282 item_dispensing_machine.lua:13 +#: api.lua:234 api.lua:291 +#, lua-format +msgid "The '%s' parameter must be of the player object type!" +msgstr "" + +#: api.lua:244 +msgid "REMOVE ALL" +msgstr "" + +#: api.lua:257 +msgid "Deposit completed!" +msgstr "" + +#: api.lua:266 +#, lua-format +msgid "The Safe of '%s' is full!" +msgstr "" + +#: api.lua:278 +#, lua-format +msgid "The inventory of '%s' is empty!" +msgstr "" + +#: api.lua:308 on_final.lua:9 +#, lua-format +msgid "Saving strongbox from all players in the file '%s'!" +msgstr "" + +#: api.lua:328 api.lua:350 api.lua:365 api.lua:412 +#, lua-format +msgid "The '%s' parameter must be of the position type (x,y,z)!" +msgstr "" + +#: api.lua:380 api.lua:422 item_dispensing_machine.lua:13 #: item_dispensing_machine.lua:204 item_dispensing_machine.lua:224 #: item_dispensing_machine.lua:296 msgid "DISPENSING MACHINE" msgstr "" -#: api.lua:246 +#: api.lua:386 #, lua-format msgid "" "A letter was sent by the dispensing machine '%s' to '%s' advising about '%s'!" msgstr "" -#: api.lua:252 +#: api.lua:392 msgid "" "Due to an unknown error, it was not possible to send an email through the " "dispensing machine!" @@ -366,10 +413,6 @@ msgstr "" msgid "STRONGBOX owned by '%s':" msgstr "" -#: item_strongbox.lua:53 item_strongbox.lua:60 -msgid "STRONGBOX" -msgstr "" - #: item_strongbox.lua:54 #, lua-format msgid "The safe is going to work %02d seconds after it is installed!" @@ -380,12 +423,7 @@ msgstr "" msgid "You do not have access to the safe belonging to '%s'!" msgstr "" -#: item_strongbox.lua:73 on_final.lua:9 -#, lua-format -msgid "Saving strongbox from all players in the file '%s'!" -msgstr "" - -#: item_strongbox.lua:88 +#: item_strongbox.lua:77 msgid "strongbox" msgstr ""