Bugfixes
This commit is contained in:
parent
6c817fc7fe
commit
675dbd1a9c
9
bank.lua
9
bank.lua
|
@ -245,9 +245,12 @@ elseif rawget(_G, 'money') then
|
||||||
mod = 'money2',
|
mod = 'money2',
|
||||||
user_exists = money.has_credit,
|
user_exists = money.has_credit,
|
||||||
getbal = money.get,
|
getbal = money.get,
|
||||||
setbal = function(...)
|
setbal = function(name, ...)
|
||||||
money.set(...)
|
if money.has_credit(name) then
|
||||||
return true
|
money.set(name, ...)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
end,
|
end,
|
||||||
pay = function(from, to, amount)
|
pay = function(from, to, amount)
|
||||||
local err = money.transfer(from, to, amount)
|
local err = money.transfer(from, to, amount)
|
||||||
|
|
13
minibank.lua
13
minibank.lua
|
@ -8,12 +8,21 @@ local storage = minetest.get_mod_storage()
|
||||||
|
|
||||||
-- Use mod storage for getbal() and setbal().
|
-- Use mod storage for getbal() and setbal().
|
||||||
-- Store as strings because of weird bugs when using floats.
|
-- Store as strings because of weird bugs when using floats.
|
||||||
local function getbal(name)
|
local function rawgetbal(name)
|
||||||
return tonumber(storage:get_string('minibank-' .. name))
|
return tonumber(storage:get_string('minibank-' .. name))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function getbal(name)
|
||||||
|
local lname = name:lower()
|
||||||
|
if lname ~= name and rawgetbal(name) ~= nil then
|
||||||
|
setbal(lname, rawgetbal(name))
|
||||||
|
storage:set_string(name, '')
|
||||||
|
end
|
||||||
|
return rawgetbal(lname)
|
||||||
|
end
|
||||||
|
|
||||||
local function setbal(name, balance)
|
local function setbal(name, balance)
|
||||||
storage:set_string('minibank-' .. name, tostring(balance))
|
storage:set_string('minibank-' .. name:lower(), tostring(balance))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create an empty account for new players
|
-- Create an empty account for new players
|
||||||
|
|
Loading…
Reference in New Issue