Skip to content
Snippets Groups Projects
Commit 480e55ed authored by Tim's avatar Tim
Browse files

Fix rope protection handling and get rid of a global callback.

parent 0bba88c7
No related branches found
No related tags found
No related merge requests found
local rope = {}
-- Code by Mirko K. (modified by Temperest, Wulfsdad and kilbith) (License: GPL).
minetest.register_on_punchnode(function(pos, oldnode, digger)
if oldnode.name == "xdecor:rope" then
rope:remove(pos, oldnode, digger, "xdecor:rope")
end
end)
function rope.place(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local pos = pointed_thing.above
......@@ -27,7 +21,7 @@ function rope.place(itemstack, placer, pointed_thing)
return itemstack
end
function rope:remove(pos, oldnode, digger, rope_name)
function rope.remove(pos, oldnode, digger, rope_name)
local num = 0
local below = {x=pos.x, y=pos.y, z=pos.z}
local digger_inv = digger:get_inventory()
......@@ -52,5 +46,12 @@ xdecor.register("rope", {
inventory_image = "xdecor_rope_inv.png",
wield_image = "xdecor_rope_inv.png",
selection_box = xdecor.pixelbox(8, {{3, 0, 3, 2, 8, 2}}),
on_place = rope.place
on_place = rope.place,
on_punch = function(pos, node, puncher, pointed_thing)
local player_name = puncher:get_player_name()
if not minetest.is_protected(pos, player_name) or
minetest.get_player_privs(player_name).protection_bypass then
rope.remove(pos, node, puncher, "xdecor:rope")
end
end
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment