2022-06-06 13:28:02 -03:00
minetest.register_privilege ( " developer " , {
description = modMinerTrade.translate ( " Can access evolving ATM functions. " ) ,
give_to_singleplayer = false ,
} )
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
2022-06-08 02:48:08 -03:00
modMinerTrade.getDelayToUse = function ( )
if modMinerTrade.delay_to_use == nil then
modMinerTrade.delay_to_use = minetest.settings : get ( " minertrade.delay_to_use " )
if modMinerTrade.delay_to_use == nil
or type ( tonumber ( modMinerTrade.delay_to_use ) ) ~= " number "
or tonumber ( modMinerTrade.delay_to_use ) < 1
then
modMinerTrade.delay_to_use = 300 -- 300 = 5 minutes
minetest.settings : set ( " minertrade.delay_to_use " , modMinerTrade.delay_to_use )
end
end
return tonumber ( modMinerTrade.delay_to_use )
end
2022-06-02 09:48:39 -03:00
modMinerTrade.canInteract = function ( playername )
--local clickername = clicker:get_player_name()
2022-06-03 00:57:09 -03:00
if minetest.get_player_privs ( playername ) . mayor then
2022-06-02 09:48:39 -03:00
return true
end
2022-06-03 00:57:09 -03:00
return false
2022-06-02 09:48:39 -03:00
end
2022-05-12 11:32:28 -03:00
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 "
2022-06-01 12:55:32 -03:00
or tonumber ( maxStatements ) < 1 --Min
or tonumber ( maxStatements ) > 300 --Max
2022-05-14 21:41:54 -03:00
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-06-06 17:45:54 -03:00
when = os.date ( " %Y-%b-%d %H:%M:%S " ) ,
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-06-06 13:28:02 -03:00
modMinerTrade.getSalt_Hash = function ( )
if modMinerTrade.bank . salt_hash == nil then
2022-06-06 17:45:54 -03:00
modMinerTrade.bank . salt_hash = minetest.encode_base64 ( " SALT_HASH: " .. os.date ( " %Y-%B-%d %Hh:%Mm:%Ss " ) )
2022-06-06 13:28:02 -03:00
end
return modMinerTrade.bank . salt_hash
end
2023-08-09 20:41:29 -03:00
modMinerTrade.addTransferProof = function ( player , accountname , txtBeneficiary , txtValue , txtReason )
local playername = player : get_player_name ( )
local objProof = modMinerTrade.getProofStack ( playername , accountname , txtBeneficiary , txtValue , txtReason )
local invPlayer = player : get_inventory ( )
if invPlayer : room_for_item ( " main " , objProof ) then -- verifica se compartimento de Recebimento de pagamento do vendedor tem espaço
invPlayer : add_item ( " main " , objProof )
minetest.chat_send_player ( playername ,
core.colorize ( " #00FF00 " , " [ " .. modMinerTrade.translate ( " ATM " ) .. " ]: " )
.. modMinerTrade.translate ( " Transfer successful! " )
)
else
minetest.add_item ( player : get_pos ( ) , objProof )
minetest.chat_send_player ( playername ,
core.colorize ( " #00FF00 " , " [ " .. modMinerTrade.translate ( " ATM " ) .. " ]: " )
.. core.colorize ( " #FF0000 " ,
modMinerTrade.translate ( " The Transfer Proof was left on the floor because '%s' inventory has no free space. " ) : format ( playername )
)
)
end
end
2022-06-06 17:45:54 -03:00
modMinerTrade.getProofStack = function ( playername , accountname , txtBeneficiary , txtValue , txtReason )
2022-06-06 13:28:02 -03:00
local player = minetest.get_player_by_name ( playername )
if player ~= nil and player : is_player ( ) then
2022-06-06 17:45:54 -03:00
local lpp = 14 -- Lines per book's page
2022-06-06 13:28:02 -03:00
local max_text_size = 10000
local max_title_size = 80
local short_title_size = 35
local objProof = ItemStack ( " default:book_written " )
--local data = objProof:get_meta():to_table().fields
local data = { }
--data.title = fields.title:sub(1, max_title_size)
data.title = modMinerTrade.translate ( " TRANSFER PROOF " ) : sub ( 1 , max_title_size )
2022-06-06 17:45:54 -03:00
data.owner = " MINETEST BANK "
data.description = core.colorize ( " #00FF00 " , data.title )
.. " \n " .. modMinerTrade.translate ( " Reason: %s " ) : format ( txtReason )
--.."\n"..modMinerTrade.translate("Printed by %s"):format(playername)
2022-06-06 13:28:02 -03:00
local when = os.date ( " %Y-%B-%d %Hh:%Mm:%Ss " )
local myDocument = " "
2022-06-06 17:45:54 -03:00
.. " \n " .. modMinerTrade.translate ( " Document Type " ) .. " : " .. modMinerTrade.translate ( " TRANSFER PROOF " )
.. " \n " .. modMinerTrade.translate ( " Responsible Player " ) .. " : " .. playername
.. " \n " .. modMinerTrade.translate ( " Account Holder " ) .. " : " .. accountname
.. " \n " .. modMinerTrade.translate ( " Beneficiary " ) .. " : " .. txtBeneficiary
.. " \n " .. modMinerTrade.translate ( " When " ) .. " : " .. when
.. " \n " .. modMinerTrade.translate ( " Value " ) .. " : " .. txtValue .. " minercash "
.. " \n " .. modMinerTrade.translate ( " Transfer Reason " ) .. " : " .. txtReason
2022-06-06 13:28:02 -03:00
local Auth = minetest.get_password_hash (
modMinerTrade.getSalt_Hash ( ) ,
2022-06-06 17:45:54 -03:00
minetest.encode_base64 ( myDocument : trim ( ) )
2022-06-06 13:28:02 -03:00
)
2022-06-06 17:45:54 -03:00
data.text = " "
.. " \n " .. myDocument : trim ( )
2022-06-06 13:28:02 -03:00
.. " \n ---------------------------------- "
.. " \n " .. Auth
data.text = data.text : sub ( 1 , max_text_size )
data.text = data.text : gsub ( " \r \n " , " \n " ) : gsub ( " \r " , " \n " )
data.page = 1
data.page_max = math.ceil ( ( # data.text : gsub ( " [^ \n ] " , " " ) + 1 ) / lpp )
objProof : get_meta ( ) : from_table ( { fields = data } )
return objProof
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-06-03 00:57:09 -03:00
modMinerTrade.showAccountBank = {
--modMinerTrade.showAccountBank.inAtm(playername, accountname)
inAtm = function ( playername , accountname )
modMinerTrade.bank . player [ playername ] . focused_accountname = accountname
modMinerTrade.bank . player [ playername ] . focused_accountmode = " atm "
modMinerTrade.doSoundPlayer ( playername , " sfx_atm " , 5 )
modMinerTrade.showAccountBank . frmMain ( playername )
end ,
--modMinerTrade.showAccountBank.inCreditCard(playername, accountname)
inCreditCard = function ( playername , accountname )
modMinerTrade.bank . player [ playername ] . focused_accountname = accountname
modMinerTrade.bank . player [ playername ] . focused_accountmode = " online "
modMinerTrade.doSoundPlayer ( playername , " sfx_atm " , 5 )
modMinerTrade.showAccountBank . frmMain ( playername )
end ,
2022-05-12 11:32:28 -03:00
frmMain = function ( playername ) --FORMULÁRIO: PRINCIPAL / RAIZ
2022-06-03 00:57:09 -03:00
local accountname = modMinerTrade.bank . player [ playername ] . focused_accountname
local accountmode = modMinerTrade.bank . player [ playername ] . focused_accountmode
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-06-08 09:23:18 -03:00
.. " button[0.25,3.50;5.00,0.5;btnTransfers; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " TRANSFERS " ) ) ) .. " ] "
2022-06-03 00:57:09 -03:00
if
accountmode ~= nil
and type ( accountmode ) == " string "
and accountmode == " atm "
then
formspec = formspec
.. " button[0.25,2.00;5.00,0.5;btnDeposits; " .. minetest.formspec_escape ( core.colorize ( " #FFFFF " , modMinerTrade.translate ( " DEPOSITS " ) ) ) .. " ] "
.. " button[0.25,2.75;5.00,0.5;btnWithdrawals; " .. minetest.formspec_escape ( core.colorize ( " #FFFFF " , modMinerTrade.translate ( " WITHDRAWALS " ) ) ) .. " ] " -- [DINHEIRO E CHECK]
2022-06-08 09:23:18 -03:00
end
if minetest.get_player_privs ( playername ) . developer then
formspec = formspec
.. " 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,4.25;5.00,0.5;btnLoans; " .. minetest.formspec_escape ( core.colorize ( " #888888 " , modMinerTrade.translate ( " LOANS " ) ) ) .. " ] " --Emprestimos
2022-06-21 01:27:02 -03:00
.. " button[0.25,5.75;5.00,0.5;btnLottery; " .. minetest.formspec_escape ( core.colorize ( " #888888 " , modMinerTrade.translate ( " LOTTERY " ) ) ) .. " ] " --Lotérica
.. " button[0.25,6.50;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.
2022-06-03 00:57:09 -03:00
end
formspec = formspec
2022-06-21 01:27:02 -03:00
.. " button_exit[0.25,7.25;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 11:32:28 -03:00
minetest.show_formspec ( playername , " frmAtmMain " , formspec )
end ,
frmBalance = function ( playername ) --FORMULÁRIO: SALDO
2022-06-03 00:57:09 -03:00
local accountname = modMinerTrade.bank . player [ playername ] . focused_accountname
2022-05-12 11:32:28 -03:00
local msgBalance = " "
2022-06-03 00:57:09 -03:00
if modMinerTrade.isExistAcount ( accountname ) then
msgBalance = modMinerTrade.translate ( " You have %02d minercash. " ) : format ( modMinerTrade.getBalance ( accountname ) )
2022-05-12 11:32:28 -03:00
else
2022-06-03 00:57:09 -03:00
msgBalance = modMinerTrade.translate ( " Player '%s' is not an account holder of this bank. " ) : format ( accountname )
2017-03-13 18:26:38 -03:00
end
2022-05-13 23:24:20 -03:00
2022-06-03 00:57:09 -03:00
--local tblStatements = modMinerTrade.getStatement(accountname)
local totalTransactions = modMinerTrade.getTotalTransactions ( accountname )
2022-05-14 21:41:54 -03:00
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-06-03 00:57:09 -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 " , accountname : upper ( ) ) ) .. " ] "
2022-05-12 23:32:22 -03:00
2022-06-03 00:57:09 -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 [ accountname ] . 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-06-08 09:23:18 -03:00
frmStatement = function ( playername , selStatement ) --FORMULÁRIO: EXTRATO
2022-06-03 00:57:09 -03:00
local accountname = modMinerTrade.bank . player [ playername ] . focused_accountname
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-06-03 00:57:09 -03:00
local isAccount = modMinerTrade.isExistAcount ( accountname )
2022-05-13 12:40:50 -03:00
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)).."]"
2022-06-03 00:57:09 -03:00
local listStatement = modMinerTrade.getStatement ( accountname )
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-06-03 00:57:09 -03:00
local value = modMinerTrade.getBalance ( accountname )
2022-05-13 12:40:50 -03:00
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
2022-06-03 00:57:09 -03:00
msgStatement = modMinerTrade.translate ( " Player '%s' is not an account holder of this bank. " ) : format ( accountname )
2022-05-13 12:40:50 -03:00
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-06-08 09:23:18 -03:00
frmWithdrawals = function ( playername ) --FORMULÁRIO: FORMAS DE SAQUE
2022-06-03 00:57:09 -03:00
local accountname = modMinerTrade.bank . player [ playername ] . focused_accountname
2022-05-13 23:24:20 -03:00
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-06-08 09:23:18 -03:00
frmGiveCash = function ( playername , txtValue , msgDetails ) --FORMULÁRIO: SAQUE EM DINHEIRO
2022-06-03 00:57:09 -03:00
local accountname = modMinerTrade.bank . player [ playername ] . focused_accountname
2022-06-06 17:45:54 -03:00
--modMinerTrade.debug("modMinerTrade.showAccountBank.frmGiveCash() >>> playername = "..playername.." | txtValue = "..dump(txtValue).." | msgDetails = "..dump(msgDetails))
2022-05-13 23:24:20 -03:00
local msgBalance = " "
2022-06-03 00:57:09 -03:00
if modMinerTrade.isExistAcount ( accountname ) then
msgBalance = modMinerTrade.translate ( " You have %02d minercash. " ) : format ( modMinerTrade.getBalance ( accountname ) )
2022-05-13 23:24:20 -03:00
else
2022-06-03 00:57:09 -03:00
msgBalance = modMinerTrade.translate ( " Player '%s' is not an account holder of this bank. " ) : format ( accountname )
2022-05-13 23:24:20 -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;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 ) ) .. " ] "
2022-06-03 00:57:09 -03:00
if modMinerTrade.isExistAcount ( accountname ) then
2022-05-13 23:24:20 -03:00
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
minetest.show_formspec ( playername , " frmAtmGiveCash " , formspec )
end ,
2022-06-08 09:23:18 -03:00
frmDeposits = function ( playername ) --FORMULÁRIO: DEPÓSITOS
2022-06-03 00:57:09 -03:00
local accountname = modMinerTrade.bank . player [ playername ] . focused_accountname
2022-05-15 01:27:41 -03:00
-- playername = player:get_player_name()
2022-06-03 00:57:09 -03:00
local newInv = minetest.create_detached_inventory ( " deposits_ " .. accountname , {
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()))
2022-06-03 00:57:09 -03:00
--local accountname = player:get_player_name()
2022-05-15 01:27:41 -03:00
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
2022-06-03 00:57:09 -03:00
modMinerTrade.addBalance ( accountname , stackValue )
2022-05-15 01:27:41 -03:00
modMinerTrade.addStatement (
2022-06-03 00:57:09 -03:00
accountname , stackValue ,
2022-05-18 11:59:28 -03:00
modMinerTrade.translate ( " You deposited %02d x '%s'! " ) : format ( stack : get_count ( ) , stack : get_name ( ) )
2022-05-15 01:27:41 -03:00
)
--stack:take_item(stack:get_count())
stack : take_item ( )
modMinerTrade.doSoundPlayer ( playername , " sfx_cash_register " , 5 )
2022-06-03 00:57:09 -03:00
modMinerTrade.showAccountBank . frmDeposits ( playername )
2022-05-15 01:27:41 -03:00
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 = " "
2022-06-03 00:57:09 -03:00
if modMinerTrade.isExistAcount ( accountname ) then
msgBalance = modMinerTrade.translate ( " You have %02d minercash. " ) : format ( modMinerTrade.getBalance ( accountname ) )
2022-05-15 09:57:51 -03:00
2022-05-15 01:27:41 -03:00
else
2022-06-03 00:57:09 -03:00
msgBalance = modMinerTrade.translate ( " Player '%s' is not an account holder of this bank. " ) : format ( accountname )
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-06-03 00:57:09 -03:00
.. " list[detached: " .. minetest.formspec_escape ( " deposits_ " .. accountname ) .. " ;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-06-08 09:23:18 -03:00
frmTransfer = function ( playername ) --FORMULÁRIO: TRANSFERÊNCIAS
2022-06-03 00:57:09 -03:00
local accountname = modMinerTrade.bank . player [ playername ] . focused_accountname
2022-06-06 17:45:54 -03:00
--modMinerTrade.debug("modMinerTrade.showAccountBank.frmTransfer() >>> playername = "..dump(playername).." | accountname = "..dump(accountname).." | txtBeneficiary = "..dump(txtBeneficiary).." | txtValue = "..dump(txtValue).." | txtReason = "..dump(txtReason).." | msgDetails = "..dump(msgDetails))
2022-06-02 09:48:39 -03:00
local msgBalance = " "
2022-06-03 00:57:09 -03:00
if modMinerTrade.isExistAcount ( accountname ) then
msgBalance = modMinerTrade.translate ( " You have %02d minercash. " ) : format ( modMinerTrade.getBalance ( accountname ) )
2022-06-02 09:48:39 -03:00
else
2022-06-03 00:57:09 -03:00
msgBalance = modMinerTrade.translate ( " Player '%s' is not an account holder of this bank. " ) : format ( accountname )
2022-06-02 09:48:39 -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] "
2022-06-03 00:57:09 -03:00
.. " button[0.25,0.50;5.00,0.5;btnAtmMain; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " BACK " ) ) ) .. " ] "
2022-06-02 09:48:39 -03:00
.. " 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 ) ) .. " ] "
2022-06-03 00:57:09 -03:00
if modMinerTrade.isExistAcount ( accountname ) then
2022-06-02 09:48:39 -03:00
if txtBeneficiary == nil or type ( txtBeneficiary ) ~= " string " then
txtBeneficiary = " "
end
if txtValue == nil or txtValue == " " then
txtValue = " 1 "
end
2022-06-06 17:45:54 -03:00
if txtReason == nil or type ( txtReason ) ~= " string " or txtReason : trim ( ) == " " then
txtReason = modMinerTrade.translate ( " Transfer for undeclared reason! " )
2022-06-03 00:57:09 -03:00
end
2022-06-02 09:48:39 -03:00
if msgDetails == nil or msgDetails == " " then
msgDetails = modMinerTrade.translate ( " Write the 'beneficiary player name' and the 'value in minercash' that want to transfer! " )
end
formspec = formspec
--.. "label[5.25,0.50;"..minetest.formspec_escape(core.colorize("#00FFFF", "WITHDRAWAL IN MINERCASH:")).."]"
2022-06-06 17:45:54 -03:00
.. " field[7.00,3.50;6.00,0.50;txtBeneficiary; "
2022-06-02 09:48:39 -03:00
.. minetest.formspec_escape (
core.colorize (
" #00FFFF " ,
modMinerTrade.translate ( " BENEFICIARY NAME " ) .. " : "
)
) .. " ; "
2022-06-03 00:57:09 -03:00
.. minetest.formspec_escape ( txtBeneficiary )
2022-06-02 09:48:39 -03:00
.. " ] "
2022-06-03 00:57:09 -03:00
.. " field[7.00,5.00;3.00,0.50;txtValue; "
2022-06-02 09:48:39 -03:00
.. minetest.formspec_escape (
core.colorize (
" #00FFFF " ,
2022-06-03 00:57:09 -03:00
modMinerTrade.translate ( " VALUE " ) .. " : "
2022-06-02 09:48:39 -03:00
)
) .. " ; "
.. minetest.formspec_escape ( txtValue )
.. " ] "
2022-06-06 17:45:54 -03:00
.. " field[7.00,6.50;9.00,0.50;txtReason; "
2022-06-03 00:57:09 -03:00
.. minetest.formspec_escape (
core.colorize (
" #00FFFF " ,
2022-06-06 17:45:54 -03:00
modMinerTrade.translate ( " REASON OF TRANSFER " ) .. " : "
2022-06-03 00:57:09 -03:00
)
) .. " ; "
2022-06-06 17:45:54 -03:00
.. minetest.formspec_escape ( txtReason )
2022-06-03 00:57:09 -03:00
.. " ] "
2022-06-06 17:45:54 -03:00
.. " button[9.85,7.50;4.00,1.00;btnAtmTransfer; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " DO TRANSFER " ) ) ) .. " ] "
2022-06-02 09:48:39 -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
minetest.show_formspec ( playername , " frmAtmTransfer " , formspec )
end ,
2022-06-08 09:44:18 -03:00
frmLoanFunctions = function ( playername ) --FORMULÁRIO: FUNÇÕES DE EMPRESTIMO
2022-06-08 09:23:18 -03:00
local accountname = modMinerTrade.bank . player [ playername ] . focused_accountname
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] "
.. " label[6.75,0.75; " .. minetest.formspec_escape ( core.colorize ( " #00FFFF " , modMinerTrade.translate ( " LOAN FUNCTIONS " ) .. " : " ) ) .. " ] "
.. " label[9.25,3.25; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " NEW LOANS AVAILABLE " ) ) ) .. " ] "
.. " tooltip[btnMinercoin; " .. minetest.formspec_escape ( modMinerTrade.translate ( " List of all loan offers that you can take advantage of at low cost. " ) ) .. " ;#CCCC0088;#000000] "
.. " image_button[7.25,2.50;2.00,2.00;obj_moneysuitcase.png;btnLoansAvailable;] "
.. " label[9.25,5.75; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " LOANS WITH PENDING RETURNS " ) ) ) .. " ] "
.. " tooltip[btnMinercoin; " .. minetest.formspec_escape ( modMinerTrade.translate ( " List of all loans you have taken and that are still pending repayment. " ) ) .. " ;#CCCC0088;#000000] "
.. " image_button[7.25,5.00;2.00,2.00;obj_credit_card.png;btnLoansPendingReturns;] "
.. " label[9.25,8.25; " .. minetest.formspec_escape ( core.colorize ( " #FFFFFF " , modMinerTrade.translate ( " RULES FOR LOANS " ) ) ) .. " ] "
.. " tooltip[btnMinercoin; " .. minetest.formspec_escape ( modMinerTrade.translate ( " List of all rules for you to have access to a loan. " ) ) .. " ;#CCCC0088;#000000] "
.. " image_button[7.25,7.50;2.00,2.00;obj_bank_check.png;btnLoansRules;] "
modMinerTrade.doSoundPlayer ( playername , " sfx_atm " , 5 )
minetest.show_formspec ( playername , " frmAtmLoanFunctions " , 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-06-03 00:57:09 -03:00
modMinerTrade.showAccountBank . 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-06-03 00:57:09 -03:00
modMinerTrade.showAccountBank . frmBalance ( playername )
2022-05-13 12:40:50 -03:00
elseif fields.btnStatement ~= nil then
modMinerTrade.doSoundPlayer ( playername , " sfx_atm " , 5 )
2022-06-03 00:57:09 -03:00
modMinerTrade.showAccountBank . frmStatement ( playername )
2022-05-12 11:32:28 -03:00
elseif fields.btnWithdrawals ~= nil then
2022-06-03 00:57:09 -03:00
modMinerTrade.showAccountBank . frmWithdrawals ( playername )
2022-05-15 01:27:41 -03:00
elseif fields.btnDeposits ~= nil then
modMinerTrade.doSoundPlayer ( playername , " sfx_atm " , 5 )
2022-06-03 00:57:09 -03:00
modMinerTrade.showAccountBank . frmDeposits ( playername )
2022-06-02 09:48:39 -03:00
elseif fields.btnTransfers ~= nil then
2022-06-06 17:45:54 -03:00
modMinerTrade.doSoundPlayer ( playername , " sfx_atm " , 5 )
modMinerTrade.showAccountBank . frmTransfer ( playername )
2022-06-08 09:44:18 -03:00
elseif fields.btnLoans ~= nil then
modMinerTrade.doSoundPlayer ( playername , " sfx_atm " , 5 )
modMinerTrade.showAccountBank . frmLoanFunctions ( 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-06-03 00:57:09 -03:00
modMinerTrade.showAccountBank . frmStatement ( playername , fldStatement.row )
2022-05-13 12:40:50 -03:00
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 )
2022-06-03 00:57:09 -03:00
modMinerTrade.showAccountBank . frmGiveCash ( playername )
2022-05-13 23:24:20 -03:00
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 )
2022-06-03 00:57:09 -03:00
modMinerTrade.showAccountBank . frmWithdrawals ( playername )
2022-05-13 23:24:20 -03:00
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 ,
2022-05-18 11:59:28 -03:00
modMinerTrade.translate ( " You have withdrawn %02d minercash from your bank account. " ) : format ( delivered )
2022-05-13 23:24:20 -03:00
)
end
if delivered == tonumber ( myValue ) then
modMinerTrade.doSoundPlayer ( playername , " sfx_cash_register " , 5 )
2022-06-03 00:57:09 -03:00
modMinerTrade.showAccountBank . frmMain ( playername )
2022-05-13 23:24:20 -03:00
else
modMinerTrade.doSoundPlayer ( playername , " sfx_failure " , 5 )
2022-06-03 00:57:09 -03:00
modMinerTrade.showAccountBank . frmGiveCash ( playername ,
2022-05-13 23:24:20 -03:00
tonumber ( myValue ) - delivered ,
modMinerTrade.translate (
2022-05-18 11:59:28 -03:00
" You don't have space in your inventory to withdraw so much minercash. "
2022-05-13 23:24:20 -03:00
)
)
end
end
else
modMinerTrade.doSoundPlayer ( playername , " sfx_failure " , 5 )
2022-06-03 00:57:09 -03:00
modMinerTrade.showAccountBank . frmGiveCash ( playername ,
2022-05-13 23:24:20 -03:00
myValue ,
modMinerTrade.translate (
" The maximum amount you can withdraw is: %02d minercash. "
) : format ( myBalance )
)
end
else
modMinerTrade.doSoundPlayer ( playername , " sfx_failure " , 5 )
end
end
2022-06-06 17:45:54 -03:00
elseif formname == " frmAtmTransfer " then
if fields.btnAtmTransfer ~= nil then
--modMinerTrade.debug("modMinerTrade.onReceiveFields() >>> player = "..playername.." | formname = "..formname.." | fields = "..dump(fields))
2022-06-06 13:28:02 -03:00
local player = minetest.get_player_by_name ( playername )
if player ~= nil and player : is_player ( ) then
local accountname = modMinerTrade.bank . player [ playername ] . focused_accountname
2022-06-06 17:45:54 -03:00
local txtBeneficiary = " "
if fields.txtBeneficiary ~= nil
and type ( fields.txtBeneficiary ) == " string "
and fields.txtBeneficiary : trim ( ) ~= " "
then
txtBeneficiary = fields.txtBeneficiary : trim ( )
end
local txtValue = 0
if fields.txtValue ~= nil
and tonumber ( fields.txtValue ) ~= nil
and type ( tonumber ( fields.txtValue ) ) == " number "
and tonumber ( fields.txtValue ) >= 1
then
txtValue = tonumber ( fields.txtValue )
end
local txtReason = modMinerTrade.translate ( " Transfer for undeclared reason! " )
if fields.txtReason ~= nil
and type ( fields.txtReason ) == " string "
and fields.txtReason : trim ( ) ~= " "
then
--txtReason = string.format("%-150s",fields.txtReason:trim()):trim() --max 150 craracters
txtReason = fields.txtReason : trim ( ) : sub ( 1 , 150 ) --max 150 craracters
end
modMinerTrade.debug ( " modMinerTrade.onReceiveFields() >>> playername = " .. dump ( playername ) .. " | accountname = " .. dump ( accountname ) .. " | txtBeneficiary = " .. dump ( txtBeneficiary ) .. " | txtValue = " .. dump ( txtValue ) .. " | txtReason = " .. dump ( txtReason ) )
--modMinerTrade.debug("modMinerTrade.onReceiveFields() >>> accountname = "..dump(accountname))
2022-06-06 13:28:02 -03:00
if modMinerTrade.isExistAcount ( accountname ) then
2022-06-06 17:45:54 -03:00
if txtBeneficiary ~= " " and txtValue >= 1 then
2022-06-06 13:28:02 -03:00
if modMinerTrade.isExistAcount ( txtBeneficiary ) then
if accountname ~= txtBeneficiary then
local thisBalance = modMinerTrade.getBalance ( accountname )
if txtValue <= thisBalance then
modMinerTrade.addBalance ( txtBeneficiary , txtValue )
2022-06-08 02:48:08 -03:00
modMinerTrade.addStatement ( txtBeneficiary , txtValue ,
modMinerTrade.translate ( " The '%s' say: '%s' " ) : format ( playername , txtReason )
)
2022-06-06 13:28:02 -03:00
modMinerTrade.addBalance ( accountname , 0 - txtValue )
2022-06-08 02:48:08 -03:00
modMinerTrade.addStatement ( accountname , 0 - txtValue ,
modMinerTrade.translate ( " The '%s' say to '%s': '%s' " ) : format ( playername , txtBeneficiary , txtReason )
)
2022-06-06 13:28:02 -03:00
2023-08-09 20:41:29 -03:00
modMinerTrade.addTransferProof ( player , accountname , txtBeneficiary , txtValue , txtReason )
2022-06-06 13:28:02 -03:00
--modMinerTrade.doSoundPlayer(playername, "sfx_atm", 5)
2022-06-06 17:45:54 -03:00
--modMinerTrade.showAccountBank.frmTransfer(playername, txtBeneficiary, txtValue, txtReason, msgDetails) --FORMULÁRIO: SAQUE
2022-06-06 13:28:02 -03:00
modMinerTrade.doSoundPlayer ( playername , " sfx_cash_register " , 5 )
modMinerTrade.showAccountBank . frmMain ( playername )
else
modMinerTrade.doSoundPlayer ( playername , " sfx_failure " , 5 )
modMinerTrade.showAccountBank . frmTransfer (
2022-06-06 17:45:54 -03:00
playername , txtBeneficiary , txtValue , txtReason ,
2022-06-06 13:28:02 -03:00
modMinerTrade.translate ( " The bank account holder '%s' does not have enough balance to make this requested transfer. " ) : format ( accountname )
)
end
else
modMinerTrade.doSoundPlayer ( playername , " sfx_failure " , 5 )
modMinerTrade.showAccountBank . frmTransfer (
2022-06-06 17:45:54 -03:00
playername , txtBeneficiary , txtValue , txtReason ,
2022-06-06 13:28:02 -03:00
modMinerTrade.translate ( " Account holder '%s' cannot be a beneficiary of itself. " ) : format ( accountname )
)
end
else
modMinerTrade.doSoundPlayer ( playername , " sfx_failure " , 5 )
modMinerTrade.showAccountBank . frmTransfer (
2022-06-06 17:45:54 -03:00
playername , txtBeneficiary , txtValue , txtReason ,
2022-06-06 13:28:02 -03:00
modMinerTrade.translate ( " The beneficiary '%s' does not have a current account with this bank. " ) : format ( txtBeneficiary )
)
end
else
modMinerTrade.doSoundPlayer ( playername , " sfx_failure " , 5 )
modMinerTrade.showAccountBank . frmTransfer ( playername )
end
else
--modMinerTrade.doSoundPlayer(playername, "sfx_failure", 5)
--modMinerTrade.showAccountBank.frmTransfer(playername)
modMinerTrade.doSoundPlayer ( playername , " sfx_failure " , 5 )
modMinerTrade.showAccountBank . frmTransfer (
playername , nil , nil , nil ,
modMinerTrade.translate ( " There is no account holder '%s' in this bank. " ) : format ( accountname )
)
end
end --Final of: if player ~= nil and player:is_player() then
2022-06-02 09:48:39 -03:00
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 " , {
2022-05-18 11:59:28 -03:00
description = core.colorize ( " #00FF00 " ,
modMinerTrade.translate ( " PUBLIC ATM " )
) .. " \n \t * " .. modMinerTrade.translate ( " Deposit and Withdraw your minercash into your bank account. " ) ,
2022-05-12 17:03:46 -03:00
--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
2022-06-03 00:57:09 -03:00
modMinerTrade.canInteract ( playername )
2022-06-02 09:48:39 -03:00
or modMinerTrade.getNodesInRange ( posAbove , 5 , " minertrade:dispensingmachine " ) >= 1
2022-05-12 17:03:46 -03:00
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 )
2022-05-18 11:59:28 -03:00
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. "
)
--]]
core.colorize ( " #00FF00 " ,
modMinerTrade.translate ( " PUBLIC ATM " )
) .. " \n \t * " .. modMinerTrade.translate ( " Deposit and Withdraw your minercash into your bank account. " )
)
2022-05-12 17:03:46 -03:00
local now = os.time ( ) --Em milisegundos
2022-06-02 09:48:39 -03:00
if not modMinerTrade.canInteract ( playername ) then
meta : set_string ( " opentime " , now + modMinerTrade.getDelayToUse ( ) )
2022-05-12 17:03:46 -03:00
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
2022-06-02 09:48:39 -03:00
if now >= opentime or modMinerTrade.canInteract ( clickername ) then
2022-05-12 17:03:46 -03:00
--[[
modMinerTrade.showInventory (
clicker ,
clickername ,
modMinerTrade.translate ( " PUBLIC ATM - Account of '%s': " ) : format ( clickername )
)
--]]
2022-06-03 00:57:09 -03:00
--modMinerTrade.doSoundPlayer(clickername, "sfx_atm", 5)
--modMinerTrade.showAccountBank.frmMain(clickername)
modMinerTrade.showAccountBank . inAtm ( clickername , clickername )
2022-05-12 17:03:46 -03:00
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! "
2022-06-02 09:48:39 -03:00
) : format ( opentime - now )
2022-05-12 17:03:46 -03:00
)
end
2022-05-12 23:32:22 -03:00
--modMinerTrade.debug("on_rightclick() >>> "..modMinerTrade.getUrlDatabase())
2022-05-12 17:03:46 -03:00
end ,
} )
2022-05-18 11:59:28 -03:00
--[[ --]]
2022-05-12 17:03:46 -03:00
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 ( )
end )