mirror of
https://github.com/HybridDog/connected_chests.git
synced 2024-12-28 22:20:18 +01:00
disallow removing nodes by digging the left part of big chests
This commit is contained in:
parent
afc271823c
commit
533ef781b1
20
init.lua
20
init.lua
@ -111,18 +111,16 @@ for name,_ in pairs(chests) do
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function remove_next(pos, oldnode)
|
local function return_remove_next(allowed_name)
|
||||||
local p1 = oldnode.param2
|
local function remove_next(pos, oldnode)
|
||||||
for p,param in pairs(param_tab) do
|
local x, z = unpack(string.split(param_tab2[oldnode.param2], " "))
|
||||||
if param == p1 then
|
|
||||||
p1 = p
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local x, z = unpack(string.split(p1, " "))
|
|
||||||
pos.x = pos.x-x
|
pos.x = pos.x-x
|
||||||
pos.z = pos.z-z
|
pos.z = pos.z-z
|
||||||
|
if minetest.get_node(pos).name == allowed_name then
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return remove_next
|
||||||
end
|
end
|
||||||
|
|
||||||
local function log_access(pos, player, text)
|
local function log_access(pos, player, text)
|
||||||
@ -146,7 +144,7 @@ minetest.register_node("connected_chests:chest_left", {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
can_dig = default_chest.can_dig,
|
can_dig = default_chest.can_dig,
|
||||||
after_dig_node = remove_next,
|
after_dig_node = return_remove_next("connected_chests:chest_right"),
|
||||||
on_metadata_inventory_move = function(pos, _, _, _, _, _, player)
|
on_metadata_inventory_move = function(pos, _, _, _, _, _, player)
|
||||||
log_access(pos, player, "in a big chest")
|
log_access(pos, player, "in a big chest")
|
||||||
end,
|
end,
|
||||||
@ -182,7 +180,7 @@ minetest.register_node("connected_chests:chest_locked_left", {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
can_dig = default_chest_locked.can_dig,
|
can_dig = default_chest_locked.can_dig,
|
||||||
after_dig_node = remove_next,
|
after_dig_node = return_remove_next("connected_chests:chest_locked_right"),
|
||||||
allow_metadata_inventory_move = default_chest_locked.allow_metadata_inventory_move,
|
allow_metadata_inventory_move = default_chest_locked.allow_metadata_inventory_move,
|
||||||
allow_metadata_inventory_put = default_chest_locked.allow_metadata_inventory_put,
|
allow_metadata_inventory_put = default_chest_locked.allow_metadata_inventory_put,
|
||||||
allow_metadata_inventory_take = default_chest_locked.allow_metadata_inventory_take,
|
allow_metadata_inventory_take = default_chest_locked.allow_metadata_inventory_take,
|
||||||
|
Loading…
Reference in New Issue
Block a user