yl_speak_up.allow_staff_use = function(itemstack, user, pointed_thing) local has_priv = minetest.check_player_privs(user, {npc_master=true}) local p_name = user:get_player_name() if not has_priv then minetest.chat_send_player(p_name,yl_speak_up.message_tool_taken_because_of_lacking_priv) -- no special NPC involved yl_speak_up.log_change(p_name, nil, "User "..p_name.. " used an admin item: "..itemstack:get_name().. " at pos "..minetest.pos_to_string(user:get_pos(),0), "action") itemstack:take_item(1) return end if (pointed_thing.type ~= "object") then return end local obj = pointed_thing.ref local luaentity = obj:get_luaentity() -- Is the thing we clicked really one of our NPCs? if not(luaentity) or (luaentity and not(luaentity.yl_speak_up)) then return end return obj end minetest.register_tool("yl_speak_up:staff_of_i_said_so", { description = "Staff of I-said-so", inventory_image = "yl_speak_up_staff_of_i_said_so.png", on_use = function(itemstack, user, pointed_thing) local obj = yl_speak_up.allow_staff_use(itemstack, user, pointed_thing) if(not(obj)) then return itemstack end yl_speak_up.config(user, obj) return itemstack end }) minetest.register_tool("yl_speak_up:staff_of_shut_up", { description = "Staff of shut-up", inventory_image = "yl_speak_up_staff_of_shut_up.png", on_use = function(itemstack, user, pointed_thing) local obj = yl_speak_up.allow_staff_use(itemstack, user, pointed_thing) if(not(obj)) then return itemstack end local p_name = user:get_player_name() yl_speak_up.set_muted(p_name, obj, true) return itemstack end }) minetest.register_tool("yl_speak_up:staff_of_dawai_dawai", { description = "Staff of dawai-dawai", inventory_image = "yl_speak_up_staff_of_dawai_dawai.png", on_use = function(itemstack, user, pointed_thing) local obj = yl_speak_up.allow_staff_use(itemstack, user, pointed_thing) if(not(obj)) then return itemstack end local p_name = user:get_player_name() yl_speak_up.set_muted(p_name, obj, false) return itemstack end }) minetest.register_tool("yl_speak_up:staff_of_game_over", { description = "Staff of game-over", inventory_image = "yl_speak_up_staff_of_game_over.png", on_use = function(itemstack, user, pointed_thing) local obj = yl_speak_up.allow_staff_use(itemstack, user, pointed_thing) if(not(obj)) then return itemstack end local p_name = user:get_player_name() local luaentity = obj:get_luaentity() local npc = luaentity.yl_speak_up.id minetest.chat_send_player(p_name,"NPC with ID n_"..npc.." removed from position ".. minetest.pos_to_string(obj:get_pos(),0).." on command of "..p_name) yl_speak_up.log_change(p_name, "n_"..tostring(npc), "removed with Staff of game-over") obj:remove() return itemstack end }) minetest.register_tool("yl_speak_up:staff_of_fashion", { description = "Staff of fashion", inventory_image = "yl_speak_up_staff_of_fashion.png", on_use = function(itemstack, user, pointed_thing) local obj = yl_speak_up.allow_staff_use(itemstack, user, pointed_thing) if(not(obj)) then return itemstack end local p_name = user:get_player_name() local luaentity = obj:get_luaentity() local npc = luaentity.yl_speak_up.id yl_speak_up.fashion(user, obj) minetest.chat_send_player(p_name,"NPC with ID n_"..npc.." will redress at pos ".. minetest.pos_to_string(obj:get_pos(),0).." on command of "..p_name) yl_speak_up.log_change(p_name, "n_"..tostring(npc), "changed skin with Staff of fashion") return itemstack end })