money3/init.lua

71 lines
2.0 KiB
Lua
Raw Normal View History

2014-02-15 05:46:44 +01:00
--
2019-05-23 06:47:11 +02:00
-- money3
2014-02-15 05:46:44 +01:00
--
2019-05-23 06:47:11 +02:00
-- Copyright © 2012 Bad_Command
-- Copyright © 2012 kotolegokot
-- Copyright © 2019 by luk3yx
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2014-02-15 05:46:44 +01:00
--
2019-05-23 06:47:11 +02:00
money3 = {}
money3.version = 2.5
2014-02-15 05:46:44 +01:00
2019-05-23 06:47:11 +02:00
local modpath = assert(minetest.get_modpath("money3",
"Please call this mod money3."))
dofile(modpath .. "/config.lua")
2014-02-15 05:46:44 +01:00
2019-05-23 06:47:11 +02:00
assert(not minetest.get_modpath("money2"), "money3 and money2 do not mix.")
2014-02-15 05:46:44 +01:00
2019-05-23 06:47:11 +02:00
local storage = minetest.get_mod_storage()
loadfile(modpath .. "/core.lua")(storage)
2014-02-15 05:46:44 +01:00
2019-05-23 06:47:11 +02:00
-- Only load convertval.lua if required.
if next(money3.convert_items) then
loadfile(modpath .. "/convertval.lua")(storage)
2014-02-15 05:46:44 +01:00
end
2019-05-23 06:47:11 +02:00
-- Load income
if money3.enable_income then
dofile(modpath .. "/income.lua")
2014-02-15 05:46:44 +01:00
end
2019-05-23 06:47:11 +02:00
-- Make sure the lurkcoin mod knows that money3 exists
if minetest.get_modpath("lurkcoin") then
lurkcoin.change_bank({
user_exists = money3.user_exists,
getbal = money3.get,
setbal = function(name, ...)
if money3.user_exists(name) then
money3.set(name, ...)
2014-02-15 05:46:44 +01:00
return true
end
2019-05-23 06:47:11 +02:00
return false
end,
pay = function(from, to, amount)
local err = money.transfer(from, to, amount)
return not err, err
2014-02-15 05:46:44 +01:00
end
2019-05-23 06:47:11 +02:00
})
2014-02-15 05:46:44 +01:00
end
2019-05-23 06:47:11 +02:00
-- Backwards compatibility
rawset(_G, "money", money3)
2014-02-15 05:46:44 +01:00
2019-05-23 06:47:11 +02:00
-- I couldn't be bothered to update lockedsign.lua
if minetest.get_modpath("locked_sign") then
dofile(modpath .. "/lockedsign.lua")
2014-02-15 05:46:44 +01:00
end