summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2013-12-10 19:52:40 -0500
committerShadowNinja <shadowninja@minetest.net>2013-12-10 19:52:40 -0500
commit818a0e5ff048a24570026b5905cd6e2113cd91c9 (patch)
tree83d5e651c6d77662547d22ecc91b8fcbf4b98387
parent47b0b59884488ede2d66f937ed084595e42256f5 (diff)
Add protection support to the sonic screwdriver
-rw-r--r--technic/tools/sonic_screwdriver.lua23
1 files changed, 13 insertions, 10 deletions
diff --git a/technic/tools/sonic_screwdriver.lua b/technic/tools/sonic_screwdriver.lua
index 7bd26fd..32f29d6 100644
--- a/technic/tools/sonic_screwdriver.lua
+++ b/technic/tools/sonic_screwdriver.lua
@@ -41,17 +41,20 @@ minetest.register_tool("technic:sonic_screwdriver", {
p = 0
end
end
- -- hacky_swap_node, unforunatly.
- local meta = minetest.get_meta(pos)
- local meta0 = meta:to_table()
- node.param2 = p
- minetest.set_node(pos, node)
- meta = minetest.get_meta(pos)
- meta:from_table(meta0)
+ if minetest.is_protected(pos, user:get_player_name()) then
+ minetest.record_protection_violation(pos, user:get_player_name())
+ else
+ local meta = minetest.get_meta(pos)
+ local meta0 = meta:to_table()
+ node.param2 = p
+ minetest.set_node(pos, node)
+ meta = minetest.get_meta(pos)
+ meta:from_table(meta0)
- meta1.charge = meta1.charge - 100
- itemstack:set_metadata(set_item_meta(meta1))
- technic.set_RE_wear(itemstack, meta1.charge, sonic_screwdriver_max_charge)
+ meta1.charge = meta1.charge - 100
+ itemstack:set_metadata(set_item_meta(meta1))
+ technic.set_RE_wear(itemstack, meta1.charge, sonic_screwdriver_max_charge)
+ end
end
return itemstack
end,