diff --git a/bank.lua b/bank.lua index 4ebd5da..fa44e7a 100644 --- a/bank.lua +++ b/bank.lua @@ -87,21 +87,21 @@ minetest.register_node("bitchange:bank", { end, allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) local meta = minetest.get_meta(pos) - if bitchange_has_access(meta:get_string("owner"), player:get_player_name()) then + if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then return count end return 0 end, allow_metadata_inventory_put = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) - if bitchange_has_access(meta:get_string("owner"), player:get_player_name()) then + if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then return stack:get_count() end return 0 end, allow_metadata_inventory_take = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) - if bitchange_has_access(meta:get_string("owner"), player:get_player_name()) then + if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then return stack:get_count() end return 0 diff --git a/config.default.txt b/config.default.txt index 0e4c79a..b0c6538 100644 --- a/config.default.txt +++ b/config.default.txt @@ -1,30 +1,31 @@ -- General configuration - BitChange -- Created by Krock -bitchange_initial_give = 2 +bitchange.initial_give = 2 -- Enable/Disable whole nodes -bitchange_enable_exchangeshop = true -bitchange_enable_moneychanger = true -bitchange_enable_warehouse = false -bitchange_enable_toolrepair = true -bitchange_enable_donationbox = true +bitchange.enable_exchangeshop = true +bitchange.enable_moneychanger = true +bitchange.enable_warehouse = false +bitchange.enable_toolrepair = true +bitchange.enable_donationbox = true -- Set this variable to false if you have a supported currency enabled -- and if you want to disable the exchanging/converting point - the bank -- Supported: money (by kotolegokot), money2 (by Bad Command), currency (by Dan Duncombe) -bitchange_enable_bank = false +bitchange.enable_bank = false -- Converting other ores to MineCoins -- Tin moreores -- Zinc technic_worldgen -- Quartz quartz -bitchange_use_moreores_tin = false -bitchange_use_technic_zinc = false -bitchange_use_quartz = false +bitchange.use_moreores_tin = false +bitchange.use_technic_zinc = false +bitchange.use_quartz = false -- Pipeworks support -bitchange_exchangeshop_pipeworks = false -bitchange_warehouse_pipeworks = false +bitchange.exchangeshop_pipeworks = false +bitchange.warehouse_pipeworks = false -- Advanced generation settings -- Change in 'minecoins.lua', starting at line 101 +bitchange.enable_generation = true \ No newline at end of file diff --git a/donationbox.lua b/donationbox.lua index 7ce24c8..9140690 100644 --- a/donationbox.lua +++ b/donationbox.lua @@ -48,7 +48,7 @@ minetest.register_node("bitchange:donationbox", { local inv = meta:get_inventory() if not inv:is_empty("main") then return false - elseif bitchange_has_access(meta:get_string("owner"), player:get_player_name()) then + elseif bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then return true end return false @@ -59,9 +59,9 @@ minetest.register_node("bitchange:donationbox", { allow_metadata_inventory_put = function(pos, listname, index, stack, player) return stack:get_count() end, - allow_metadata_inventory_take = function(pos, listname, index, stack, player) + allow_metadata_inventory_take = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) - if(not bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then + if not bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then return 0 end return stack:get_count() @@ -69,10 +69,10 @@ minetest.register_node("bitchange:donationbox", { }) minetest.register_craft({ - output = 'bitchange:donationbox', + output = "bitchange:donationbox", recipe = { - {'default:wood', '', 'default:wood'}, - {'default:wood', 'bitchange:minecoin', 'default:wood'}, - {'default:wood', 'default:wood', 'default:wood'} + {"default:wood", "", "default:wood"}, + {"default:wood", "bitchange:minecoin", "default:wood"}, + {"default:wood", "default:wood", "default:wood"} } }) \ No newline at end of file diff --git a/init.lua b/init.lua index 077ebf9..7c54611 100644 --- a/init.lua +++ b/init.lua @@ -3,7 +3,7 @@ bitchange = {} bitchange.mod_path = minetest.get_modpath("bitchange") local world_path = minetest.get_worldpath() -if freeminer then +if rawget(_G, "freeminer") then minetest = freeminer end @@ -27,22 +27,22 @@ end dofile(bitchange.mod_path.."/minecoins.lua") dofile(bitchange.mod_path.."/moreores.lua") -if bitchange_enable_exchangeshop then +if bitchange.enable_exchangeshop then dofile(bitchange.mod_path.."/shop.lua") end -if bitchange_enable_moneychanger then +if bitchange.enable_moneychanger then dofile(bitchange.mod_path.."/moneychanger.lua") end -if bitchange_enable_warehouse then +if bitchange.enable_warehouse then dofile(bitchange.mod_path.."/warehouse.lua") end -if bitchange_enable_toolrepair then +if bitchange.enable_toolrepair then dofile(bitchange.mod_path.."/toolrepair.lua") end -if bitchange_enable_donationbox then +if bitchange.enable_donationbox then dofile(bitchange.mod_path.."/donationbox.lua") end -if bitchange_enable_bank then +if bitchange.enable_bank then local loaded_bank = false for i, v in ipairs({"money", "money2", "currency"}) do if minetest.get_modpath(v) then @@ -61,13 +61,13 @@ end if not minetest.setting_getbool("creative_mode") and bitchange_initial_give > 0 then -- Giving initial money minetest.register_on_newplayer(function(player) - player:get_inventory():add_item("main", "bitchange:mineninth "..bitchange_initial_give) + player:get_inventory():add_item("main", "bitchange:mineninth "..bitchange.initial_give) end) end -- Privs minetest.register_privilege("bitchange", "Can access to owned nodes of the bitchange mod") -function bitchange_has_access(owner, player_name) +function bitchange.has_access(owner, player_name) return (player_name == owner or owner == "" or minetest.get_player_privs(player_name).server or minetest.get_player_privs(player_name).bitchange) end diff --git a/minecoins.lua b/minecoins.lua index adc6022..1c8f75d 100644 --- a/minecoins.lua +++ b/minecoins.lua @@ -40,19 +40,19 @@ minetest.register_node("bitchange:minecoinblock", { is_ground_content = true, groups = {cracky=2}, sounds = default.node_sound_stone_defaults(), - stack_max = 30000, + stack_max = 30000, }) minetest.register_craftitem("bitchange:minecoin", { description = "MineCoin", inventory_image = "bitchange_minecoin.png", - stack_max = 30000, + stack_max = 30000, }) minetest.register_craftitem("bitchange:mineninth", { description = "MineNinth", inventory_image = "bitchange_mineninth.png", - stack_max = 30000, + stack_max = 30000, }) minetest.register_craftitem("bitchange:coinbase", { @@ -62,56 +62,58 @@ minetest.register_craftitem("bitchange:coinbase", { -- Crafting minetest.register_craft({ - output = 'bitchange:minecoinblock', + output = "bitchange:minecoinblock", recipe = { - {'bitchange:minecoin', 'bitchange:minecoin', 'bitchange:minecoin'}, - {'bitchange:minecoin', 'bitchange:minecoin', 'bitchange:minecoin'}, - {'bitchange:minecoin', 'bitchange:minecoin', 'bitchange:minecoin'}, + {"bitchange:minecoin", "bitchange:minecoin", "bitchange:minecoin"}, + {"bitchange:minecoin", "bitchange:minecoin", "bitchange:minecoin"}, + {"bitchange:minecoin", "bitchange:minecoin", "bitchange:minecoin"}, } }) minetest.register_craft({ - output = 'bitchange:minecoin 9', + output = "bitchange:minecoin 9", recipe = { - {'bitchange:minecoinblock'}, + {"bitchange:minecoinblock"}, } }) minetest.register_craft({ - output = 'bitchange:minecoin', + output = "bitchange:minecoin", recipe = { - {'bitchange:mineninth', 'bitchange:mineninth', 'bitchange:mineninth'}, - {'bitchange:mineninth', 'bitchange:mineninth', 'bitchange:mineninth'}, - {'bitchange:mineninth', 'bitchange:mineninth', 'bitchange:mineninth'}, + {"bitchange:mineninth", "bitchange:mineninth", "bitchange:mineninth"}, + {"bitchange:mineninth", "bitchange:mineninth", "bitchange:mineninth"}, + {"bitchange:mineninth", "bitchange:mineninth", "bitchange:mineninth"}, } }) minetest.register_craft({ - output = 'bitchange:mineninth 9', + output = "bitchange:mineninth 9", recipe = { - {'bitchange:minecoin'}, + {"bitchange:minecoin"}, } }) -- Cooking minetest.register_craft({ - type = 'cooking', + type = "cooking", recipe = "bitchange:coinbase", output = "bitchange:mineninth", }) minetest.register_craft({ - type = 'cooking', + type = "cooking", recipe = "default:goldblock", output = "bitchange:minecoinblock 2", }) + minetest.register_craft({ - type = 'cooking', + type = "cooking", recipe = "bitchange:minecoinblock", output = "default:gold_ingot 4", }) -- Generation +if bitchange.enable_generation then minetest.register_ore({ ore_type = "scatter", ore = "bitchange:minecoin_in_ground", @@ -143,4 +145,5 @@ minetest.register_ore({ clust_size = 7, height_max = 28000, height_min = -255, -}) \ No newline at end of file +}) +end \ No newline at end of file diff --git a/moneychanger.lua b/moneychanger.lua index 9e91f57..3ca28e2 100644 --- a/moneychanger.lua +++ b/moneychanger.lua @@ -22,104 +22,86 @@ moneychanger.update_fields = function(pos, listname, index, stack, take) local stack_src = inv:get_stack("source", 1) local stack_src_name = stack_src:get_name() local stack_real_count = 0 - local canMove = false - if(take) then + + if take then stack_real_count = stack_inv:get_count() - stack:get_count() else - if(stack_inv:get_name() ~= "") then + if stack_inv:get_name() ~= "" then stack_real_count = stack_inv:get_count() + stack:get_count() else stack_real_count = stack:get_count() end end - if(listname == "source" and (stack_rest:get_count() == 0 or take)) then + if listname == "rest" then + return stack:get_count() + end + + if listname == "source" and (stack_rest:get_count() == 0 or take) then inv:set_list("output", { "", "" }) - if(stack_real_count > 0) then - if(stack_name == "bitchange:minecoinblock") then + if stack_real_count > 0 then + if stack_name == "bitchange:minecoinblock" then inv:set_list("output", { "bitchange:minecoin "..(stack_real_count*9), "" }) - elseif(stack_name == "bitchange:minecoin") then + elseif stack_name == "bitchange:minecoin" then inv:set_list("output", { "bitchange:mineninth "..math.min(stack_real_count*9, 30000), "bitchange:minecoinblock "..math.floor(stack_real_count/9) }) else inv:set_list("output", { "bitchange:minecoin "..math.min(math.floor(stack_real_count/9), 30000), "" }) end - canMove = true - elseif(stack_real_count == 0 and stack_src:get_count() > 0) then - canMove = true + return stack:get_count() + elseif stack_real_count == 0 and stack_src:get_count() > 0 then + return stack:get_count() end - elseif(listname == "output" and stack_rest:get_count() == 0) then - if(stack_src:get_count() < 1) then - if(stack:get_count() > 0) then - canMove = true + elseif listname == "output" and stack_rest:get_count() == 0 then + if stack_src:get_count() < 1 then + if stack:get_count() > 0 then + return stack:get_count() end inv:set_list("source", { "" }) else - if(stack_src_name ~= "") then - if(stack_name == "bitchange:minecoinblock" and stack_src_name == "bitchange:minecoin") then + if stack_src_name ~= "" then + if stack_name == "bitchange:minecoinblock" and stack_src_name == "bitchange:minecoin" then local amount_left = (stack_src:get_count() - (stack:get_count()*9)) - if(amount_left > 0) then + if amount_left > 0 then inv:set_list("source", { stack_src_name.." "..amount_left }) else inv:set_list("source", { "" }) end - if(index == 1) then + if index == 1 then inv:set_stack("output", 2, "") else inv:set_stack("output", 1, "") end - canMove = true - elseif(stack_name == "bitchange:minecoin" and stack_src_name == "bitchange:mineninth") then + return stack:get_count() + elseif stack_name == "bitchange:minecoin" and stack_src_name == "bitchange:mineninth" then local amount_left = (stack_src:get_count() - (stack:get_count()*9)) - if(amount_left > 0) then + if amount_left > 0 then inv:set_list("source", { stack_src_name.." "..amount_left }) else inv:set_list("source", { "" }) end - canMove = true - elseif(stack_name == "bitchange:minecoin" and stack_src_name == "bitchange:minecoinblock") then + return stack:get_count() + elseif (stack_name == "bitchange:minecoin" and stack_src_name == "bitchange:minecoinblock") or + (stack_name == "bitchange:mineninth" and stack_src_name == "bitchange:minecoin") then local amount_left = stack_src:get_count() - (stack:get_count()/9) local rest_count = (amount_left - math.floor(amount_left))*9 - if(amount_left > -1) then + if amount_left > -1 then inv:set_list("source", { stack_src_name.." "..math.floor(amount_left) }) - if(rest_count > 0) then + if rest_count > 0 then inv:set_list("rest", { stack_name.." "..rest_count }) else inv:set_list("rest", { "" }) end - if(index == 1) then + if index == 1 then inv:set_stack("output", 2, "") else inv:set_stack("output", 1, "") end inv:set_stack("output", index, stack_name.." "..stack:get_count()) - canMove = true - end - elseif(stack_name == "bitchange:mineninth" and stack_src_name == "bitchange:minecoin") then - local amount_left = stack_src:get_count() - (stack:get_count()/9) - local rest_count = (amount_left - math.floor(amount_left))*9 - if(amount_left > -1) then - inv:set_list("source", { stack_src_name.." "..math.floor(amount_left) }) - if(rest_count > 0) then - inv:set_list("rest", { stack_name.." "..rest_count }) - else - inv:set_list("rest", { "" }) - end - if(index == 1) then - inv:set_stack("output", 2, "") - else - inv:set_stack("output", 1, "") - end - inv:set_stack("output", index, stack_name.." "..stack:get_count()) - canMove = true + return stack:get_count() end end end end - elseif(listname == "rest") then - canMove = true - end - if(canMove) then - return stack:get_count() end return 0 end @@ -150,17 +132,19 @@ minetest.register_node("bitchange:moneychanger", { end, allow_metadata_inventory_put = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) - if(not bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then + if not bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then return 0 end - if(listname == "source") then + if listname == "source" then local stack_name = stack:get_name() local inv = meta:get_inventory() local inv_stack = inv:get_stack(listname, index) - if(inv_stack:get_name() ~= "") then + if inv_stack:get_name() ~= "" then return 0 end - if(stack_name == "bitchange:mineninth" or stack_name == "bitchange:minecoin" or stack_name == "bitchange:minecoinblock") then + if stack_name == "bitchange:mineninth" or + stack_name == "bitchange:minecoin" or + stack_name == "bitchange:minecoinblock") then return moneychanger.update_fields(pos, listname, index, stack, false) end end @@ -168,7 +152,7 @@ minetest.register_node("bitchange:moneychanger", { end, allow_metadata_inventory_take = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) - if(bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then + if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then return moneychanger.update_fields(pos, listname, index, stack, true) end return 0 @@ -176,7 +160,7 @@ minetest.register_node("bitchange:moneychanger", { can_dig = function(pos, player) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() - if(bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then + if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then return inv:is_empty("source") and inv:is_empty("output") and inv:is_empty("rest") end return 0 diff --git a/moreores.lua b/moreores.lua index 8c611a9..95ddd51 100644 --- a/moreores.lua +++ b/moreores.lua @@ -1,7 +1,7 @@ --Created by Krock --License: WTFPL -if bitchange_use_moreores_tin and minetest.get_modpath("moreores") then +if bitchange.use_moreores_tin and minetest.get_modpath("moreores") then minetest.register_craft({ output = "bitchange:coinbase 18", recipe = { @@ -12,7 +12,7 @@ if bitchange_use_moreores_tin and minetest.get_modpath("moreores") then }) end -if bitchange_use_technic_zinc and minetest.get_modpath("technic_worldgen") then +if bitchange.use_technic_zinc and minetest.get_modpath("technic_worldgen") then minetest.register_craft({ output = "bitchange:coinbase 8", recipe = { @@ -23,7 +23,7 @@ if bitchange_use_technic_zinc and minetest.get_modpath("technic_worldgen") then }) end -if bitchange_use_quartz and minetest.get_modpath("quartz") then +if bitchange.use_quartz and minetest.get_modpath("quartz") then minetest.register_craft({ output = "bitchange:coinbase", recipe = { diff --git a/shop.lua b/shop.lua index 0d09698..1ee4438 100644 --- a/shop.lua +++ b/shop.lua @@ -50,7 +50,7 @@ local function get_exchange_shop_formspec(number,pos,title) end local function get_exchange_shop_tube_config(mode) - if bitchange_exchangeshop_pipeworks then + if bitchange.exchangeshop_pipeworks then if mode == 1 then return {choppy=2, oddly_breakable_by_hand=2, tubedevice=1, tubedevice_receiver=1} else @@ -231,7 +231,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields) if err_msg ~= "" then minetest.chat_send_player(player_name, "Exchange shop: "..err_msg) end - elseif bitchange_has_access(shop_owner, player_name) then + elseif bitchange.has_access(shop_owner, player_name) then local num = 0 if fields.vcustm then num = 2 @@ -301,12 +301,12 @@ minetest.register_node("bitchange:shop", { end, allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) local meta = minetest.get_meta(pos) - if bitchange_has_access(meta:get_string("owner"), player:get_player_name()) then + if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then return count end return 0 end, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) + allow_metadata_inventory_put = function(pos, listname, index, stack, player) if player:get_player_name() == ":pipeworks" then return stack:get_count() end @@ -315,18 +315,18 @@ minetest.register_node("bitchange:shop", { return 0 end local meta = minetest.get_meta(pos) - if bitchange_has_access(meta:get_string("owner"), player:get_player_name()) and + if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) and listname ~= "cust_ej" and listname ~= "custm_ej" then return stack:get_count() end return 0 end, - allow_metadata_inventory_take = function(pos, listname, index, stack, player) + allow_metadata_inventory_take = function(pos, listname, index, stack, player) if player:get_player_name() == ":pipeworks" then return stack:get_count() end local meta = minetest.get_meta(pos) - if bitchange_has_access(meta:get_string("owner"), player:get_player_name()) or listname == "cust_ej" then + if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) or listname == "cust_ej" then return stack:get_count() end return 0 diff --git a/textures/bitchange_bank_front.png b/textures/bitchange_bank_front.png index f2362f2..11282e5 100644 Binary files a/textures/bitchange_bank_front.png and b/textures/bitchange_bank_front.png differ diff --git a/textures/bitchange_bank_side.png b/textures/bitchange_bank_side.png index ac0bdaf..7389d0a 100644 Binary files a/textures/bitchange_bank_side.png and b/textures/bitchange_bank_side.png differ diff --git a/textures/bitchange_minecoin.png b/textures/bitchange_minecoin.png index 602cef6..1903f88 100644 Binary files a/textures/bitchange_minecoin.png and b/textures/bitchange_minecoin.png differ diff --git a/textures/bitchange_minecoinblock.png b/textures/bitchange_minecoinblock.png index 8c801c1..f1a51c6 100644 Binary files a/textures/bitchange_minecoinblock.png and b/textures/bitchange_minecoinblock.png differ diff --git a/textures/bitchange_mineninth.png b/textures/bitchange_mineninth.png index e18192c..2c3a2c6 100644 Binary files a/textures/bitchange_mineninth.png and b/textures/bitchange_mineninth.png differ diff --git a/textures/bitchange_moneychanger_front.png b/textures/bitchange_moneychanger_front.png index 1465e70..0869f4c 100644 Binary files a/textures/bitchange_moneychanger_front.png and b/textures/bitchange_moneychanger_front.png differ diff --git a/textures/bitchange_moneychanger_side.png b/textures/bitchange_moneychanger_side.png index 142397f..faae639 100644 Binary files a/textures/bitchange_moneychanger_side.png and b/textures/bitchange_moneychanger_side.png differ diff --git a/textures/bitchange_moneychanger_top.png b/textures/bitchange_moneychanger_top.png index 8f35e4d..b89c3d8 100644 Binary files a/textures/bitchange_moneychanger_top.png and b/textures/bitchange_moneychanger_top.png differ diff --git a/textures/bitchange_shop_front.png b/textures/bitchange_shop_front.png index 953dd9f..4d4bf42 100644 Binary files a/textures/bitchange_shop_front.png and b/textures/bitchange_shop_front.png differ diff --git a/textures/bitchange_shop_side.png b/textures/bitchange_shop_side.png index b7c9d6a..01131b2 100644 Binary files a/textures/bitchange_shop_side.png and b/textures/bitchange_shop_side.png differ diff --git a/textures/bitchange_shop_top.png b/textures/bitchange_shop_top.png index 5742be6..ee03f63 100644 Binary files a/textures/bitchange_shop_top.png and b/textures/bitchange_shop_top.png differ diff --git a/textures/bitchange_toolrepair_bottom.png b/textures/bitchange_toolrepair_bottom.png index a6bedcd..3069718 100644 Binary files a/textures/bitchange_toolrepair_bottom.png and b/textures/bitchange_toolrepair_bottom.png differ diff --git a/textures/bitchange_toolrepair_top.png b/textures/bitchange_toolrepair_top.png index 78ef123..84adfd1 100644 Binary files a/textures/bitchange_toolrepair_top.png and b/textures/bitchange_toolrepair_top.png differ diff --git a/textures/bitchange_warehouse_front.png b/textures/bitchange_warehouse_front.png index 40e6035..0e4b57e 100644 Binary files a/textures/bitchange_warehouse_front.png and b/textures/bitchange_warehouse_front.png differ diff --git a/textures/bitchange_warehouse_side.png b/textures/bitchange_warehouse_side.png index 88d969c..47f3b83 100644 Binary files a/textures/bitchange_warehouse_side.png and b/textures/bitchange_warehouse_side.png differ diff --git a/textures/bitchange_warehouse_top.png b/textures/bitchange_warehouse_top.png index c3558eb..e3df0bb 100644 Binary files a/textures/bitchange_warehouse_top.png and b/textures/bitchange_warehouse_top.png differ diff --git a/toolrepair.lua b/toolrepair.lua index 82533bc..0ab38c3 100644 --- a/toolrepair.lua +++ b/toolrepair.lua @@ -2,20 +2,20 @@ --License: WTFPL local function set_infotext(meta, mode) - if(mode == meta:get_int("state")) then + if mode == meta:get_int("state") then return end local owner = meta:get_string("owner") local text = "Tool Repair " local text2 = "[Inactive]" - if(mode == 0) then + if mode == 0 then text = text.."(constructing)" - elseif(mode == 1) then + elseif mode == 1 then text2 = "Inactive" - elseif(mode == 2) then + elseif mode == 2 then text2 = "Active" end - if(mode ~= 0) then + if mode ~= 0 then text = text.."["..text2.."] (owned by "..owner..")" end @@ -59,19 +59,19 @@ minetest.register_node("bitchange:toolrepair", { end, allow_metadata_inventory_put = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) - if(player:get_player_name() ~= meta:get_string("owner")) then + if player:get_player_name() ~= meta:get_string("owner") then return 0 end - if(listname == "src") then + if listname == "src" then if(stack:get_wear() > 0 and stack:get_wear() < 65535 and stack:get_name() ~= "technic:water_can" and stack:get_name() ~= "technic:lava_can") then return 1 end - elseif(listname == "fuel") then - if(stack:get_name() == "bitchange:mineninth") then + elseif listname == "fuel" then + if stack:get_name() == "bitchange:mineninth" then return stack:get_count() end end @@ -79,7 +79,7 @@ minetest.register_node("bitchange:toolrepair", { end, allow_metadata_inventory_take = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) - if(bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then + if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then return stack:get_count() end return 0 @@ -87,7 +87,7 @@ minetest.register_node("bitchange:toolrepair", { can_dig = function(pos, player) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() - if(bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then + if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then return inv:is_empty("src") and inv:is_empty("fuel") end return 0 @@ -95,11 +95,11 @@ minetest.register_node("bitchange:toolrepair", { }) minetest.register_craft({ - output = 'bitchange:toolrepair', + output = "bitchange:toolrepair", recipe = { - {'default:steel_ingot', 'default:stick', 'default:steel_ingot'}, - {'default:jungletree', 'default:mese_crystal', 'default:jungletree'}, - {'default:jungletree', 'bitchange:minecoinblock', 'default:jungletree'} + {"default:steel_ingot", "default:stick", "default:steel_ingot"}, + {"default:jungletree", "default:mese_crystal", "default:jungletree"}, + {"default:jungletree", "bitchange:minecoinblock", "default:jungletree"} } }) diff --git a/warehouse.lua b/warehouse.lua index 37ccd46..b8f6322 100644 --- a/warehouse.lua +++ b/warehouse.lua @@ -3,7 +3,7 @@ --License: WTFPL function get_warehouse_tube_config(mode) - if(bitchange_warehouse_pipeworks) then + if(bitchange.warehouse_pipeworks) then if(mode == 1) then return {cracky=1, level=2, tubedevice=1, tubedevice_receiver=1} else @@ -11,22 +11,22 @@ function get_warehouse_tube_config(mode) insert_object = function(pos, node, stack, direction) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() - if(inv:room_for_item("main",stack)) then - return inv:add_item("main",stack) + if inv:room_for_item("main", stack) then + return inv:add_item("main", stack) else - return inv:add_item("main2",stack) + return inv:add_item("main2", stack) end end, can_insert = function(pos, node, stack, direction) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() - if(inv:room_for_item("main",stack)) then + if inv:room_for_item("main", stack) then return true else - return inv:room_for_item("main2",stack) + return inv:room_for_item("main2", stack) end end, - input_inventory="main", + input_inventory = "main", connect_sides = {left=1, right=1, back=1, top=1, bottom=1} } end @@ -90,31 +90,31 @@ minetest.register_node("bitchange:warehouse", { end, allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) local meta = minetest.get_meta(pos) - if(not bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then + if not bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then return 0 end return count end, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) + allow_metadata_inventory_put = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) - if(not bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then + if not bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then return 0 end return stack:get_count() end, - allow_metadata_inventory_take = function(pos, listname, index, stack, player) + allow_metadata_inventory_take = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) - if(not bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then + if not bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then return 0 end return stack:get_count() end, on_receive_fields = function(pos, formname, fields, sender) local meta = minetest.get_meta(pos) - if(not bitchange_has_access(meta:get_string("owner"), sender:get_player_name())) then + if not bitchange.has_access(meta:get_string("owner"), sender:get_player_name()) then return end - if(fields.inv_lv1) then + if fields.inv_lv1 then meta:set_string("formspec", "size[12,10;]".. "label[0,0;Warehouse]".. "label[2,0;Layer:]".. @@ -124,7 +124,7 @@ minetest.register_node("bitchange:warehouse", { "list[current_name;main;0,1;12,4;]".. "list[current_player;main;2,6;8,4;]") end - if(fields.inv_lv2) then + if fields.inv_lv2 then meta:set_string("formspec", "size[12,10;]".. "label[0,0;Warehouse]".. "label[2,0;Layer:]".. @@ -138,10 +138,10 @@ minetest.register_node("bitchange:warehouse", { }) minetest.register_craft({ - output = 'bitchange:warehouse', + output = "bitchange:warehouse", recipe = { - {'default:chest_locked', 'bitchange:minecoinblock', 'default:chest_locked'}, - {'default:chest_locked', 'default:mese', 'default:chest_locked'}, - {'default:chest_locked', 'default:chest_locked', 'default:chest_locked'} + {"default:chest_locked", "bitchange:minecoinblock", "default:chest_locked"}, + {"default:chest_locked", "default:mese", "default:chest_locked"}, + {"default:chest_locked", "default:chest_locked", "default:chest_locked"} } }) \ No newline at end of file