[maptools] add priv requirement for admin pick

This commit is contained in:
elite 2017-07-10 19:33:48 -04:00
parent 8ca612e87c
commit 1d8c419ae0
2 changed files with 28 additions and 0 deletions

View File

@ -26,6 +26,7 @@ dofile(modpath .. "/craftitems.lua")
dofile(modpath .. "/default_nodes.lua") dofile(modpath .. "/default_nodes.lua")
dofile(modpath .. "/nodes.lua") dofile(modpath .. "/nodes.lua")
dofile(modpath .. "/tools.lua") dofile(modpath .. "/tools.lua")
dofile(modpath .. "/priv.lua")
if minetest.setting_getbool("log_mods") then if minetest.setting_getbool("log_mods") then
minetest.log("action", S("[maptools] loaded.")) minetest.log("action", S("[maptools] loaded."))

View File

@ -0,0 +1,27 @@
local function kill_node(pos, node, puncher)
if puncher:get_wielded_item():get_name() == "maptools:pick_admin" then
if not minetest.check_player_privs(
puncher:get_player_name(), {worldedit = true}) then
puncher:set_wielded_item("")
minetest.log("action", puncher:get_player_name() ..
" tried to use a Super Pickaxe!")
return
end
local nn = minetest.get_node(pos).name
if nn == "air" then return end
minetest.log("action", puncher:get_player_name() ..
" digs " .. nn ..
" at " .. minetest.pos_to_string(pos) ..
" using a Super Pickaxe!")
local node_drops = minetest.get_node_drops(nn, "superpick:pick")
for i=1, #node_drops do
local add_node = puncher:get_inventory():add_item("main", node_drops[i])
if add_node then minetest.add_item(pos, add_node) end
end
end
end
minetest.register_on_punchnode(function(pos, node, puncher)
kill_node(pos, node, puncher)
end)