2022-05-12 23:32:22 -03:00
modMinerTrade.getUrlDatabase = function ( )
--Extensao '.tbl' ou '.db'
local extension = " "
if modMinerTrade.save_compressed then
extension = " .db64 "
else
extension = " .tbl "
end
return minetest.get_worldpath ( ) .. " /minertrade " .. extension
end
2022-05-12 11:32:28 -03:00
modMinerTrade.doBankSave = function ( )
2022-05-12 23:32:22 -03:00
--modMinerTrade.debug("modMinerTrade.doBankSave() >>> "..modMinerTrade.getUrlDatabase())
local file = io.open ( modMinerTrade.getUrlDatabase ( ) , " w " )
2022-05-12 11:32:28 -03:00
if file then
2022-05-12 23:32:22 -03:00
local content = minetest.serialize ( modMinerTrade.bank )
--modMinerTrade.debug("modMinerTrade.doBankSave() >>> content = "..dump(content))
if modMinerTrade.save_compressed then
content = minetest.encode_base64 ( content )
end
file : write ( content )
2022-05-12 11:32:28 -03:00
file : close ( )
2022-05-16 05:13:48 -03:00
minetest.log ( ' action ' , " [MINERTRADE] " .. modMinerTrade.translate ( " Saving data bank in the file '%s'! " ) : format ( modMinerTrade.getUrlDatabase ( ) ) )
2022-05-12 11:32:28 -03:00
else
2022-05-12 23:32:22 -03:00
minetest.log ( ' error ' , " [MINERTRADE:ERRO] " .. modMinerTrade.translate ( " The file '%s' is not in table format! " ) : format ( modMinerTrade.getUrlDatabase ( ) ) )
2022-05-12 11:32:28 -03:00
end
end
modMinerTrade.doBankLoad = function ( )
2022-05-13 23:24:20 -03:00
--modMinerTrade.debug("modMinerTrade.doBankSave() >>> "..modMinerTrade.getUrlDatabase())
2022-05-12 23:32:22 -03:00
local file = io.open ( modMinerTrade.getUrlDatabase ( ) , " r " )
2022-05-12 11:32:28 -03:00
if file then
2022-05-12 23:32:22 -03:00
if modMinerTrade.save_compressed then
modMinerTrade.bank = minetest.deserialize ( minetest.decode_base64 ( file : read ( " *all " ) ) )
else
modMinerTrade.bank = minetest.deserialize ( file : read ( " *all " ) )
end
2022-05-13 23:24:20 -03:00
--modMinerTrade.debug("modMinerTrade.doBankLoad() >>> modMinerTrade.bank = "..dump(modMinerTrade.bank))
2022-05-12 11:32:28 -03:00
file : close ( )
if not modMinerTrade.bank or type ( modMinerTrade.bank ) ~= " table " then
2022-05-12 23:32:22 -03:00
minetest.log ( ' error ' , " [MINERTRADE:ERRO] " .. modMinerTrade.translate ( " The file '%s' is not in table format! " ) : format ( modMinerTrade.getUrlDatabase ( ) ) )
2022-05-12 11:32:28 -03:00
return { }
else
2022-05-16 05:13:48 -03:00
minetest.log ( ' action ' , " [MINERTRADE] " .. modMinerTrade.translate ( " Opening '%s' with data bank! " ) : format ( modMinerTrade.getUrlDatabase ( ) ) )
2022-05-12 11:32:28 -03:00
end
end
end
modMinerTrade.isExistAcount = function ( playername )
if modMinerTrade.bank . player [ playername ] ~= nil then
return true
else
return false
end
end
modMinerTrade.createAcount = function ( playername )
if modMinerTrade.bank . player [ playername ] == nil then
modMinerTrade.bank . player [ playername ] = {
2022-05-13 23:24:20 -03:00
account_created = os.date ( " %Y-%B-%d %Hh:%Mm:%Ss " ) ,
2022-05-12 11:32:28 -03:00
balance = 0 ,
2022-05-14 21:41:54 -03:00
total_transactions = 0 ,
2022-05-12 23:32:22 -03:00
statement = { }
2022-05-12 11:32:28 -03:00
}
2022-05-13 23:24:20 -03:00
--modMinerTrade.bank.player[playername].account_created
2022-05-13 12:40:50 -03:00
modMinerTrade.bank . accounts = modMinerTrade.bank . accounts + 1
2022-05-12 11:32:28 -03:00
return true
else
return false
end
2017-03-13 18:47:26 -03:00
2022-05-12 11:32:28 -03:00
return modMinerTrade.bank . player [ playername ] . balance
end
2017-03-13 18:26:38 -03:00
2022-05-12 11:32:28 -03:00
modMinerTrade.getBalance = function ( playername )
if modMinerTrade.isExistAcount ( playername ) then
return modMinerTrade.bank . player [ playername ] . balance
end
end
2017-03-13 18:26:38 -03:00
2022-05-12 23:32:22 -03:00
modMinerTrade.addBalance = function ( playername , value )
if value ~= nil and type ( value ) == " number " and value ~= 0 then
if modMinerTrade.isExistAcount ( playername ) then
modMinerTrade.bank . player [ playername ] . balance = modMinerTrade.bank . player [ playername ] . balance + value
return true
end
end
return false
end
2022-05-14 21:41:54 -03:00
modMinerTrade.getMaxStatements = function ( ) --MÁXIMO DE EXTRATOS ARMAZENADOS.
local maxStatements = minetest.settings : get ( " minertrade.bank.max_statements " )
if maxStatements == nil
or type ( tonumber ( maxStatements ) ) ~= " number "
or tonumber ( maxStatements ) < 1
or tonumber ( maxStatements ) > 300
then
maxStatements = 30
minetest.settings : set ( " minertrade.bank.max_statements " , tostring ( maxStatements ) )
end
return tonumber ( maxStatements )
end
modMinerTrade.getTotalTransactions = function ( playername ) --TOTAL DE MOVIMENTAÇOES FINANCEIRAS DESDE ACRIACAO DA CONTA.
if modMinerTrade.isExistAcount ( playername ) then
return modMinerTrade.bank . player [ playername ] . total_transactions or 0
end
return 0
end
2022-05-12 23:32:22 -03:00
modMinerTrade.addStatement = function ( playername , value , description )
if value ~= nil and type ( value ) == " number " and value ~= 0 then
if modMinerTrade.isExistAcount ( playername ) then
2022-05-14 21:41:54 -03:00
local myStatement = modMinerTrade.getStatement ( playername )
local totalTransactions = modMinerTrade.getTotalTransactions ( playername )
if myStatement ~= nil
and type ( myStatement )
and # myStatement >= 1
then
local maxStatements = modMinerTrade.getMaxStatements ( )
if # myStatement >= maxStatements then
local toDelete = ( # myStatement - maxStatements ) + 1
for i = toDelete , 1 , - 1 do
table.remove ( myStatement , i )
end
end
end
2022-05-12 23:32:22 -03:00
table.insert (
2022-05-14 21:41:54 -03:00
myStatement ,
2022-05-12 23:32:22 -03:00
{
2022-05-13 12:40:50 -03:00
when = os.date ( " %Y-%B-%d %Hh:%Mm:%Ss " ) ,
2022-05-12 23:32:22 -03:00
value = value ,
description = description ,
}
)
2022-05-14 21:41:54 -03:00
modMinerTrade.bank . player [ playername ] . total_transactions = totalTransactions + 1
modMinerTrade.bank . player [ playername ] . statement = myStatement
2022-05-12 23:32:22 -03:00
return true
end
end
return false
end
2022-05-13 12:40:50 -03:00
modMinerTrade.getStatement = function ( playername )
if playername ~= nil and type ( playername ) == " string " and playername ~= " " then
if modMinerTrade.isExistAcount ( playername ) then
return modMinerTrade.bank . player [ playername ] . statement
end
end
end
2022-05-15 01:27:41 -03:00
modMinerTrade.checkValidStack = function ( stack )
local cashtypes = modMinerTrade.getCashTypes ( )
for i , item in pairs ( cashtypes ) do
if item == stack : get_name ( ) then
return stack : get_count ( )
end
end
return 0
end
modMinerTrade.getValueStack = function ( stack )
local cashtypes = modMinerTrade.getCashTypes ( )
for i , item in pairs ( cashtypes ) do
if item == stack : get_name ( ) then
local amount = stack : get_count ( )
return ( 9 ^ ( i - 1 ) ) * amount
end
end
return 0
end
2022-05-12 11:32:28 -03:00
modMinerTrade.showAtm = {
frmMain = function ( playername ) --FORMULÁRIO: PRINCIPAL / RAIZ
2022-05-13 23:24:20 -03:00
local formspec = " size[16,10] "
2022-05-12 17:03:46 -03:00
.. " bgcolor[#636D7688;false] "
2022-05-12 11:32:28 -03:00
--.."bgcolor[#636D76FF;false]"
--..default.gui_bg
--..default.gui_bg_img
--..default.gui_slots
2022-05-12 17:03:46 -03:00
--.."background[5.0,-0.25;10,10;default_steel_block.png^text_atm_front.png]"
2022-05-13 23:24:20 -03:00
.. " box[0.00,0.10;5.50,9.5;#000000] "
.. " button[0.25,0.50;5.00,0.5;btnBalance; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " BALANCE " ) ) ) .. " ] "
.. " button[0.25,1.25;5.00,0.5;btnStatement; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " STATEMENT " ) ) ) .. " ] "
2022-05-15 01:27:41 -03:00
.. " button[0.25,2.00;5.00,0.5;btnDeposits; " .. minetest.formspec_escape ( core.colorize ( " #FFFFF " , modMinerTrade.translate ( " DEPOSITS " ) ) ) .. " ] "
2022-05-13 23:24:20 -03:00
.. " button[0.25,2.75;5.00,0.5;btnWithdrawals; " .. minetest.formspec_escape ( core.colorize ( " #FFFFF " , modMinerTrade.translate ( " WITHDRAWALS " ) ) ) .. " ] " -- [DINHEIRO E CHECK]
.. " button[0.25,3.50;5.00,0.5;btnTransfers; " .. minetest.formspec_escape ( core.colorize ( " #888888 " , modMinerTrade.translate ( " TRANSFERS " ) ) ) .. " ] "
.. " button[0.25,4.25;5.00,0.5;btnLoans; " .. minetest.formspec_escape ( core.colorize ( " #888888 " , modMinerTrade.translate ( " LOANS " ) ) ) .. " ] " --Emprestimos
.. " button[0.25,5.00;5.00,0.5;btnCreditCard; " .. minetest.formspec_escape ( core.colorize ( " #888888 " , modMinerTrade.translate ( " CREDIT CARD " ) ) ) .. " ] " -- [EXPEDIR E MUDAR SENHA]
.. " button[0.25,5.75;5.00,0.5;btnSetings; " .. minetest.formspec_escape ( core.colorize ( " #888888 " , modMinerTrade.translate ( " SETTINGS " ) ) ) .. " ] " --Se quer ou não uma senha, se quer receber uma carta quando houver uma nova movimentacao.
.. " button_exit[0.25,6.50;5.00,0.5;; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " EXIT " ) ) ) .. " ] "
2022-05-12 17:03:46 -03:00
2022-05-13 23:24:20 -03:00
--.. "box[6.0,0.25;9.5,9.5;#000000]"
.. " background[6.0,0.25;9.5,9.5;text_atm_front.png] "
2022-05-12 17:03:46 -03:00
2022-05-13 23:24:20 -03:00
2022-05-12 11:32:28 -03:00
minetest.show_formspec ( playername , " frmAtmMain " , formspec )
end ,
frmBalance = function ( playername ) --FORMULÁRIO: SALDO
local msgBalance = " "
if modMinerTrade.isExistAcount ( playername ) then
2022-05-13 12:40:50 -03:00
msgBalance = modMinerTrade.translate ( " You have %02d minercash. " ) : format ( modMinerTrade.getBalance ( playername ) )
2022-05-12 11:32:28 -03:00
else
msgBalance = modMinerTrade.translate ( " Player '%s' is not an account holder of this bank. " ) : format ( playername )
2017-03-13 18:26:38 -03:00
end
2022-05-13 23:24:20 -03:00
2022-05-14 21:41:54 -03:00
--local tblStatements = modMinerTrade.getStatement(playername)
local totalTransactions = modMinerTrade.getTotalTransactions ( playername )
2022-05-13 23:24:20 -03:00
local formspec = " size[16,10] "
2022-05-12 17:03:46 -03:00
.. " bgcolor[#636D7688;false] "
2022-05-12 11:32:28 -03:00
--.."bgcolor[#636D76FF;false]"
--..default.gui_bg
--..default.gui_bg_img
--..default.gui_slots
2017-03-13 18:26:38 -03:00
2022-05-13 23:24:20 -03:00
.. " box[0.00,0.10;5.50,9.5;#000000] "
.. " button[0.25,0.50;5.00,0.5;btnAtmMain; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " BACK " ) ) ) .. " ] "
.. " button_exit[0.25,6.50;5.00,0.5;; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " EXIT " ) ) ) .. " ] "
2022-05-12 17:03:46 -03:00
2022-05-13 23:24:20 -03:00
.. " box[6.0,0.25;9.5,9.5;#00000088] "
.. " background[6.0,0.25;9.5,9.5;text_atm_front.png] "
2022-05-12 17:03:46 -03:00
2022-05-14 21:41:54 -03:00
.. " textarea[6.75,1.00;9.0,9.0;; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , modMinerTrade.translate ( " NAME OF BANKING ACCOUNT HOLDER " ) .. " : " ) ) .. " ; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , playername : upper ( ) ) ) .. " ] "
2022-05-12 23:32:22 -03:00
2022-05-14 21:41:54 -03:00
.. " textarea[6.75,2.50;9.0,9.0;; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , modMinerTrade.translate ( " ACCOUNT CREATED " ) .. " : " ) ) .. " ; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , modMinerTrade.bank . player [ playername ] . account_created ) ) .. " ] "
2022-05-12 17:03:46 -03:00
2022-05-14 21:41:54 -03:00
.. " textarea[6.75,4.00;9.0,9.0;; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , modMinerTrade.translate ( " FINANCIAL TRANSACTIONS " ) .. " : " ) ) .. " ; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , ( " %02d " ) : format ( totalTransactions ) .. " transactions. " ) ) .. " ] "
.. " textarea[6.75,5.50;9.0,9.0;; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , modMinerTrade.translate ( " BALANCES " ) .. " : " ) ) .. " ; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , msgBalance ) ) .. " ] "
2017-03-13 18:26:38 -03:00
2022-05-12 11:32:28 -03:00
modMinerTrade.doSoundPlayer ( playername , " sfx_atm " , 5 )
2022-05-12 17:03:46 -03:00
minetest.show_formspec (
playername ,
" frmAtmBalance " ,
formspec
)
2022-05-12 11:32:28 -03:00
end ,
2022-05-13 12:40:50 -03:00
frmStatement = function ( playername , selStatement ) --FORMULÁRIO: SALDO
2022-05-13 23:24:20 -03:00
local formspec = " size[16,10] "
2022-05-13 12:40:50 -03:00
.. " bgcolor[#636D7644;false] "
--.."bgcolor[#636D76FF;false]"
--..default.gui_bg
--..default.gui_bg_img
--..default.gui_slots
--.."bgcolor[#636D76FF;false]"
--.."background[-0.25,-0.25;10,11;safe_inside.png]"
--.."button[0,0.0;4,0.5;btnAtmMain;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("BACK"))).."]"
--.."button_exit[0,3.0;4,0.5;;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("EXIT"))).."]"
2022-05-13 23:24:20 -03:00
.. " box[0.00,0.10;5.50,9.5;#000000] "
.. " button[0.25,0.50;5.00,0.5;btnAtmMain; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " BACK " ) ) ) .. " ] "
.. " button_exit[0.25,6.50;5.00,0.5;; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " EXIT " ) ) ) .. " ] "
.. " box[6.0,0.25;9.5,9.5;#00000088] "
2022-05-13 12:40:50 -03:00
--.."background[5.0,0.25;9.5,9.5;text_atm_front.png]"
2022-05-13 23:24:20 -03:00
local msgStatement = modMinerTrade.translate ( " Select a bank statement to view transaction details! " )
2022-05-13 12:40:50 -03:00
local isAccount = modMinerTrade.isExistAcount ( playername )
if isAccount then
formspec = formspec
2022-05-13 23:24:20 -03:00
.. " label[6.25,0.50; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , modMinerTrade.translate ( " STATEMENT " ) .. " : " ) ) .. " ] "
2022-05-13 12:40:50 -03:00
--.. "label[5.25,2.50;"..minetest.formspec_escape(core.colorize("#00FFFF", msgStatement)).."]"
--"textarea[5.75,1.00;9.0,9.0;;"..minetest.formspec_escape(core.colorize("#00FFFF", modMinerTrade.translate("STATEMENT")..":"))..";"..minetest.formspec_escape(core.colorize("#00FFFF", msgStatement)).."]"
local listStatement = modMinerTrade.getStatement ( playername )
2022-05-14 21:41:54 -03:00
local plusStatement = " #888, " .. modMinerTrade.translate ( " N° " ) .. " , " .. modMinerTrade.translate ( " WHEN " ) .. " , " .. modMinerTrade.translate ( " VALUE " )
2022-05-13 12:40:50 -03:00
for i , oneStatement in ipairs ( listStatement ) do
local sign = " "
if oneStatement.value >= 1 then
sign = " + "
end
--local line = oneStatement.when.." | "..sign..oneStatement.value.." minercash."
2022-05-13 23:24:20 -03:00
local line = " #FFF, "
2022-05-14 21:41:54 -03:00
.. ( ( " %03d " ) : format ( i ) ) .. " , "
2022-05-13 23:24:20 -03:00
.. minetest.formspec_escape ( oneStatement.when )
.. " , "
2022-05-14 21:41:54 -03:00
.. minetest.formspec_escape ( sign .. ( " %02d " ) : format ( oneStatement.value ) .. " MT$. " )
2022-05-13 12:40:50 -03:00
if plusStatement == " " then
2022-05-13 23:24:20 -03:00
plusStatement = line
2022-05-13 12:40:50 -03:00
else
2022-05-13 23:24:20 -03:00
plusStatement = plusStatement .. " , " .. line
2022-05-13 12:40:50 -03:00
end
end
2022-05-13 23:24:20 -03:00
--[[ ]]
2022-05-13 12:40:50 -03:00
local value = modMinerTrade.getBalance ( playername )
if value ~= nil then
local sign = " "
if value >= 1 then
sign = " + "
end
2022-05-14 21:41:54 -03:00
plusStatement = plusStatement .. " ,#FFFF00,, "
2022-05-13 23:24:20 -03:00
--..minetest.formspec_escape(os.date("%Y-%B-%d %Hh:%Mm:%Ss"))
2022-05-14 21:41:54 -03:00
.. minetest.formspec_escape ( modMinerTrade.translate ( " TOTAL " ) .. " : " )
2022-05-13 23:24:20 -03:00
.. minetest.formspec_escape ( sign .. ( " %02d " ) : format ( value ) .. " minercash. " )
2022-05-14 21:41:54 -03:00
.. " , "
2022-05-13 12:40:50 -03:00
end
2022-05-13 23:24:20 -03:00
--]]
2022-05-13 12:40:50 -03:00
local mySel = " "
2022-05-13 23:24:20 -03:00
if selStatement ~= nil and type ( selStatement ) == " number " and selStatement >= 2 and selStatement <= # listStatement + 1 then
2022-05-13 12:40:50 -03:00
mySel = selStatement
2022-05-13 23:24:20 -03:00
msgStatement = dump ( listStatement [ selStatement - 1 ] . description )
2022-05-13 12:40:50 -03:00
end
formspec = formspec
.. " style[fldStatement;bgcolor=red;textcolor=yellow;border=true] "
2022-05-14 21:41:54 -03:00
.. " tablecolumns[color;text;text;text] "
2022-05-13 23:24:20 -03:00
.. " table[6.25,1.00;9.0,6.75;fldStatement; " .. plusStatement .. " ; " .. mySel .. " ] "
2022-05-13 12:40:50 -03:00
--.. "textlist[5.25,1.00;9.0,6.0;fldStatement;"..plusStatement..";"..mySel.."]"
--.."tablecolumns[cell1,opt1_a,opt2_a;cell2,opt1_b,opt2_b;type_c,opt1_c,opt2_c]"
--.."tableoptions[opt1;opt2;opt3]"
else
msgStatement = modMinerTrade.translate ( " Player '%s' is not an account holder of this bank. " ) : format ( playername )
end
formspec = formspec
2022-05-13 23:24:20 -03:00
.. " textarea[6.75,8.50;9.0,1.5;; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , modMinerTrade.translate ( " TRANSACTION DETAILS " ) .. " : " ) ) .. " ; "
2022-05-13 12:40:50 -03:00
.. minetest.formspec_escape ( core.colorize ( " #00FFFF " , msgStatement ) )
.. " ] "
minetest.show_formspec (
playername ,
" frmAtmStatement " ,
formspec
)
end ,
2022-05-13 23:24:20 -03:00
frmWithdrawals = function ( playername ) --FORMULÁRIO: SAQUE
local formspec = " size[16,10] "
.. " bgcolor[#636D7688;false] "
--.."bgcolor[#636D76FF;false]"
--..default.gui_bg
--..default.gui_bg_img
--..default.gui_slots
.. " box[0.00,0.10;5.50,9.5;#000000] "
.. " button[0.25,0.50;5.00,0.5;btnAtmMain; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " BACK " ) ) ) .. " ] "
.. " button_exit[0.25,6.50;5.00,0.5;; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " EXIT " ) ) ) .. " ] "
.. " background[6.0,0.25;9.5,9.5;text_atm_front.png] "
.. " box[6.0,0.25;9.5,9.5;#000000CC] "
2022-05-15 01:27:41 -03:00
.. " label[6.75,0.75; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , modMinerTrade.translate ( " SELECT BANK WITHDRAWAL METHOD " ) .. " : " ) ) .. " ] "
2022-05-13 23:24:20 -03:00
--.. "textarea[5.75,1.00;9.0,9.0;;"..minetest.formspec_escape(core.colorize("#00FFFF", modMinerTrade.translate("BALANCES")..":"))..";"..minetest.formspec_escape(core.colorize("#00FFFF", msgBalance)).."]"
--.. "button[6.25,1.50;1.00,1.00;btnAtmMain;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("BACK"))).."]"
--.."style_type[image_button;bgcolor=#00000000;border=false]"
--.."style[btnMinercoin;bgimg=sbl_save.png;bgimg_hovered=sbl_save_pressed.png;bgimg_pressed=sbl_save_pressed.png;border=false]"
2022-05-15 01:27:41 -03:00
.. " label[9.25,3.25; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " MINERCASH " ) ) ) .. " ] "
2022-05-13 23:24:20 -03:00
.. " tooltip[btnMinercoin; " .. minetest.formspec_escape ( modMinerTrade.translate ( " Withdrawals in minercash. " ) ) .. " ;#CCCC0088;#000000] "
.. " image_button[7.25,2.50;2.00,2.00;obj_minercoin.png;btnGiveCash;] "
2022-05-15 01:27:41 -03:00
.. " label[9.25,5.75; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " BANK CHECK " ) ) ) .. " ] "
2022-05-13 23:24:20 -03:00
.. " tooltip[btnMinercoin; " .. minetest.formspec_escape ( modMinerTrade.translate ( " Withdrawals in bank check. " ) ) .. " ;#CCCC0088;#000000] "
.. " image_button[7.25,5.00;2.00,2.00;obj_bank_check.png;btnGiveCheck;] "
2017-03-13 18:26:38 -03:00
2022-05-12 11:32:28 -03:00
modMinerTrade.doSoundPlayer ( playername , " sfx_atm " , 5 )
minetest.show_formspec ( playername , " frmAtmWithdrawals " , formspec )
2017-03-13 18:26:38 -03:00
end ,
2022-05-13 23:24:20 -03:00
frmGiveCash = function ( playername , txtValue , msgDetails ) --FORMULÁRIO: SAQUE
modMinerTrade.debug ( " modMinerTrade.showAtm.frmGiveCash() >>> playername = " .. playername .. " | txtValue = " .. dump ( txtValue ) .. " | msgDetails = " .. dump ( msgDetails ) )
local msgBalance = " "
if modMinerTrade.isExistAcount ( playername ) then
msgBalance = modMinerTrade.translate ( " You have %02d minercash. " ) : format ( modMinerTrade.getBalance ( playername ) )
else
msgBalance = modMinerTrade.translate ( " Player '%s' is not an account holder of this bank. " ) : format ( playername )
end
local formspec = " size[16,10] "
.. " bgcolor[#636D7688;false] "
--.."bgcolor[#636D76FF;false]"
--..default.gui_bg
--..default.gui_bg_img
--..default.gui_slots
.. " box[0.00,0.10;5.50,9.5;#000000] "
.. " button[0.25,0.50;5.00,0.5;btnWithdrawals; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " BACK " ) ) ) .. " ] "
.. " button_exit[0.25,6.50;5.00,0.5;; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " EXIT " ) ) ) .. " ] "
.. " background[6.0,0.25;9.5,9.5;text_atm_front.png] "
.. " box[6.0,0.25;9.5,9.5;#000000CC] "
.. " textarea[6.75,1.00;9.0,9.0;; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , modMinerTrade.translate ( " BALANCES " ) .. " : " ) ) .. " ; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , msgBalance ) ) .. " ] "
if modMinerTrade.isExistAcount ( playername ) then
if txtValue == nil or txtValue == " " then
txtValue = " 1 "
end
if msgDetails == nil or msgDetails == " " then
msgDetails = modMinerTrade.translate ( " Write the value that want to withdrawal! " )
end
formspec = formspec
--.. "label[5.25,0.50;"..minetest.formspec_escape(core.colorize("#00FFFF", "WITHDRAWAL IN MINERCASH:")).."]"
.. " field[7.00,3.50;3.00,0.50;txtValue; "
.. minetest.formspec_escape (
core.colorize (
" #00FFFF " ,
modMinerTrade.translate ( " VALUE " ) .. " : "
)
) .. " ; "
.. minetest.formspec_escape ( txtValue )
.. " ] "
.. " button[9.85,3.00;4.00,1.00;btnAtmGive; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " WITHDRAWAL " ) ) ) .. " ] "
2017-03-13 18:26:38 -03:00
2022-05-13 23:24:20 -03:00
.. " textarea[6.75,8.50;9.0,1.5;; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , modMinerTrade.translate ( " DETAILS " ) .. " : " ) ) .. " ; "
.. minetest.formspec_escape ( core.colorize ( " #00FFFF " , msgDetails ) )
.. " ] "
end
--.. "textarea[5.75,1.00;9.0,9.0;;"..minetest.formspec_escape(core.colorize("#00FFFF", modMinerTrade.translate("BALANCES")..":"))..";"..minetest.formspec_escape(core.colorize("#00FFFF", msgBalance)).."]"
--.. "button[6.25,1.50;1.00,1.00;btnAtmMain;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("BACK"))).."]"
--.."style_type[image_button;bgcolor=#00000000;border=false]"
--.."style[btnMinercoin;bgimg=sbl_save.png;bgimg_hovered=sbl_save_pressed.png;bgimg_pressed=sbl_save_pressed.png;border=false]"
--[[
.. " label[7.25,2.75; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , " MINERCASH " ) ) .. " ] "
.. " tooltip[btnMinercoin; " .. minetest.formspec_escape ( modMinerTrade.translate ( " Withdrawals in minercash. " ) ) .. " ;#CCCC0088;#000000] "
.. " image_button[5.25,2.00;2.00,2.00;obj_minercoin.png;btnGiveCash;] "
.. " label[7.25,5.25; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , " BANK CHECK " ) ) .. " ] "
.. " tooltip[btnMinercoin; " .. minetest.formspec_escape ( modMinerTrade.translate ( " Withdrawals in bank check. " ) ) .. " ;#CCCC0088;#000000] "
.. " image_button[5.25,4.50;2.00,2.00;obj_bank_check.png;btnGiveCheck;] "
--]]
minetest.show_formspec ( playername , " frmAtmGiveCash " , formspec )
end ,
2022-05-15 01:27:41 -03:00
frmDeposits = function ( playername ) --FORMULÁRIO: SAQUE
-- playername = player:get_player_name()
2022-05-16 05:13:48 -03:00
local newInv = minetest.create_detached_inventory ( " deposits_ " .. playername , {
2022-05-15 01:27:41 -03:00
-- Called when a player wants to move items inside the inventory
allow_move = function ( inv , from_list , from_index , to_list , to_index , count , player )
--return count
return 0
end ,
-- Called when a player wants to put items into the inventory
allow_put = function ( inv , listname , index , stack , player )
if modMinerTrade.checkValidStack ( stack ) >= 1 then
return stack : get_count ( )
else
return 0
end
end ,
-- Called when a player wants to take items out of the inventory
allow_take = function ( inv , listname , index , stack , player )
if modMinerTrade.checkValidStack ( stack ) >= 1 then
return 0
else
return stack : get_count ( )
end
end ,
-- on_* - no return value
-- Called after the actual action has happened, according to what was allowed.
on_move = function ( inv , from_list , from_index , to_list , to_index , count , player )
--modMinerTrade.setSafeInventory(playername, inv:get_list("safe"))
--minetest.log('action',playername.." colocou "..stack:get_count().." '"..stack:get_name().."' em seu cofre!")
end ,
on_put = function ( inv , listname , index , stack , player )
--modMinerTrade.setSafeInventory(playername, inv:get_list("safe"))
--minetest.log('action',modMinerTrade.translate("Player '%s' has placed %02d '%s' in his safe!"):format(playername, stack:get_count(), stack:get_name()))
local playername = player : get_player_name ( )
if modMinerTrade.checkValidStack ( stack ) >= 1 then
local stackValue = modMinerTrade.getValueStack ( stack )
--modMinerTrade.debug("modMinerTrade.convValueToItemList() >>> items = "..dump(items).." | newItem = "..dump(newItem))
if stackValue >= 1 then
modMinerTrade.addBalance ( playername , stackValue )
modMinerTrade.addStatement (
playername , stackValue ,
( " You deposited %02d x '%s'! " ) : format ( stack : get_count ( ) , stack : get_name ( ) )
)
--stack:take_item(stack:get_count())
stack : take_item ( )
modMinerTrade.doSoundPlayer ( playername , " sfx_cash_register " , 5 )
modMinerTrade.showAtm . frmDeposits ( playername )
end
else
modMinerTrade.doSoundPlayer ( playername , " sfx_failure " , 5 )
end
--return stack
end ,
on_take = function ( inv , listname , index , stack , player )
--modMinerTrade.setSafeInventory(playername, inv:get_list("safe"))
--minetest.log('action',modMinerTrade.translate("Player '%s' has removed %02d '%s' in his safe!"):format(playername, stack:get_count(), stack:get_name()))
end ,
} )
newInv : set_size ( " deposit " , 1 )
newInv : set_stack ( " deposit " , 1 , nil )
2022-05-15 09:57:51 -03:00
local msgBalance = " "
if modMinerTrade.isExistAcount ( playername ) then
msgBalance = modMinerTrade.translate ( " You have %02d minercash. " ) : format ( modMinerTrade.getBalance ( playername ) )
2022-05-15 01:27:41 -03:00
else
2022-05-15 09:57:51 -03:00
msgBalance = modMinerTrade.translate ( " Player '%s' is not an account holder of this bank. " ) : format ( playername )
2022-05-15 01:27:41 -03:00
end
local formspec = " size[16,10] "
.. " bgcolor[#636D7688;false] "
--.."bgcolor[#636D76FF;false]"
--..default.gui_bg
--..default.gui_bg_img
--..default.gui_slots
.. " box[0.00,0.10;5.50,9.5;#000000] "
.. " button[0.25,0.50;5.00,0.5;btnAtmMain; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " BACK " ) ) ) .. " ] "
.. " button_exit[0.25,6.50;5.00,0.5;; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " EXIT " ) ) ) .. " ] "
.. " background[6.0,0.25;9.5,9.5;text_atm_front.png] "
2022-05-15 09:57:51 -03:00
.. " box[6.0,0.25;9.5,9.5;#000000AA] "
2022-05-15 01:27:41 -03:00
2022-05-15 09:57:51 -03:00
.. " label[6.50,0.50; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , modMinerTrade.translate ( " BANK DEPOSIT " ) ) ) .. " ] "
2022-05-15 01:27:41 -03:00
--.. "textarea[5.75,1.00;9.0,9.0;;"..minetest.formspec_escape(core.colorize("#00FFFF", modMinerTrade.translate("BALANCES")..":"))..";"..minetest.formspec_escape(core.colorize("#00FFFF", msgBalance)).."]"
2022-05-15 09:57:51 -03:00
.. " box[6.5,1.50;8.5,1.05;#00FF0044] "
.. " textarea[7.25,2.00;9.0,2.0;; "
.. minetest.formspec_escape ( core.colorize ( " #FFFF00 " , modMinerTrade.translate ( " YOUR BALANCE " ) .. " : " ) ) .. " ; "
.. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , minetest.formspec_escape ( msgBalance ) ) )
.. " ] "
2022-05-15 01:27:41 -03:00
--listcolors[slot_bg_normal;slot_bg_hover;slot_border;tooltip_bgcolor;tooltip_fontcolor]
.. " listcolors[#88888866;#666666;#CCCCCC;#444444;#FFFFFF] "
.. " label[7.00,3.00; " .. minetest.formspec_escape ( modMinerTrade.translate ( " ATM entrance " ) ) .. " :] "
2022-05-15 09:57:51 -03:00
.. " image[9.00,3.35;2,2;obj_minercoin.png] "
.. " image[10.50,3.75;1,1;gui_arrow.png^[transformR270] "
2022-05-16 05:13:48 -03:00
.. " list[detached: " .. minetest.formspec_escape ( " deposits_ " .. playername ) .. " ;deposit;11.50,3.75;1,1;] "
2022-05-15 01:27:41 -03:00
--.."button[3,2.0;2,1;exchange;"..minetest.formspec_escape(modMinerTrade.translate("DEPOSIT")).."]"
.. " label[7.00,5.00; " .. minetest.formspec_escape ( modMinerTrade.translate ( " Your Inventory " ) ) .. " :] "
.. " list[current_player;main;7.00,5.50;8,4;] "
minetest.show_formspec ( playername , " frmAtmDeposits " , formspec )
end ,
2022-05-12 11:32:28 -03:00
}
2022-05-15 01:27:41 -03:00
modMinerTrade.getCashTypes = function ( )
return {
[ 1 ] = " minertrade:minercoin " ,
[ 2 ] = " minertrade:minermoney_blue " ,
[ 3 ] = " minertrade:minermoney_green " ,
[ 4 ] = " minertrade:minermoney_yellow " ,
[ 5 ] = " minertrade:minermoney_orange " ,
[ 6 ] = " minertrade:minermoney_red " ,
[ 7 ] = " minertrade:minermoney_black " ,
}
end
2022-05-13 23:24:20 -03:00
modMinerTrade.convValueToItemList = function ( value )
if value ~= nil
and type ( value ) == " number "
and value >= 1
then
2022-05-15 01:27:41 -03:00
local moneytypes = modMinerTrade.getCashTypes ( )
2022-05-13 23:24:20 -03:00
local items = { }
for i = # moneytypes , 1 , - 1 do
local valMoney = 9 ^ ( i - 1 )
local money = math.floor ( value / valMoney )
local decrease = money * valMoney
value = value - decrease
if money >= 1 then
local newItem = {
name = moneytypes [ i ] ,
amount = money ,
price = decrease
}
--modMinerTrade.debug("modMinerTrade.convValueToItemList() >>> items = "..dump(items).." | newItem = "..dump(newItem))
table.insert ( items , newItem )
end
if value == 0 then break end
end
return items
end
end
2022-05-16 05:13:48 -03:00
modMinerTrade.delDetachedInventory = function ( playername )
--core.detached_inventories["safe_"..ownername] = nil
return minetest.remove_detached_inventory ( " deposits_ " .. playername )
--return minetest.remove_detached_inventory_raw("safe_"..ownername)
end
2022-05-12 17:03:46 -03:00
modMinerTrade.onReceiveFields = function ( player , formname , fields )
local playername = player : get_player_name ( )
2022-05-13 12:40:50 -03:00
--modMinerTrade.debug("modMinerTrade.onReceiveFields() >>> player = "..playername.." | formname = "..formname.." | fields = "..dump(fields))
2022-05-12 11:32:28 -03:00
if fields.btnAtmMain ~= nil then
2022-05-13 23:24:20 -03:00
modMinerTrade.doSoundPlayer ( playername , " sfx_atm " , 5 )
2022-05-12 11:32:28 -03:00
modMinerTrade.showAtm . frmMain ( playername )
2022-05-16 05:13:48 -03:00
elseif fields.quit then
--são funções importantíssimas para não perder inventário do jogador e nem calça legging no servidor.
modMinerTrade.doBankSave ( )
local isDeleted = modMinerTrade.delDetachedInventory ( playername )
modMinerTrade.debug ( " modMinerTrade.onReceiveFields() >>> Database saved and delete detached inventory... Done [ " .. dump ( isDeleted ) .. " ] " )
2022-05-12 11:32:28 -03:00
else
if formname == " frmAtmMain " then
2022-05-12 17:03:46 -03:00
if fields.btnBalance ~= nil then
2022-05-12 11:32:28 -03:00
modMinerTrade.showAtm . frmBalance ( playername )
2022-05-13 12:40:50 -03:00
elseif fields.btnStatement ~= nil then
modMinerTrade.doSoundPlayer ( playername , " sfx_atm " , 5 )
modMinerTrade.showAtm . frmStatement ( playername )
2022-05-12 11:32:28 -03:00
elseif fields.btnWithdrawals ~= nil then
modMinerTrade.showAtm . frmWithdrawals ( playername )
2022-05-15 01:27:41 -03:00
elseif fields.btnDeposits ~= nil then
modMinerTrade.doSoundPlayer ( playername , " sfx_atm " , 5 )
modMinerTrade.showAtm . frmDeposits ( playername )
2022-05-12 11:32:28 -03:00
end
2022-05-13 12:40:50 -03:00
elseif formname == " frmAtmStatement " then
--modMinerTrade.debug("modMinerTrade.onReceiveFields() >>> player = "..playername.." | formname = "..formname.." | fields = "..dump(fields))
if fields.fldStatement ~= nil then
local tblStatement = modMinerTrade.getStatement ( playername )
local fldStatement = minetest.explode_table_event ( fields.fldStatement )
2022-05-13 23:24:20 -03:00
if fldStatement.row ~= nil and type ( fldStatement.row ) == " number " and fldStatement.row >= 2 and fldStatement.row <= # tblStatement + 1 then
--modMinerTrade.debug("modMinerTrade.onReceiveFields() >>> fldStatement = "..dump(fldStatement))
2022-05-13 12:40:50 -03:00
modMinerTrade.showAtm . frmStatement ( playername , fldStatement.row )
end
end
2022-05-13 23:24:20 -03:00
elseif formname == " frmAtmWithdrawals " then
if fields.btnGiveCash ~= nil then
modMinerTrade.doSoundPlayer ( playername , " sfx_atm " , 5 )
modMinerTrade.showAtm . frmGiveCash ( playername )
elseif fields.btnGiveCheck ~= nil then
modMinerTrade.doSoundPlayer ( playername , " sfx_failure " , 5 )
end
elseif formname == " frmAtmGiveCash " then
--modMinerTrade.debug("modMinerTrade.onReceiveFields() >>> player = "..playername.." | formname = "..formname.." | fields = "..dump(fields))
if fields.btnWithdrawals ~= nil then
modMinerTrade.doSoundPlayer ( playername , " sfx_atm " , 5 )
modMinerTrade.showAtm . frmWithdrawals ( playername )
elseif fields.btnAtmGive ~= nil
and fields.txtValue ~= nil
and tonumber ( fields.txtValue ) ~= nil
and type ( tonumber ( fields.txtValue ) ) == " number "
and tonumber ( fields.txtValue ) >= 1
then
local myValue = fields.txtValue
if modMinerTrade.isExistAcount ( playername ) then
local myBalance = modMinerTrade.getBalance ( playername )
if tonumber ( myValue ) <= myBalance then
local player = minetest.get_player_by_name ( playername )
if player ~= nil and player : is_player ( ) then
local delivered = 0
local items = modMinerTrade.convValueToItemList ( tonumber ( myValue ) )
--modMinerTrade.debug("modMinerTrade.onReceiveFields() >>> formname = "..formname.." | items = "..dump(items))
if items ~= nil
and type ( items ) == " table "
and # items >= 1
then
local minv = player : get_inventory ( )
for _ , item in ipairs ( items ) do
--if not pinv:contains_item("customer_gives",item) then
local itemdesc = item.name .. " " .. item.amount
if minv : room_for_item ( " main " , itemdesc ) then -- verifica se compartimento de Recebimento de pagamento do vendedor tem espaço
minv : add_item ( " main " , itemdesc )
delivered = delivered + item.price
else
break
end
end
end
if delivered >= 1 then
modMinerTrade.addBalance ( playername , 0 - delivered )
modMinerTrade.addStatement (
playername , 0 - delivered ,
( " You have withdrawn %02d minercash from your bank account. " ) : format ( delivered )
)
end
if delivered == tonumber ( myValue ) then
modMinerTrade.doSoundPlayer ( playername , " sfx_cash_register " , 5 )
modMinerTrade.showAtm . frmMain ( playername )
else
modMinerTrade.doSoundPlayer ( playername , " sfx_failure " , 5 )
modMinerTrade.showAtm . frmGiveCash ( playername ,
tonumber ( myValue ) - delivered ,
modMinerTrade.translate (
" you don't have space in your inventory to withdraw so much minercash. "
)
)
end
end
else
modMinerTrade.doSoundPlayer ( playername , " sfx_failure " , 5 )
modMinerTrade.showAtm . frmGiveCash ( playername ,
myValue ,
modMinerTrade.translate (
" The maximum amount you can withdraw is: %02d minercash. "
) : format ( myBalance )
)
end
else
modMinerTrade.doSoundPlayer ( playername , " sfx_failure " , 5 )
end
end
2017-03-13 18:26:38 -03:00
end
2022-05-12 11:32:28 -03:00
end
end
2022-05-13 23:24:20 -03:00
2022-05-12 11:32:28 -03:00
--###############################################################################################################
2022-05-12 17:03:46 -03:00
minetest.register_node ( " minertrade:atm " , {
description = modMinerTrade.translate ( " PUBLIC ATM \n * Save your money in the ATM, and withdraw your money in your Personal Safe or other ATM in the shops scattered around the map. " ) ,
--inventory_image = minetest.inventorycube("text_atm_front_1.png"),
--inventory_image = "text_atm_front_1.png",
paramtype = " light " ,
sunlight_propagates = true ,
light_source = default.LIGHT_MAX ,
paramtype2 = " facedir " ,
--legacy_facedir_simple = true, --<=Nao sei para que serve!
is_ground_content = false ,
groups = { cracky = 1 } ,
--groups = {cracky=3,oddly_breakable_by_hand=3},
--sounds = default.node_sound_glass_defaults(),
tiles = {
--[[
" default_wood.png " ,
" default_wood.png " ,
" default_wood.png " ,
" default_wood.png " ,
" default_wood.png " ,
" text_atm_front_1.png " ,
--]]
--[[
" safe_side.png " ,
" safe_side.png " ,
" safe_side.png " ,
" safe_side.png " ,
" safe_side.png " ,
" safe_side.png^text_atm_front.png " ,
--]]
" default_steel_block.png " ,
" default_steel_block.png " ,
" default_steel_block.png " ,
" default_steel_block.png " ,
" default_steel_block.png " ,
" default_steel_block.png^text_atm_front.png " ,
} ,
on_place = function ( itemstack , placer , pointed_thing )
local playername = placer : get_player_name ( )
if not pointed_thing.type == " node " then
return itemstack
end
local posAbove = pointed_thing.above --acima
local posUnder = pointed_thing.under --abaixo
if not placer or not placer : is_player ( ) or
not minetest.registered_nodes [ minetest.get_node ( posAbove ) . name ] . buildable_to
then --Verifica se pode construir sobre os objetos construiveis
return itemstack
end
local nodeUnder = minetest.get_node ( posUnder )
if minetest.registered_nodes [ nodeUnder.name ] . on_rightclick then --Verifica se o itema na mao do jogador tem funcao rightclick
return minetest.registered_nodes [ nodeUnder.name ] . on_rightclick ( posUnder , nodeUnder , placer , itemstack )
end
if
minetest.get_player_privs ( playername ) . server
or modMinerTrade.getNodesInRange ( posAbove , 2 , " minertrade:dispensingmachine " ) >= 1
then
local facedir = minetest.dir_to_facedir ( placer : get_look_dir ( ) )
--minetest.chat_send_player(playername, "[ATM] aaaaaa")
minetest.set_node ( posAbove , {
name = " minertrade:atm " ,
param2 = facedir ,
} )
local meta = minetest.get_meta ( posAbove )
--meta:set_string("infotext", modMinerTrade.translate("PUBLIC ATM\n* Save your money in the ATM, and withdraw your money in your Personal Safe or other ATM in the shops scattered around the map."))
local now = os.time ( ) --Em milisegundos
if not minetest.get_player_privs ( playername ) . server then
meta : set_string ( " opentime " , now + modMinerTrade.delayConstruct )
else
meta : set_string ( " opentime " , now )
end
itemstack : take_item ( ) -- itemstack:take_item() = Ok
else
minetest.chat_send_player ( playername ,
core.colorize ( " #00ff00 " , " [ " .. modMinerTrade.translate ( " ATM " ) .. " ]: " )
.. modMinerTrade.translate ( " You can not install this 'ATM' too far from a 'Dispensing Machine'! " )
)
--return itemstack -- = Cancel
end
return itemstack
end ,
on_rightclick = function ( pos , node , clicker )
local clickername = clicker : get_player_name ( )
local meta = minetest.get_meta ( pos )
--meta:set_string("infotext", modMinerTrade.translate("PUBLIC ATM\n* Save your money in the ATM, and withdraw your money in your Personal Safe or other ATM in the shops scattered around the map."))
local opentime = tonumber ( meta : get_string ( " opentime " ) ) or 0
local now = os.time ( ) --Em milisegundos
if now >= opentime or minetest.get_player_privs ( clickername ) . server then
--[[
modMinerTrade.showInventory (
clicker ,
clickername ,
modMinerTrade.translate ( " PUBLIC ATM - Account of '%s': " ) : format ( clickername )
)
--]]
2022-05-13 23:24:20 -03:00
modMinerTrade.doSoundPlayer ( clickername , " sfx_atm " , 5 )
2022-05-12 17:03:46 -03:00
modMinerTrade.showAtm . frmMain ( clickername )
else
--minetest.sound_play("sfx_failure", {object=clicker, max_hear_distance=5.0,})
modMinerTrade.doSoundPlayer ( clickername , " sfx_failure " , 5 )
minetest.chat_send_player ( clickername ,
core.colorize ( " #00ff00 " , " [ " .. modMinerTrade.translate ( " ATM " ) .. " ]: " )
.. modMinerTrade.translate (
" The ATM will only run %02d seconds after it is installed! "
) : format ( opentime - now )
)
end
2022-05-12 23:32:22 -03:00
--modMinerTrade.debug("on_rightclick() >>> "..modMinerTrade.getUrlDatabase())
2022-05-12 17:03:46 -03:00
end ,
} )
--[[
minetest.register_craft ( {
output = ' minertrade:atm ' ,
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 ( " atm " , " minertrade:atm " )
minetest.register_alias ( modMinerTrade.translate ( " atm " ) , " minertrade:atm " )
2022-05-12 23:32:22 -03:00
minetest.register_on_player_receive_fields ( function ( sender , formname , fields )
return modMinerTrade.onReceiveFields ( sender , formname , fields )
end )
minetest.register_on_joinplayer ( function ( player )
local playername = player : get_player_name ( )
if not modMinerTrade.isExistAcount ( playername ) then
modMinerTrade.createAcount ( playername )
end
end )
minetest.register_on_leaveplayer ( function ( player )
modMinerTrade.doBankSave ( )
end )
minetest.register_on_shutdown ( function ( )
modMinerTrade.doBankSave ( )
minetest.log ( ' action ' , " [STRONGBOX] " .. modMinerTrade.translate ( " Saving bank from all players in the file '%s'! " ) : format ( modMinerTrade.getUrlDatabase ( ) ) )
end )