Commit 84f1b0f3 authored by SmallJoker's avatar SmallJoker
Browse files

💥 Break old settings

- Rename bitchange_ -> bitchange.
- Better coding style
- Run OptiPNG
parent 20fcf0a0
...@@ -87,21 +87,21 @@ minetest.register_node("bitchange:bank", { ...@@ -87,21 +87,21 @@ minetest.register_node("bitchange:bank", {
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos) 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 return count
end end
return 0 return 0
end, 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) 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() return stack:get_count()
end end
return 0 return 0
end, 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) 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() return stack:get_count()
end end
return 0 return 0
......
-- General configuration - BitChange -- General configuration - BitChange
-- Created by Krock -- Created by Krock
bitchange_initial_give = 2 bitchange.initial_give = 2
-- Enable/Disable whole nodes -- Enable/Disable whole nodes
bitchange_enable_exchangeshop = true bitchange.enable_exchangeshop = true
bitchange_enable_moneychanger = true bitchange.enable_moneychanger = true
bitchange_enable_warehouse = false bitchange.enable_warehouse = false
bitchange_enable_toolrepair = true bitchange.enable_toolrepair = true
bitchange_enable_donationbox = true bitchange.enable_donationbox = true
-- Set this variable to false if you have a supported currency enabled -- Set this variable to false if you have a supported currency enabled
-- and if you want to disable the exchanging/converting point - the bank -- and if you want to disable the exchanging/converting point - the bank
-- Supported: money (by kotolegokot), money2 (by Bad Command), currency (by Dan Duncombe) -- 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 -- Converting other ores to MineCoins
-- Tin moreores -- Tin moreores
-- Zinc technic_worldgen -- Zinc technic_worldgen
-- Quartz quartz -- Quartz quartz
bitchange_use_moreores_tin = false bitchange.use_moreores_tin = false
bitchange_use_technic_zinc = false bitchange.use_technic_zinc = false
bitchange_use_quartz = false bitchange.use_quartz = false
-- Pipeworks support -- Pipeworks support
bitchange_exchangeshop_pipeworks = false bitchange.exchangeshop_pipeworks = false
bitchange_warehouse_pipeworks = false bitchange.warehouse_pipeworks = false
-- Advanced generation settings -- Advanced generation settings
-- Change in 'minecoins.lua', starting at line 101 -- Change in 'minecoins.lua', starting at line 101
bitchange.enable_generation = true
\ No newline at end of file
...@@ -48,7 +48,7 @@ minetest.register_node("bitchange:donationbox", { ...@@ -48,7 +48,7 @@ minetest.register_node("bitchange:donationbox", {
local inv = meta:get_inventory() local inv = meta:get_inventory()
if not inv:is_empty("main") then if not inv:is_empty("main") then
return false 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 return true
end end
return false return false
...@@ -59,9 +59,9 @@ minetest.register_node("bitchange:donationbox", { ...@@ -59,9 +59,9 @@ minetest.register_node("bitchange:donationbox", {
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
return stack:get_count() return stack:get_count()
end, 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) 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 return 0
end end
return stack:get_count() return stack:get_count()
...@@ -69,10 +69,10 @@ minetest.register_node("bitchange:donationbox", { ...@@ -69,10 +69,10 @@ minetest.register_node("bitchange:donationbox", {
}) })
minetest.register_craft({ minetest.register_craft({
output = 'bitchange:donationbox', output = "bitchange:donationbox",
recipe = { recipe = {
{'default:wood', '', 'default:wood'}, {"default:wood", "", "default:wood"},
{'default:wood', 'bitchange:minecoin', 'default:wood'}, {"default:wood", "bitchange:minecoin", "default:wood"},
{'default:wood', 'default:wood', 'default:wood'} {"default:wood", "default:wood", "default:wood"}
} }
}) })
\ No newline at end of file
...@@ -3,7 +3,7 @@ bitchange = {} ...@@ -3,7 +3,7 @@ bitchange = {}
bitchange.mod_path = minetest.get_modpath("bitchange") bitchange.mod_path = minetest.get_modpath("bitchange")
local world_path = minetest.get_worldpath() local world_path = minetest.get_worldpath()
if freeminer then if rawget(_G, "freeminer") then
minetest = freeminer minetest = freeminer
end end
...@@ -27,22 +27,22 @@ end ...@@ -27,22 +27,22 @@ end
dofile(bitchange.mod_path.."/minecoins.lua") dofile(bitchange.mod_path.."/minecoins.lua")
dofile(bitchange.mod_path.."/moreores.lua") dofile(bitchange.mod_path.."/moreores.lua")
if bitchange_enable_exchangeshop then if bitchange.enable_exchangeshop then
dofile(bitchange.mod_path.."/shop.lua") dofile(bitchange.mod_path.."/shop.lua")
end end
if bitchange_enable_moneychanger then if bitchange.enable_moneychanger then
dofile(bitchange.mod_path.."/moneychanger.lua") dofile(bitchange.mod_path.."/moneychanger.lua")
end end
if bitchange_enable_warehouse then if bitchange.enable_warehouse then
dofile(bitchange.mod_path.."/warehouse.lua") dofile(bitchange.mod_path.."/warehouse.lua")
end end
if bitchange_enable_toolrepair then if bitchange.enable_toolrepair then
dofile(bitchange.mod_path.."/toolrepair.lua") dofile(bitchange.mod_path.."/toolrepair.lua")
end end
if bitchange_enable_donationbox then if bitchange.enable_donationbox then
dofile(bitchange.mod_path.."/donationbox.lua") dofile(bitchange.mod_path.."/donationbox.lua")
end end
if bitchange_enable_bank then if bitchange.enable_bank then
local loaded_bank = false local loaded_bank = false
for i, v in ipairs({"money", "money2", "currency"}) do for i, v in ipairs({"money", "money2", "currency"}) do
if minetest.get_modpath(v) then if minetest.get_modpath(v) then
...@@ -61,13 +61,13 @@ end ...@@ -61,13 +61,13 @@ end
if not minetest.setting_getbool("creative_mode") and bitchange_initial_give > 0 then if not minetest.setting_getbool("creative_mode") and bitchange_initial_give > 0 then
-- Giving initial money -- Giving initial money
minetest.register_on_newplayer(function(player) 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)
end end
-- Privs -- Privs
minetest.register_privilege("bitchange", "Can access to owned nodes of the bitchange mod") 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) return (player_name == owner or owner == "" or minetest.get_player_privs(player_name).server or minetest.get_player_privs(player_name).bitchange)
end end
......
...@@ -40,19 +40,19 @@ minetest.register_node("bitchange:minecoinblock", { ...@@ -40,19 +40,19 @@ minetest.register_node("bitchange:minecoinblock", {
is_ground_content = true, is_ground_content = true,
groups = {cracky=2}, groups = {cracky=2},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
stack_max = 30000, stack_max = 30000,
}) })
minetest.register_craftitem("bitchange:minecoin", { minetest.register_craftitem("bitchange:minecoin", {
description = "MineCoin", description = "MineCoin",
inventory_image = "bitchange_minecoin.png", inventory_image = "bitchange_minecoin.png",
stack_max = 30000, stack_max = 30000,
}) })
minetest.register_craftitem("bitchange:mineninth", { minetest.register_craftitem("bitchange:mineninth", {
description = "MineNinth", description = "MineNinth",
inventory_image = "bitchange_mineninth.png", inventory_image = "bitchange_mineninth.png",
stack_max = 30000, stack_max = 30000,
}) })
minetest.register_craftitem("bitchange:coinbase", { minetest.register_craftitem("bitchange:coinbase", {
...@@ -62,56 +62,58 @@ minetest.register_craftitem("bitchange:coinbase", { ...@@ -62,56 +62,58 @@ minetest.register_craftitem("bitchange:coinbase", {
-- Crafting -- Crafting
minetest.register_craft({ minetest.register_craft({
output = 'bitchange:minecoinblock', output = "bitchange:minecoinblock",
recipe = { 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({ minetest.register_craft({
output = 'bitchange:minecoin 9', output = "bitchange:minecoin 9",
recipe = { recipe = {
{'bitchange:minecoinblock'}, {"bitchange:minecoinblock"},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = 'bitchange:minecoin', output = "bitchange:minecoin",
recipe = { 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({ minetest.register_craft({
output = 'bitchange:mineninth 9', output = "bitchange:mineninth 9",
recipe = { recipe = {
{'bitchange:minecoin'}, {"bitchange:minecoin"},
} }
}) })
-- Cooking -- Cooking
minetest.register_craft({ minetest.register_craft({
type = 'cooking', type = "cooking",
recipe = "bitchange:coinbase", recipe = "bitchange:coinbase",
output = "bitchange:mineninth", output = "bitchange:mineninth",
}) })
minetest.register_craft({ minetest.register_craft({
type = 'cooking', type = "cooking",
recipe = "default:goldblock", recipe = "default:goldblock",
output = "bitchange:minecoinblock 2", output = "bitchange:minecoinblock 2",
}) })
minetest.register_craft({ minetest.register_craft({
type = 'cooking', type = "cooking",
recipe = "bitchange:minecoinblock", recipe = "bitchange:minecoinblock",
output = "default:gold_ingot 4", output = "default:gold_ingot 4",
}) })
-- Generation -- Generation
if bitchange.enable_generation then
minetest.register_ore({ minetest.register_ore({
ore_type = "scatter", ore_type = "scatter",
ore = "bitchange:minecoin_in_ground", ore = "bitchange:minecoin_in_ground",
...@@ -143,4 +145,5 @@ minetest.register_ore({ ...@@ -143,4 +145,5 @@ minetest.register_ore({
clust_size = 7, clust_size = 7,
height_max = 28000, height_max = 28000,
height_min = -255, height_min = -255,
}) })
\ No newline at end of file end
\ No newline at end of file
...@@ -22,104 +22,86 @@ moneychanger.update_fields = function(pos, listname, index, stack, take) ...@@ -22,104 +22,86 @@ moneychanger.update_fields = function(pos, listname, index, stack, take)
local stack_src = inv:get_stack("source", 1) local stack_src = inv:get_stack("source", 1)
local stack_src_name = stack_src:get_name() local stack_src_name = stack_src:get_name()
local stack_real_count = 0 local stack_real_count = 0
local canMove = false
if(take) then if take then
stack_real_count = stack_inv:get_count() - stack:get_count() stack_real_count = stack_inv:get_count() - stack:get_count()
else else
if(stack_inv:get_name() ~= "") then if stack_inv:get_name() ~= "" then
stack_real_count = stack_inv:get_count() + stack:get_count() stack_real_count = stack_inv:get_count() + stack:get_count()
else else
stack_real_count = stack:get_count() stack_real_count = stack:get_count()
end end
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", { "", "" }) inv:set_list("output", { "", "" })
if(stack_real_count > 0) then if stack_real_count > 0 then
if(stack_name == "bitchange:minecoinblock") then if stack_name == "bitchange:minecoinblock" then
inv:set_list("output", { "bitchange:minecoin "..(stack_real_count*9), "" }) 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) }) inv:set_list("output", { "bitchange:mineninth "..math.min(stack_real_count*9, 30000), "bitchange:minecoinblock "..math.floor(stack_real_count/9) })
else else
inv:set_list("output", { "bitchange:minecoin "..math.min(math.floor(stack_real_count/9), 30000), "" }) inv:set_list("output", { "bitchange:minecoin "..math.min(math.floor(stack_real_count/9), 30000), "" })
end end
canMove = true return stack:get_count()
elseif(stack_real_count == 0 and stack_src:get_count() > 0) then elseif stack_real_count == 0 and stack_src:get_count() > 0 then
canMove = true return stack:get_count()
end end
elseif(listname == "output" and stack_rest:get_count() == 0) then elseif listname == "output" and stack_rest:get_count() == 0 then
if(stack_src:get_count() < 1) then if stack_src:get_count() < 1 then
if(stack:get_count() > 0) then if stack:get_count() > 0 then
canMove = true return stack:get_count()
end end
inv:set_list("source", { "" }) inv:set_list("source", { "" })
else else
if(stack_src_name ~= "") then if stack_src_name ~= "" then
if(stack_name == "bitchange:minecoinblock" and stack_src_name == "bitchange:minecoin") then if stack_name == "bitchange:minecoinblock" and stack_src_name == "bitchange:minecoin" then
local amount_left = (stack_src:get_count() - (stack:get_count()*9)) 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 }) inv:set_list("source", { stack_src_name.." "..amount_left })
else else
inv:set_list("source", { "" }) inv:set_list("source", { "" })
end end
if(index == 1) then if index == 1 then
inv:set_stack("output", 2, "") inv:set_stack("output", 2, "")
else else
inv:set_stack("output", 1, "") inv:set_stack("output", 1, "")
end end
canMove = true return stack:get_count()
elseif(stack_name == "bitchange:minecoin" and stack_src_name == "bitchange:mineninth") then elseif stack_name == "bitchange:minecoin" and stack_src_name == "bitchange:mineninth" then
local amount_left = (stack_src:get_count() - (stack:get_count()*9)) 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 }) inv:set_list("source", { stack_src_name.." "..amount_left })
else else
inv:set_list("source", { "" }) inv:set_list("source", { "" })
end end
canMove = true return stack:get_count()
elseif(stack_name == "bitchange:minecoin" and stack_src_name == "bitchange:minecoinblock") then 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 amount_left = stack_src:get_count() - (stack:get_count()/9)
local rest_count = (amount_left - math.floor(amount_left))*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) }) 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 }) inv:set_list("rest", { stack_name.." "..rest_count })
else else
inv:set_list("rest", { "" }) inv:set_list("rest", { "" })
end end
if(index == 1) then if index == 1 then
inv:set_stack("output", 2, "") inv:set_stack("output", 2, "")
else else
inv:set_stack("output", 1, "") inv:set_stack("output", 1, "")
end end
inv:set_stack("output", index, stack_name.." "..stack:get_count()) inv:set_stack("output", index, stack_name.." "..stack:get_count())
canMove = true return stack:get_count()
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
end end
end end
end end
end end
elseif(listname == "rest") then
canMove = true
end
if(canMove) then
return stack:get_count()
end end
return 0 return 0
end end
...@@ -150,17 +132,19 @@ minetest.register_node("bitchange:moneychanger", { ...@@ -150,17 +132,19 @@ minetest.register_node("bitchange:moneychanger", {
end, 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) 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 return 0
end end
if(listname == "source") then if listname == "source" then
local stack_name = stack:get_name() local stack_name = stack:get_name()
local inv = meta:get_inventory() local inv = meta:get_inventory()
local inv_stack = inv:get_stack(listname, index) local inv_stack = inv:get_stack(listname, index)
if(inv_stack:get_name() ~= "") then if inv_stack:get_name() ~= "" then
return 0 return 0
end 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) return moneychanger.update_fields(pos, listname, index, stack, false)
end end
end end
...@@ -168,7 +152,7 @@ minetest.register_node("bitchange:moneychanger", { ...@@ -168,7 +152,7 @@ minetest.register_node("bitchange:moneychanger", {
end, 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) 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) return moneychanger.update_fields(pos, listname, index, stack, true)
end end
return 0 return 0
...@@ -176,7 +160,7 @@ minetest.register_node("bitchange:moneychanger", { ...@@ -176,7 +160,7 @@ minetest.register_node("bitchange:moneychanger", {
can_dig = function(pos, player) can_dig = function(pos, player)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() 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") return inv:is_empty("source") and inv:is_empty("output") and inv:is_empty("rest")
end end
return 0 return 0
......