mirror of
https://github.com/SmallJoker/bitchange.git
synced 2025-07-17 15:50:19 +02:00
💥 Break old settings
- Rename bitchange_ -> bitchange. - Better coding style - Run OptiPNG
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user