diff options
author | stujones11 <stujones111@gmail.com> | 2016-01-13 19:51:50 +0000 |
---|---|---|
committer | stujones11 <stujones111@gmail.com> | 2016-01-13 21:06:38 +0000 |
commit | 4416e9b8ad399afa9016a9454e2f84926797cbb5 (patch) | |
tree | 26ebd2fc79da9181d26c2dd78cdd32ed7d013381 /railtrack | |
parent | 6dfdaf78522a9c92e4323fa5bb77eb3a7c11aa30 (diff) |
Remove placement privs until a better solution is found & misc fixes
Diffstat (limited to 'railtrack')
-rw-r--r-- | railtrack/init.lua | 13 | ||||
-rw-r--r-- | railtrack/railtrack.lua | 20 |
2 files changed, 15 insertions, 18 deletions
diff --git a/railtrack/init.lua b/railtrack/init.lua index 373fcaa..353249f 100644 --- a/railtrack/init.lua +++ b/railtrack/init.lua @@ -96,11 +96,14 @@ minetest.register_tool("railtrack:fixer", { end end local node = minetest.get_node(pos) - minetest.remove_node(pos) - set_node(pos, node) - local def = minetest.registered_items[node.name] or {} - if type(def.after_place_node) == "function" then - def.after_place_node(pos, user, node) + if node then + minetest.remove_node(pos) + minetest.set_node(pos, node) + local def = minetest.registered_items[node.name] or {} + local itemstack = ItemStack(node.name) + if type(def.after_place_node) == "function" then + def.after_place_node(pos, user, itemstack) + end end end, }) diff --git a/railtrack/railtrack.lua b/railtrack/railtrack.lua index 3a1f714..9b4c2c9 100644 --- a/railtrack/railtrack.lua +++ b/railtrack/railtrack.lua @@ -22,18 +22,6 @@ railtrack.default_rail = { groups = {bendy = 2, dig_immediate = 2, attached_node = 1, connect_to_raillike = minetest.raillike_group("rail")}, railtype = "rail", - on_place = function(itemstack, placer, pointed_thing) - local name = placer:get_player_name() - if not name or pointed_thing.type ~= "node" then - return - end - if not minetest.is_singleplayer() then - if not minetest.check_player_privs(name, {rails=true}) then - minetest.chat_send_player(name, "Requires rails privilege") - return - end - end - end, after_place_node = function(pos, placer, itemstack) local meta = minetest.get_meta(pos) local def = itemstack:get_definition() or {} @@ -57,7 +45,13 @@ railtrack.default_rail = { on_construct = function(pos) railtrack:update_rails(pos) end, - after_destruct = function(pos) + after_destruct = function(pos, oldnode) + if not minetest.is_singleplayer() then + if not minetest.check_player_privs(name, {rails=true}) then + minetest.chat_send_player(name, "Requires rails privilege") + minetest.set_node(pos, oldnode) + end + end local cons = railtrack:get_connections(pos) for _, p in pairs(cons) do railtrack:update_rails(p) |