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
18
init.lua
18
init.lua
@ -111,19 +111,17 @@ for name,_ in pairs(chests) do
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function return_remove_next(allowed_name)
|
||||||
local function remove_next(pos, oldnode)
|
local function remove_next(pos, oldnode)
|
||||||
local p1 = oldnode.param2
|
local x, z = unpack(string.split(param_tab2[oldnode.param2], " "))
|
||||||
for p,param in pairs(param_tab) do
|
|
||||||
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
|
||||||
|
end
|
||||||
|
return remove_next
|
||||||
|
end
|
||||||
|
|
||||||
local function log_access(pos, player, text)
|
local function log_access(pos, player, text)
|
||||||
minetest.log("action", player:get_player_name()..
|
minetest.log("action", player:get_player_name()..
|
||||||
@ -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