MAQUINA DISPENSADORA ENVIA EMAIL

A pedido de Animetrom...
This commit is contained in:
Lunovox Heavenfinder 2020-04-13 18:55:23 -03:00
parent 82f1b0d097
commit 119a0a737d
7 changed files with 227 additions and 96 deletions

80
api.lua
View file

@ -157,3 +157,83 @@ modMinerTrade.showInventory = function(player, ownername, title)
modMinerTrade.getFormspec(ownername, title)
)
end
--##############################################################################
modMinerTrade.floor_pos = function(pos)
return {
x=math.floor(pos.x),
y=math.floor(pos.y),
z=math.floor(pos.z)
}
end
modMinerTrade.sendMailMachine = function(posMachine, ownername, message)
if minetest.get_modpath("correio") then
local mailMachineInterval = (60*60)
if type(posMachine)=="table" and type(posMachine.x)=="number" and type(posMachine.y)=="number" and type(posMachine.z)=="number" then
local posMachineName = minetest.pos_to_string(modMinerTrade.floor_pos(posMachine))
if type(ownername)=="string" and ownername:trim()~="" and minetest.player_exists(ownername) then --Checks whether the owner really exists.
if type(message)=="string" and message:trim()~="" then
local agora = os.time()
if type(modMinerTrade.machine_flags)~="table" then modMinerTrade.machine_flags={} end
if type(modMinerTrade.machine_flags[posMachineName])~="table" then modMinerTrade.machine_flags[posMachineName]={} end
if type(modMinerTrade.machine_flags[posMachineName].lastalert)~="number" or modMinerTrade.machine_flags[posMachineName].lastalert + mailMachineInterval < agora then
local carta = modCorreio.set_mail(
modMinerTrade.translate("DISPENSING MACHINE").." "..posMachineName,
ownername,
message:trim()
)
if carta~=nil then
minetest.log('action',
modMinerTrade.translate("A letter was sent by the dispensing machine '%s' to '%s' advising about '%s'!"):
format(posMachineName, ownername , message)
)
else
minetest.log(
"error",("[modMinerTrade.sendMailMachine(posMachine='%s', ownername='%s', message='%s')] "):format(dump(posMachine), dump(ownername), dump(message))
..modMinerTrade.translate("Due to an unknown error, it was not possible to send an email through the dispensing machine!")
)
end
modMinerTrade.machine_flags[posMachineName].lastalert = agora
end --if type(modMinerTrade.machine_flags[posMachineName].lastalert)~="number" or modMinerTrade.machine_flags[posMachineName].lastalert + mailMachineInterval < agora then
else
minetest.log(
"error",("[modMinerTrade.sendMailMachine(posMachine='%s', ownername='%s', message='%s')] "):format(dump(posMachine), dump(ownername), dump(message))
..modMinerTrade.translate("The '%s' parameter must be of the non-empty string type!"):format("message")
)
end
else
minetest.log(
"error",("[modMinerTrade.sendMailMachine(posMachine='%s', ownername='%s', message='%s')] "):format(dump(posMachine), dump(ownername), dump(message))
..modMinerTrade.translate("The '%s' parameter must be of the non-empty string type!"):format("ownername")
)
end
else
minetest.log(
"error",("[modMinerTrade.sendMailMachine(posMachine='%s', ownername='%s', message='%s')] "):format(dump(posMachine), dump(ownername), dump(message))
..modMinerTrade.translate("The 'posMachine' parameter must be of the position type (x,y,z)!")
)
end
end --if minetest.get_modpath("correio") then
end
minetest.errorDispensing = function(erroMessage, player, pos, ownername)
if type(erroMessage)=="string" and erroMessage:trim()~="" then
if player:is_player() then
local playername = player:get_player_name()
minetest.chat_send_player(playername, core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")..erroMessage)
minetest.sound_play("sfx_failure", {object=player, max_hear_distance=5.0,})
end
if type(pos)~="nil" and type(ownername)=="string" and ownername:trim()~="" then
modMinerTrade.sendMailMachine(pos, ownername, erroMessage)
end
else
minetest.log(
"error",("[minetest.errorDispensing(erroMessage='%s', player, pos, ownername)] "):format(dump(erroMessage))
..modMinerTrade.translate("The '%s' parameter must be of the non-empty string type!"):format("erroMessage")
)
end
end

View file

@ -3,3 +3,4 @@ dye
intllib?
tradelands?
areas?
correio?

View file

@ -211,31 +211,31 @@ minetest.register_node("minertrade:dispensingmachine", {
minetest.register_on_player_receive_fields(function(sender, formname, fields)
if formname == "modMinerTrade.balcaodeloja_formspec" then
local name = sender:get_player_name()
local pos = modMinerTrade.dispensing.loja_atual[name]
local sendername = sender:get_player_name()
local pos = modMinerTrade.dispensing.loja_atual[sendername]
local meta = minetest.env:get_meta(pos)
local owner = meta:get_string("owner")
--minetest.chat_send_player(name,"owner('"..owner.."') == name('"..name.."')")
local ownername = meta:get_string("owner")
--minetest.chat_send_player(sendername,"ownername('"..ownername.."') == sendername('"..sendername.."')")
if modMinerTrade.dispensing.canOpen(pos, name) and sender:get_player_control().aux1 then
minetest.chat_send_player(name,
if modMinerTrade.dispensing.canOpen(pos, sendername) and sender:get_player_control().aux1 then
minetest.chat_send_player(sendername,
core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")
..modMinerTrade.translate("You can not change your own machine!")
)
minetest.sound_play("sfx_alert", {object=sender, max_hear_distance=5.0,})
return
else
--minetest.chat_send_player(name,"fields="..dump(fields))
--minetest.chat_send_player(sendername,"fields="..dump(fields))
if fields.txtOffer ~= nil then
if fields.txtOffer ~= "" then
meta:set_string("offer", fields.txtOffer)
meta:set_string("infotext",
modMinerTrade.translate("Dispensing Machine of '%s'."):format(owner).."\n\n"
modMinerTrade.translate("Dispensing Machine of '%s'."):format(ownername).."\n\n"
.." * "..fields.txtOffer
)
else
meta:set_string("offer", "")
meta:set_string("infotext", modMinerTrade.translate("Dispensing Machine of '%s'."):format(owner))
meta:set_string("infotext", modMinerTrade.translate("Dispensing Machine of '%s'."):format(ownername))
end
minetest.sound_play("sfx_alert", {object=sender, max_hear_distance=5.0,})
return
@ -290,34 +290,38 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
minv:remove_item("stock",item) -- Remove do Estoque
pinv:add_item("customer_gets",item) -- Entrega ao jogador.
end
minetest.chat_send_player(name,
minetest.chat_send_player(sendername,
core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")
..modMinerTrade.translate("Dispending done!")
)
minetest.sound_play("sfx_cash_register", {object=sender, max_hear_distance=5.0,})
else
if error_name == "owners_fault" then
minetest.chat_send_player(name,
core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")
..modMinerTrade.translate("The stock of '%s' is gone. Contact him!"):format(owner)
minetest.errorDispensing(
modMinerTrade.translate(
--"The stock of '%s' is gone."
"Cannot deliver more items to '%s' because stock of '%s' is gone!"
):format(sendername, ownername)
,sender ,pos ,ownername
)
elseif error_name == "without_space_to_profit" then
minetest.chat_send_player(name,
core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")
..modMinerTrade.translate("Without enough space in Dispensing Machine to receive the customer item. (Please, contact the seller '%s'!)"):format(owner)
minetest.errorDispensing(
modMinerTrade.translate(
"Without enough space in Dispensing Machine to receive the customer item '%s'."
):format(sendername)
,sender ,pos ,ownername
)
elseif error_name == "without_space_to_offer" then
minetest.chat_send_player(name,
core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")
..modMinerTrade.translate("Without enough space in Dispensing Machine to receive the seller's item. (Please, empty the receiving box!)")
minetest.errorDispensing(
modMinerTrade.translate("Without enough space in Dispensing Machine to receive the seller's item. (Please, empty the receiving box!)")
,sender
)
else
minetest.chat_send_player(name,
core.colorize("#00ff00", "["..modMinerTrade.translate("DISPENSING MACHINE").."]: ")
..modMinerTrade.translate("The dispending can not be done. Make sure you offer what the machine asks for!")
minetest.errorDispensing(
modMinerTrade.translate("The dispending can not be done. Make sure you offer what the machine asks for!")
,sender
)
end
minetest.sound_play("sfx_failure", {object=sender, max_hear_distance=5.0,})
end
end --if fields.quit==nil then
end

View file

@ -88,7 +88,7 @@ minetest.register_craft({
minetest.register_alias(
modMinerTrade.translate("piggybank"),
modMinerTrade.translate("checkbank"),
"minertrade:checkbank"
)

View file

@ -7,16 +7,16 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-08 19:09-0300\n"
"PO-Revision-Date: 2020-04-08 20:03-0300\n"
"POT-Creation-Date: 2020-04-13 18:43-0300\n"
"PO-Revision-Date: 2020-04-13 18:44-0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: pt\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.6\n"
"Last-Translator: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: pt\n"
#: api.lua:4
msgid "Permission to open locked chests of other players"
@ -42,6 +42,37 @@ msgstr "O jogador '%s' colocou %02d '%s' em seu cofre!"
msgid "Player '%s' has removed %02d '%s' in his safe!"
msgstr "O jogador '%s' retirou %02d '%s' em seu cofre!"
#: api.lua:182 api.lua:224 item_dispensing_machine.lua:16
#: item_dispensing_machine.lua:204 item_dispensing_machine.lua:222
#: item_dispensing_machine.lua:294
msgid "DISPENSING MACHINE"
msgstr "MÁQUINA DE DISPENSADORA"
#: api.lua:188
#, lua-format
msgid ""
"A letter was sent by the dispensing machine '%s' to '%s' advising about '%s'!"
msgstr ""
"Uma carta foi enviada pela Máquina Dispensadora '%s' para '%s' informando "
"sobre '%s'!"
#: api.lua:194
msgid ""
"Due to an unknown error, it was not possible to send an email through the "
"dispensing machine!"
msgstr ""
"Devido a um erro desconhecido, não foi possível enviar um email através da "
"Máquina Dispensadora!"
#: api.lua:202 api.lua:208 api.lua:233
#, 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:214
msgid "The 'posMachine' parameter must be of the position type (x,y,z)!"
msgstr "O parâmetro 'posMachine' deve ser do tipo de POSITION (x,y,z)!"
#: commands.lua:2 commands.lua:9 commands.lua:27
msgid "Lets you check the contents of another players strongbox."
msgstr "Permite verificar o conteúdo do cofre de outro jogador."
@ -74,7 +105,7 @@ msgstr ""
"Cofre Pessoal ou qualquer outro Caixa Eletrônico nas lojas espalhadas pelo "
"mapa."
#: item_atm.lua:73 item_atm.lua:100
#: item_atm.lua:73 item_atm.lua:97
msgid "ATM"
msgstr "CAIXA ELETRÔNICO"
@ -84,27 +115,20 @@ msgstr ""
"Você não pode instalar este 'Caixa Eletrônico' muito longe de uma 'Máquina "
"Dispensadora'!"
#: item_atm.lua:95
#: item_atm.lua:92
#, lua-format
msgid "PUBLIC ATM - Account of '%s':"
msgstr "CAIXA ELETRÔNICO - Conta de '%s':"
#: item_atm.lua:101
#: item_atm.lua:98
#, lua-format
msgid "The ATM will only run %02d seconds after it is installed!"
msgstr "O Caixa Eletrônico só vai funcionar %02d segundos depois de instalado!"
#: item_atm.lua:117
#: item_atm.lua:114
msgid "atm"
msgstr "caixaeletronico"
#: item_dispensing_machine.lua:16 item_dispensing_machine.lua:204
#: item_dispensing_machine.lua:222 item_dispensing_machine.lua:294
#: item_dispensing_machine.lua:301 item_dispensing_machine.lua:306
#: item_dispensing_machine.lua:311 item_dispensing_machine.lua:316
msgid "DISPENSING MACHINE"
msgstr "MÁQUINA DE DISPENSADORA"
#: item_dispensing_machine.lua:19
msgid "Customer Offer"
msgstr "Cliente Oferece"
@ -183,21 +207,21 @@ msgstr "Você não pode trocar na sua própria maquina!"
msgid "Dispending done!"
msgstr "Dispensa Concluida!"
#: item_dispensing_machine.lua:302
#: item_dispensing_machine.lua:303
#, lua-format
msgid "The stock of '%s' is gone. Contact him!"
msgstr "O estoque de '%s' acabou. Contacte-o!"
msgid "Cannot deliver more items to '%s' because stock of '%s' is gone!"
msgstr ""
"Não é possível entregar mais itens para '%s' porque o estoque de '%s' acabou!"
#: item_dispensing_machine.lua:307
#: item_dispensing_machine.lua:310
#, lua-format
msgid ""
"Without enough space in Dispensing Machine to receive the customer item. "
"(Please, contact the seller '%s'!)"
"Without enough space in Dispensing Machine to receive the customer item '%s'."
msgstr ""
"Sem espaço suficiente na Maquina Dispensadora para receber o item do "
"cliente. (Por favor, entre em contato com o vendedor '%s'!)"
"Sem espaço suficiente na Maquina Dispensadora para receber o item do cliente "
"'%s'."
#: item_dispensing_machine.lua:312
#: item_dispensing_machine.lua:316
msgid ""
"Without enough space in Dispensing Machine to receive the seller's item. "
"(Please, empty the receiving box!)"
@ -205,15 +229,15 @@ msgstr ""
"Sem espaço suficiente na Maquina Dispensadora para receber o item do "
"vendedor. (Por favor, esvazie a caixa de recebimento!)"
#: item_dispensing_machine.lua:317
#: item_dispensing_machine.lua:321
msgid ""
"The dispending can not be done. Make sure you offer what the machine asks "
"for!"
msgstr ""
"A dispensa não pode ser feita. Verifique se você ofereceu o que a quina "
"pede!"
"A dispensa não pode ser feita. Verifique se você ofereceu o que a Maquina "
"Dispensadora pede!"
#: item_dispensing_machine.lua:339
#: item_dispensing_machine.lua:343
msgid "dispensingmachine"
msgstr "dispensadora"
@ -314,16 +338,16 @@ msgstr ""
"* Permite acessar a conta bancária do proprietário do cartão de crédito em "
"qualquer lugar do mundo."
#: item_miner_cash.lua:112
#: item_miner_cash.lua:113
#, lua-format
msgid "CREDIT CARD of '%s'"
msgstr "CARTÃO DE CRÉDITO de '%s'"
#: item_miner_cash.lua:125
#: item_miner_cash.lua:126
msgid "CREDIT CARD"
msgstr "CARTÃO DE CRÉDITO"
#: item_miner_cash.lua:126
#: item_miner_cash.lua:127
#, lua-format
msgid ""
"Your name has been saved to this credit card. Anyone using this credit card "
@ -332,12 +356,12 @@ msgstr ""
"Seu nome foi salvo neste cartão de crédito. Qualquer pessoa que use este "
"cartão de crédito poderá acessar a conta bancária '%s'."
#: item_miner_cash.lua:138
#: item_miner_cash.lua:135
#, lua-format
msgid "ACCOUNT BANK of '%s':"
msgstr "CONTA BANCÁRA de '%s':"
#: item_miner_cash.lua:163
#: item_miner_cash.lua:159
msgid "creditcard"
msgstr "cartaodecredito"
@ -362,31 +386,31 @@ msgstr ""
"* Guarde seu dinheiro neste cofre e retire seu dinheiro em qualquer loja que "
"possua um Caixa Eletrônico."
#: item_strongbox.lua:51
#: item_strongbox.lua:48
#, lua-format
msgid "STRONGBOX owned by '%s':"
msgstr "COFRE FORTE de '%s':"
#: item_strongbox.lua:56 item_strongbox.lua:62
#: item_strongbox.lua:53 item_strongbox.lua:60
msgid "STRONGBOX"
msgstr "COFRE"
#: item_strongbox.lua:57
#: item_strongbox.lua:54
#, lua-format
msgid "The safe is going to work %02d seconds after it is installed!"
msgstr "O cofre só vai funcionar %02d segundos depois de instalado!"
#: item_strongbox.lua:63
#: item_strongbox.lua:61
#, lua-format
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:75 on_final.lua:9
#: 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:90
#: item_strongbox.lua:88
msgid "strongbox"
msgstr "caixaforte"
@ -408,3 +432,6 @@ msgstr ""
#, lua-format
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 stock of '%s' is gone. Contact him!"
#~ msgstr "O estoque de '%s' acabou. Contacte-o!"

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-08 19:09-0300\n"
"POT-Creation-Date: 2020-04-13 18:43-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"
@ -41,6 +41,33 @@ msgstr ""
msgid "Player '%s' has removed %02d '%s' in his safe!"
msgstr ""
#: api.lua:182 api.lua:224 item_dispensing_machine.lua:16
#: item_dispensing_machine.lua:204 item_dispensing_machine.lua:222
#: item_dispensing_machine.lua:294
msgid "DISPENSING MACHINE"
msgstr ""
#: api.lua:188
#, lua-format
msgid ""
"A letter was sent by the dispensing machine '%s' to '%s' advising about '%s'!"
msgstr ""
#: api.lua:194
msgid ""
"Due to an unknown error, it was not possible to send an email through the "
"dispensing machine!"
msgstr ""
#: api.lua:202 api.lua:208 api.lua:233
#, lua-format
msgid "The '%s' parameter must be of the non-empty string type!"
msgstr ""
#: api.lua:214
msgid "The 'posMachine' parameter must be of the position type (x,y,z)!"
msgstr ""
#: commands.lua:2 commands.lua:9 commands.lua:27
msgid "Lets you check the contents of another players strongbox."
msgstr ""
@ -67,7 +94,7 @@ msgid ""
"or other ATM in the shops scattered around the map."
msgstr ""
#: item_atm.lua:73 item_atm.lua:100
#: item_atm.lua:73 item_atm.lua:97
msgid "ATM"
msgstr ""
@ -75,27 +102,20 @@ msgstr ""
msgid "You can not install this 'ATM' too far from a 'Dispensing Machine'!"
msgstr ""
#: item_atm.lua:95
#: item_atm.lua:92
#, lua-format
msgid "PUBLIC ATM - Account of '%s':"
msgstr ""
#: item_atm.lua:101
#: item_atm.lua:98
#, lua-format
msgid "The ATM will only run %02d seconds after it is installed!"
msgstr ""
#: item_atm.lua:117
#: item_atm.lua:114
msgid "atm"
msgstr ""
#: item_dispensing_machine.lua:16 item_dispensing_machine.lua:204
#: item_dispensing_machine.lua:222 item_dispensing_machine.lua:294
#: item_dispensing_machine.lua:301 item_dispensing_machine.lua:306
#: item_dispensing_machine.lua:311 item_dispensing_machine.lua:316
msgid "DISPENSING MACHINE"
msgstr ""
#: item_dispensing_machine.lua:19
msgid "Customer Offer"
msgstr ""
@ -172,31 +192,30 @@ msgstr ""
msgid "Dispending done!"
msgstr ""
#: item_dispensing_machine.lua:302
#: item_dispensing_machine.lua:303
#, lua-format
msgid "The stock of '%s' is gone. Contact him!"
msgid "Cannot deliver more items to '%s' because stock of '%s' is gone!"
msgstr ""
#: item_dispensing_machine.lua:307
#: item_dispensing_machine.lua:310
#, lua-format
msgid ""
"Without enough space in Dispensing Machine to receive the customer item. "
"(Please, contact the seller '%s'!)"
"Without enough space in Dispensing Machine to receive the customer item '%s'."
msgstr ""
#: item_dispensing_machine.lua:312
#: item_dispensing_machine.lua:316
msgid ""
"Without enough space in Dispensing Machine to receive the seller's item. "
"(Please, empty the receiving box!)"
msgstr ""
#: item_dispensing_machine.lua:317
#: item_dispensing_machine.lua:321
msgid ""
"The dispending can not be done. Make sure you offer what the machine asks "
"for!"
msgstr ""
#: item_dispensing_machine.lua:339
#: item_dispensing_machine.lua:343
msgid "dispensingmachine"
msgstr ""
@ -271,7 +290,7 @@ msgid ""
msgstr ""
#: item_miner_cash.lua:91
msgid "piggybank"
msgid "checkbank"
msgstr ""
#: item_miner_cash.lua:98
@ -282,28 +301,28 @@ msgid ""
"the world."
msgstr ""
#: item_miner_cash.lua:112
#: item_miner_cash.lua:113
#, lua-format
msgid "CREDIT CARD of '%s'"
msgstr ""
#: item_miner_cash.lua:125
#: item_miner_cash.lua:126
msgid "CREDIT CARD"
msgstr ""
#: item_miner_cash.lua:126
#: item_miner_cash.lua:127
#, lua-format
msgid ""
"Your name has been saved to this credit card. Anyone using this credit card "
"will be able to access the '%s' bank account."
msgstr ""
#: item_miner_cash.lua:138
#: item_miner_cash.lua:135
#, lua-format
msgid "ACCOUNT BANK of '%s':"
msgstr ""
#: item_miner_cash.lua:163
#: item_miner_cash.lua:159
msgid "creditcard"
msgstr ""
@ -322,31 +341,31 @@ msgid ""
"an ATM."
msgstr ""
#: item_strongbox.lua:51
#: item_strongbox.lua:48
#, lua-format
msgid "STRONGBOX owned by '%s':"
msgstr ""
#: item_strongbox.lua:56 item_strongbox.lua:62
#: item_strongbox.lua:53 item_strongbox.lua:60
msgid "STRONGBOX"
msgstr ""
#: item_strongbox.lua:57
#: item_strongbox.lua:54
#, lua-format
msgid "The safe is going to work %02d seconds after it is installed!"
msgstr ""
#: item_strongbox.lua:63
#: item_strongbox.lua:61
#, lua-format
msgid "You do not have access to the safe belonging to '%s'!"
msgstr ""
#: item_strongbox.lua:75 on_final.lua:9
#: item_strongbox.lua:73 on_final.lua:9
#, lua-format
msgid "Saving strongbox from all players in the file '%s'!"
msgstr ""
#: item_strongbox.lua:90
#: item_strongbox.lua:88
msgid "strongbox"
msgstr ""

View file

@ -6,5 +6,5 @@ release = 5.0.0
author = Lunovox Heavenfinder
title = Minertrade
depends = default,dye
optional_depends = intllib,tradelands,areas
optional_depends = intllib,tradelands,areas,correio