prepared buttons for muting/unmuting npc

This commit is contained in:
Sokomine 2021-05-10 18:55:14 +02:00
parent 0c7f4a4db9
commit ab1c8de031

View File

@ -1484,6 +1484,31 @@ local function get_fs_talkdialog(player, n_id, d_id)
"a conversation is started.]") "a conversation is started.]")
end end
-- chat option: Mute/Unmute NPC
h = h + 1
local obj = yl_speak_up.speak_to[pname].obj
-- some precautions - someone else might have eliminated the NPC in the meantime
local luaentity = nil
if(obj) then
luaentity = obj:get_luaentity()
end
if(luaentity and luaentity.yl_speak_up.talk) then
table.insert(formspec, "button[0.5," .. h .. ";53.8,0.9;mute_npc;]")
table.insert(formspec, "tooltip[mute_npc;The NPC will no longer show his dialogs "..
"when he is right-clicked. This is useful while you edit the NPC and don't "..
"want players to see unfinished entries and/or quests.]")
table.insert(formspec, "label[0.7,"..(h+0.45)..";Stop talking to other players while "..
"I give you new orders.]")
elseif(luaentity) then
-- unmute the NPC
table.insert(formspec, "button[0.5," .. h .. ";53.8,0.9;un_mute_npc;]")
table.insert(formspec, "tooltip[un_mute_npc;The NPC will show his dialogs to other "..
"players when he is right-clicked. This is the normal mode of operation. Choose "..
"this when you are finished editing.]")
table.insert(formspec, "label[0.7,"..(h+0.45)..";Talk to anyone who wants to talk to "..
"you.]")
end
-- chat option: "That was all. I'm finished with giving you new orders. Remember them!" -- chat option: "That was all. I'm finished with giving you new orders. Remember them!"
h = h + 1 h = h + 1
table.insert(formspec, "button_exit[0.5," .. h .. ";53.8,0.9;button_end_edit_mode;]") table.insert(formspec, "button_exit[0.5," .. h .. ";53.8,0.9;button_end_edit_mode;]")
@ -3079,6 +3104,8 @@ function yl_speak_up.talk(self, clicker)
end end
if not self.yl_speak_up or not self.yl_speak_up.talk or self.yl_speak_up.talk~=true then if not self.yl_speak_up or not self.yl_speak_up.talk or self.yl_speak_up.talk~=true then
-- TODO: allow to enter edit mode; show a small formspec that this npc is busy
return return
end end