2014-01-08 17:02:04 +01:00
|
|
|
--Created by Krock for the BitChange mod
|
2014-10-01 13:41:22 +02:00
|
|
|
bitchange = {}
|
|
|
|
bitchange.mod_path = minetest.get_modpath("bitchange")
|
2014-02-07 13:35:02 +01:00
|
|
|
local world_path = minetest.get_worldpath()
|
2014-01-08 17:02:04 +01:00
|
|
|
|
2015-04-16 15:06:02 +02:00
|
|
|
if rawget(_G, "freeminer") then
|
2014-02-06 20:42:01 +01:00
|
|
|
minetest = freeminer
|
|
|
|
end
|
|
|
|
|
2014-10-01 13:41:22 +02:00
|
|
|
dofile(bitchange.mod_path.."/config.default.txt")
|
2014-02-07 13:35:02 +01:00
|
|
|
-- Copied from moretrees mod
|
2014-10-01 13:41:22 +02:00
|
|
|
if not io.open(world_path.."/bitchange_config.txt", "r") then
|
|
|
|
io.input(bitchange.mod_path.."/config.default.txt")
|
2014-02-07 13:35:02 +01:00
|
|
|
io.output(world_path.."/bitchange_config.txt")
|
|
|
|
|
|
|
|
while true do
|
|
|
|
local block = io.read(256) -- 256B at once
|
|
|
|
if not block then
|
|
|
|
io.close()
|
|
|
|
break
|
|
|
|
end
|
|
|
|
io.write(block)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
dofile(world_path.."/bitchange_config.txt")
|
|
|
|
end
|
|
|
|
|
2014-10-01 13:41:22 +02:00
|
|
|
dofile(bitchange.mod_path.."/minecoins.lua")
|
|
|
|
dofile(bitchange.mod_path.."/moreores.lua")
|
2015-04-16 15:06:02 +02:00
|
|
|
if bitchange.enable_exchangeshop then
|
2014-10-01 13:41:22 +02:00
|
|
|
dofile(bitchange.mod_path.."/shop.lua")
|
2014-01-08 17:02:04 +01:00
|
|
|
end
|
2015-04-16 15:06:02 +02:00
|
|
|
if bitchange.enable_moneychanger then
|
2014-10-01 13:41:22 +02:00
|
|
|
dofile(bitchange.mod_path.."/moneychanger.lua")
|
2014-01-08 17:02:04 +01:00
|
|
|
end
|
2015-04-16 15:06:02 +02:00
|
|
|
if bitchange.enable_warehouse then
|
2014-10-01 13:41:22 +02:00
|
|
|
dofile(bitchange.mod_path.."/warehouse.lua")
|
2014-01-08 17:02:04 +01:00
|
|
|
end
|
2015-04-16 15:06:02 +02:00
|
|
|
if bitchange.enable_toolrepair then
|
2014-10-01 13:41:22 +02:00
|
|
|
dofile(bitchange.mod_path.."/toolrepair.lua")
|
2014-01-08 17:02:04 +01:00
|
|
|
end
|
2015-04-16 15:06:02 +02:00
|
|
|
if bitchange.enable_donationbox then
|
2014-10-01 13:41:22 +02:00
|
|
|
dofile(bitchange.mod_path.."/donationbox.lua")
|
2014-01-18 11:40:06 +01:00
|
|
|
end
|
2015-04-16 15:06:02 +02:00
|
|
|
if bitchange.enable_bank then
|
2014-10-01 13:41:22 +02:00
|
|
|
local loaded_bank = false
|
|
|
|
for i, v in ipairs({"money", "money2", "currency"}) do
|
|
|
|
if minetest.get_modpath(v) then
|
|
|
|
loaded_bank = v
|
|
|
|
break
|
|
|
|
end
|
2014-01-17 15:24:46 +01:00
|
|
|
end
|
2014-10-01 13:41:22 +02:00
|
|
|
if loaded_bank then
|
|
|
|
dofile(bitchange.mod_path.."/bank.lua")
|
|
|
|
bitchange.bank.file_path = world_path.."/bitchange_bank_"..loaded_bank
|
|
|
|
dofile(bitchange.mod_path.."/bank_"..loaded_bank..".lua")
|
2014-01-17 15:24:46 +01:00
|
|
|
print("[BitChange] Bank loaded: "..loaded_bank)
|
2014-01-08 17:02:04 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-05-16 10:00:46 +02:00
|
|
|
if not minetest.setting_getbool("creative_mode") and bitchange.initial_give > 0 then
|
2014-01-08 17:02:04 +01:00
|
|
|
-- Giving initial money
|
|
|
|
minetest.register_on_newplayer(function(player)
|
2015-04-16 15:06:02 +02:00
|
|
|
player:get_inventory():add_item("main", "bitchange:mineninth "..bitchange.initial_give)
|
2014-01-08 17:02:04 +01:00
|
|
|
end)
|
|
|
|
end
|
2014-01-18 11:40:06 +01:00
|
|
|
|
|
|
|
-- Privs
|
|
|
|
minetest.register_privilege("bitchange", "Can access to owned nodes of the bitchange mod")
|
2015-04-16 15:06:02 +02:00
|
|
|
function bitchange.has_access(owner, player_name)
|
2016-10-16 09:09:11 +02:00
|
|
|
if player_name == owner or owner == "" then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
local privs = minetest.get_player_privs(player_name)
|
|
|
|
return privs.server or privs.bitchange
|
2014-01-18 11:40:06 +01:00
|
|
|
end
|
|
|
|
|
2014-02-07 13:35:02 +01:00
|
|
|
print("[BitChange] Loaded.")
|