forked from your-land-mirror/yl_speak_up
125 lines
3.6 KiB
Lua
125 lines
3.6 KiB
Lua
|
|
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)
|
|
minetest.log("action","[MOD] yl_speak_up: User "..p_name..
|
|
" used an admin item: "..itemstack:get_name()..
|
|
" at pos "..minetest.pos_to_string(user:get_pos(),0))
|
|
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 "..npc.." removed from position "..
|
|
minetest.pos_to_string(obj:get_pos(),0).." on command of "..p_name)
|
|
minetest.log("action","[MOD] yl_speak_up: NPC with ID "..npc..
|
|
" removed from position "..minetest.pos_to_string(obj:get_pos(),0)..
|
|
" on command of "..p_name)
|
|
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)
|
|
minetest.log("action","[MOD] yl_speak_up: NPC with ID n_"..npc.." will redress at pos "..
|
|
minetest.pos_to_string(obj:get_pos(),0).." on command of "..p_name)
|
|
return itemstack
|
|
end
|
|
})
|