mirror of
https://gitlab.com/lunovox/minertrade.git
synced 2025-03-15 05:31:20 +00:00
Correção de Bugs. Metroria de ATM.
This commit is contained in:
parent
a086a2da7f
commit
971b6a12c9
5 changed files with 155 additions and 54 deletions
|
@ -30,11 +30,13 @@ It adds various types of money, exchange table, Dispensing Machines, Strongbox i
|
||||||
|
|
||||||
**Developers:**
|
**Developers:**
|
||||||
* [Lunovox](https://libreplanet.org/wiki/User:Lunovox)
|
* [Lunovox](https://libreplanet.org/wiki/User:Lunovox)
|
||||||
|
|
||||||
|
<!--
|
||||||
**Comandos:**
|
**Comandos:**
|
||||||
* Lets you check the contents of another players strongbox.
|
* Lets you check the contents of another players strongbox.
|
||||||
* /checkstrongbox <player_name>
|
* /checkstrongbox <player_name>
|
||||||
* /csb <player_name>
|
* /csb <player_name>
|
||||||
|
-->
|
||||||
|
|
||||||
**Settings:**
|
**Settings:**
|
||||||
|
|
||||||
|
@ -46,7 +48,7 @@ You don't need to do any of these presets mentioned below to make this mod work.
|
||||||
* ````minertrade.save_compressed = <boolean>```` : If enabled will save database bank in file '.db64', else in file '.tbl'. Default: ````true````
|
* ````minertrade.save_compressed = <boolean>```` : If enabled will save database bank in file '.db64', else in file '.tbl'. Default: ````true````
|
||||||
* ````minertrade.bank.max_statements = <number>```` : Specifies the amount statement records to each player in databade bank. Default: ````30````; Min: ````1````, Max: ````300````.
|
* ````minertrade.bank.max_statements = <number>```` : Specifies the amount statement records to each player in databade bank. Default: ````30````; Min: ````1````, Max: ````300````.
|
||||||
* ````minertrade.salary.enabled = <boolean>```` : Allows for daily distribution of Salary. Default: ````true````
|
* ````minertrade.salary.enabled = <boolean>```` : Allows for daily distribution of Salary. Default: ````true````
|
||||||
* ````minertrade.salary.value = <number>```` : Specifies the amount of salary paid daily. Default: ````9````
|
* ````minertrade.salary.value = <number>```` : Specifies the amount of salary paid daily. Default: ````1````
|
||||||
* ````minertrade.salary.intervalcheck = <number>```` : Specifies how many seconds the salary will be checked who still has to receive. Values below 5 can cause server lag. Default: ````60````
|
* ````minertrade.salary.intervalcheck = <number>```` : Specifies how many seconds the salary will be checked who still has to receive. Values below 5 can cause server lag. Default: ````60````
|
||||||
|
|
||||||
|
|
||||||
|
|
15
config.lua
15
config.lua
|
@ -2,7 +2,20 @@ modMinerTrade = {
|
||||||
modName = minetest.get_current_modname(),
|
modName = minetest.get_current_modname(),
|
||||||
modPath = minetest.get_modpath(minetest.get_current_modname()),
|
modPath = minetest.get_modpath(minetest.get_current_modname()),
|
||||||
save_compressed = (minetest.settings:get("minertrade.save_compressed") ~= "false"),
|
save_compressed = (minetest.settings:get("minertrade.save_compressed") ~= "false"),
|
||||||
delayConstruct = 300,
|
--delayConstruct = 300,
|
||||||
|
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,
|
||||||
bank = {
|
bank = {
|
||||||
accounts = 0,
|
accounts = 0,
|
||||||
last_pay = 0,
|
last_pay = 0,
|
||||||
|
|
122
item_atm.lua
122
item_atm.lua
|
@ -49,6 +49,13 @@ modMinerTrade.doBankLoad = function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
modMinerTrade.canInteract = function(playername)
|
||||||
|
--local clickername = clicker:get_player_name()
|
||||||
|
if minetest.get_player_privs(clickername).mayor then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
modMinerTrade.isExistAcount = function(playername)
|
modMinerTrade.isExistAcount = function(playername)
|
||||||
if modMinerTrade.bank.player[playername] ~= nil then
|
if modMinerTrade.bank.player[playername] ~= nil then
|
||||||
return true
|
return true
|
||||||
|
@ -370,7 +377,6 @@ modMinerTrade.showAtm = {
|
||||||
local msgBalance = ""
|
local msgBalance = ""
|
||||||
if modMinerTrade.isExistAcount(playername) then
|
if modMinerTrade.isExistAcount(playername) then
|
||||||
msgBalance = modMinerTrade.translate("You have %02d minercash."):format(modMinerTrade.getBalance(playername))
|
msgBalance = modMinerTrade.translate("You have %02d minercash."):format(modMinerTrade.getBalance(playername))
|
||||||
|
|
||||||
else
|
else
|
||||||
msgBalance = modMinerTrade.translate("Player '%s' is not an account holder of this bank."):format(playername)
|
msgBalance = modMinerTrade.translate("Player '%s' is not an account holder of this bank."):format(playername)
|
||||||
end
|
end
|
||||||
|
@ -414,22 +420,6 @@ modMinerTrade.showAtm = {
|
||||||
..minetest.formspec_escape(core.colorize("#00FFFF", msgDetails))
|
..minetest.formspec_escape(core.colorize("#00FFFF", msgDetails))
|
||||||
.."]"
|
.."]"
|
||||||
end
|
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)
|
minetest.show_formspec(playername, "frmAtmGiveCash", formspec)
|
||||||
end,
|
end,
|
||||||
frmDeposits = function(playername) --FORMULÁRIO: SAQUE
|
frmDeposits = function(playername) --FORMULÁRIO: SAQUE
|
||||||
|
@ -544,6 +534,69 @@ modMinerTrade.showAtm = {
|
||||||
|
|
||||||
minetest.show_formspec(playername, "frmAtmDeposits", formspec)
|
minetest.show_formspec(playername, "frmAtmDeposits", formspec)
|
||||||
end,
|
end,
|
||||||
|
frmTransfer = function(playername, txtBeneficiary, 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 txtBeneficiary == nil or type(txtBeneficiary) ~= "string" then
|
||||||
|
txtBeneficiary = ""
|
||||||
|
end
|
||||||
|
if txtValue == nil or txtValue == "" then
|
||||||
|
txtValue = "1"
|
||||||
|
end
|
||||||
|
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:")).."]"
|
||||||
|
.."field[7.00,3.50;3.00,0.50;txtBeneficiarytxtBeneficiary;"
|
||||||
|
..minetest.formspec_escape(
|
||||||
|
core.colorize(
|
||||||
|
"#00FFFF",
|
||||||
|
modMinerTrade.translate("BENEFICIARY NAME")..":"
|
||||||
|
)
|
||||||
|
)..";"
|
||||||
|
..minetest.formspec_escape(txtValue)
|
||||||
|
.."]"
|
||||||
|
.."field[7.00,4.50;3.00,0.50;txtValue;"
|
||||||
|
..minetest.formspec_escape(
|
||||||
|
core.colorize(
|
||||||
|
"#00FFFF",
|
||||||
|
modMinerTrade.translate("VALUE IN MINERCASH")..":"
|
||||||
|
)
|
||||||
|
)..";"
|
||||||
|
..minetest.formspec_escape(txtValue)
|
||||||
|
.."]"
|
||||||
|
.. "button[9.85,3.00;4.00,1.00;btnAtmTransfer;"..minetest.formspec_escape(core.colorize("#FFFFFF", modMinerTrade.translate("TRANSFER"))).."]"
|
||||||
|
|
||||||
|
.."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,
|
||||||
}
|
}
|
||||||
|
|
||||||
modMinerTrade.getCashTypes = function()
|
modMinerTrade.getCashTypes = function()
|
||||||
|
@ -616,6 +669,11 @@ modMinerTrade.onReceiveFields = function(player, formname, fields)
|
||||||
elseif fields.btnDeposits ~= nil then
|
elseif fields.btnDeposits ~= nil then
|
||||||
modMinerTrade.doSoundPlayer(playername, "sfx_atm", 5)
|
modMinerTrade.doSoundPlayer(playername, "sfx_atm", 5)
|
||||||
modMinerTrade.showAtm.frmDeposits(playername)
|
modMinerTrade.showAtm.frmDeposits(playername)
|
||||||
|
elseif fields.btnTransfers ~= nil then
|
||||||
|
if modMinerTrade.canInteract(playername) then --Em fase de teste é acessivel somente para developers.
|
||||||
|
modMinerTrade.doSoundPlayer(playername, "sfx_atm", 5)
|
||||||
|
modMinerTrade.showAtm.frmTransfer(playername)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif formname == "frmAtmStatement" then
|
elseif formname == "frmAtmStatement" then
|
||||||
--modMinerTrade.debug("modMinerTrade.onReceiveFields() >>> player = "..playername.." | formname = "..formname.." | fields = "..dump(fields))
|
--modMinerTrade.debug("modMinerTrade.onReceiveFields() >>> player = "..playername.." | formname = "..formname.." | fields = "..dump(fields))
|
||||||
|
@ -703,6 +761,23 @@ modMinerTrade.onReceiveFields = function(player, formname, fields)
|
||||||
modMinerTrade.doSoundPlayer(playername, "sfx_failure", 5)
|
modMinerTrade.doSoundPlayer(playername, "sfx_failure", 5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
elseif formname == "frmTransfer" then
|
||||||
|
if fields.btnWithdrawals ~= nil then
|
||||||
|
modMinerTrade.doSoundPlayer(playername, "sfx_atm", 5)
|
||||||
|
modMinerTrade.showAtm.frmTransfer(playername)
|
||||||
|
elseif fields.btnAtmGive ~= nil
|
||||||
|
and fields.txtBeneficiary ~= nil
|
||||||
|
and type(fields.txtBeneficiarytxtBeneficiary) == "string"
|
||||||
|
and fields.txtBeneficiary ~= ""
|
||||||
|
and fields.txtBeneficiary ~= playername
|
||||||
|
|
||||||
|
and fields.txtValue ~= nil
|
||||||
|
and tonumber(fields.txtValue) ~= nil
|
||||||
|
and type(tonumber(fields.txtValue))=="number"
|
||||||
|
and tonumber(fields.txtValue) >= 1
|
||||||
|
then
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -774,8 +849,8 @@ minetest.register_node("minertrade:atm", {
|
||||||
end
|
end
|
||||||
|
|
||||||
if
|
if
|
||||||
minetest.get_player_privs(playername).server
|
or modMinerTrade.canInteract(playername) --minetest.get_player_privs(playername).mayor
|
||||||
or modMinerTrade.getNodesInRange(posAbove, 2, "minertrade:dispensingmachine")>=1
|
or modMinerTrade.getNodesInRange(posAbove, 5, "minertrade:dispensingmachine") >= 1
|
||||||
then
|
then
|
||||||
local facedir = minetest.dir_to_facedir(placer:get_look_dir())
|
local facedir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||||
--minetest.chat_send_player(playername, "[ATM] aaaaaa")
|
--minetest.chat_send_player(playername, "[ATM] aaaaaa")
|
||||||
|
@ -795,8 +870,8 @@ minetest.register_node("minertrade:atm", {
|
||||||
).."\n\t* "..modMinerTrade.translate("Deposit and Withdraw your minercash into your bank account.")
|
).."\n\t* "..modMinerTrade.translate("Deposit and Withdraw your minercash into your bank account.")
|
||||||
)
|
)
|
||||||
local now = os.time() --Em milisegundos
|
local now = os.time() --Em milisegundos
|
||||||
if not minetest.get_player_privs(playername).server then
|
if not modMinerTrade.canInteract(playername) then
|
||||||
meta:set_string("opentime", now+modMinerTrade.delayConstruct)
|
meta:set_string("opentime", now + modMinerTrade.getDelayToUse())
|
||||||
else
|
else
|
||||||
meta:set_string("opentime", now)
|
meta:set_string("opentime", now)
|
||||||
end
|
end
|
||||||
|
@ -818,7 +893,7 @@ minetest.register_node("minertrade:atm", {
|
||||||
--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."))
|
--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 opentime = tonumber(meta:get_string("opentime")) or 0
|
||||||
local now = os.time() --Em milisegundos
|
local now = os.time() --Em milisegundos
|
||||||
if now >= opentime or minetest.get_player_privs(clickername).server then
|
if now >= opentime or modMinerTrade.canInteract(clickername) then
|
||||||
--[[
|
--[[
|
||||||
modMinerTrade.showInventory(
|
modMinerTrade.showInventory(
|
||||||
clicker,
|
clicker,
|
||||||
|
@ -835,7 +910,7 @@ minetest.register_node("minertrade:atm", {
|
||||||
core.colorize("#00ff00", "["..modMinerTrade.translate("ATM").."]: ")
|
core.colorize("#00ff00", "["..modMinerTrade.translate("ATM").."]: ")
|
||||||
..modMinerTrade.translate(
|
..modMinerTrade.translate(
|
||||||
"The ATM will only run %02d seconds after it is installed!"
|
"The ATM will only run %02d seconds after it is installed!"
|
||||||
):format(opentime-now)
|
):format(opentime - now)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
--modMinerTrade.debug("on_rightclick() >>> "..modMinerTrade.getUrlDatabase())
|
--modMinerTrade.debug("on_rightclick() >>> "..modMinerTrade.getUrlDatabase())
|
||||||
|
@ -872,5 +947,4 @@ end)
|
||||||
|
|
||||||
minetest.register_on_shutdown(function()
|
minetest.register_on_shutdown(function()
|
||||||
modMinerTrade.doBankSave()
|
modMinerTrade.doBankSave()
|
||||||
minetest.log('action',"[STRONGBOX] "..modMinerTrade.translate("Saving bank from all players in the file '%s'!"):format(modMinerTrade.getUrlDatabase()))
|
|
||||||
end)
|
end)
|
||||||
|
|
8
minetest.conf
Normal file
8
minetest.conf
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# MINERTRADE SETTINGS
|
||||||
|
|
||||||
|
minertrade.debug = false
|
||||||
|
minertrade.save_compressed = true
|
||||||
|
minertrade.bank.max_statements = 30
|
||||||
|
minertrade.salary.enabled = true
|
||||||
|
minertrade.salary.value = 1
|
||||||
|
minertrade.salary.intervalcheck = 60
|
|
@ -1,34 +1,38 @@
|
||||||
# MINERTRADE SETTINGS
|
# MINERTRADE SETTINGS
|
||||||
# Only players with "salary" privilege received a daily payment.
|
# Only players with "salary" privilege received a daily payment.
|
||||||
|
|
||||||
# MINERTRADE:
|
|
||||||
# Whether the database will be BASE64 compressed.
|
|
||||||
# Default: true
|
|
||||||
minertrade.save_compressed (Database Compressed) bool true
|
|
||||||
|
|
||||||
# MINERTRADE:
|
|
||||||
# If server will reward the player daily..
|
|
||||||
# Default: true
|
|
||||||
minertrade.salary.enabled (Daily Salary Enabled) bool true
|
|
||||||
|
|
||||||
# MINERTRADE:
|
|
||||||
# Value of the prize minercash that each player will receive at the end of the virtual day.
|
|
||||||
# Default: 1 | Min: 1
|
|
||||||
minertrade.salary.value (Daily Salary Value) int 1 1
|
|
||||||
# MINERTRADE:
|
|
||||||
|
|
||||||
# Time interval in seconds to check for rewardable players.
|
|
||||||
# WARNING: Decreasing this value too much can cause server lag.
|
|
||||||
# Default: 60 | Min: 1
|
|
||||||
minertrade.salay.intervalcheck (Interval Check Salary) int 60 1
|
|
||||||
|
|
||||||
# MINERTRADE:
|
|
||||||
|
|
||||||
# Maximum record number of bank statements.
|
|
||||||
# Default: 30 | Min: 1 | Max: 300
|
|
||||||
minertrade.bank.max_statements (Maximum Record Statements) int 30 1 300
|
|
||||||
|
|
||||||
# MINERTRADE:
|
# MINERTRADE:
|
||||||
# Allows you to print the debug information of this mod on the screen.
|
# Allows you to print the debug information of this mod on the screen.
|
||||||
# Default: false
|
# Default: false
|
||||||
minertrade.debug (Show Minertrade Debug) bool false
|
minertrade.debug (Show Minertrade Debug) bool false
|
||||||
|
|
||||||
|
# MINERTRADE:
|
||||||
|
# Whether the database will be BASE64 compressed.
|
||||||
|
# If enabled will save database bank in file '.db64',
|
||||||
|
# else in file '.tbl' without compression.
|
||||||
|
# Default: true
|
||||||
|
minertrade.save_compressed (Database Compressed) bool true
|
||||||
|
|
||||||
|
# MINERTRADE:
|
||||||
|
# Maximum record number of bank statements.
|
||||||
|
# Default: 30 | Min: 1 | Max: 300
|
||||||
|
minertrade.bank.max_statements (Maximum Record Statements) int 30 1 300
|
||||||
|
|
||||||
|
# MINERTRADE:
|
||||||
|
# If server will reward the player daily..
|
||||||
|
# Default: false
|
||||||
|
minertrade.salary.enabled (Daily Salary Enabled) bool true
|
||||||
|
|
||||||
|
# MINERTRADE:
|
||||||
|
# Value of the prize minercash that each player will
|
||||||
|
# receive at the end of the virtual day.
|
||||||
|
# Default: 1 | Min: 1
|
||||||
|
minertrade.salary.value (Daily Salary Value) int 1 1
|
||||||
|
|
||||||
|
# MINERTRADE:
|
||||||
|
# Time interval in seconds to check for rewardable players.
|
||||||
|
# WARNING: Decreasing this value too much can cause server lag.
|
||||||
|
# Default: 60 | Min: 1 | Max: 86400
|
||||||
|
minertrade.salary.intervalcheck (Interval Check Salary) int 60 1 86400
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue