forked from Sokomine/yl_speak_up
allow to mute/unmute the npc via talking
This commit is contained in:
parent
052b6ab73f
commit
9b98d3fd21
@ -10,8 +10,6 @@ yl_sokomine["q_apple_explorer"] = {}
|
||||
-- chat option: "That was all. I'm finished with giving you new orders. Remember them!"
|
||||
-- -> ends edit mode
|
||||
--
|
||||
-- TODO: allow owner to mute/unmute npc (would be bad if players can already see what is going
|
||||
-- to happen while the owner creates a long quest)
|
||||
-- TODO: log changes to the npc in the server logfile
|
||||
|
||||
--###
|
||||
@ -1495,16 +1493,16 @@ local function get_fs_talkdialog(player, n_id, d_id)
|
||||
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.]")
|
||||
table.insert(formspec, "label[0.7,"..(h+0.45)..";State: Not muted. 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.]")
|
||||
table.insert(formspec, "label[0.7,"..(h+0.45)..";State: You are currently muted. Talk to "..
|
||||
"anyone again who wants to talk to you.]")
|
||||
end
|
||||
|
||||
-- chat option: "That was all. I'm finished with giving you new orders. Remember them!"
|
||||
@ -2144,6 +2142,17 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
|
||||
return
|
||||
end
|
||||
|
||||
-- allow owner to mute/unmute npc (would be bad if players can already see what is going
|
||||
-- to happen while the owner creates a long quest)
|
||||
-- mute/unmute gets logged in the function and does not need extra log entries
|
||||
local obj = yl_speak_up.speak_to[pname].obj
|
||||
if(fields.mute_npc and obj) then
|
||||
yl_speak_up.set_muted(pname, obj, true)
|
||||
elseif(fields.un_mute_npc and obj) then
|
||||
yl_speak_up.set_muted(pname, obj, false)
|
||||
end
|
||||
|
||||
|
||||
-- new options etc. may be added; store these IDs so that we can switch to the right target
|
||||
local result = {}
|
||||
|
||||
@ -3095,15 +3104,27 @@ function yl_speak_up.talk(self, clicker)
|
||||
return
|
||||
end
|
||||
|
||||
local pname = clicker:get_player_name()
|
||||
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
|
||||
-- show a formspec to other players that this NPC is busy
|
||||
if(not(yl_speak_up.may_edit_npc(clicker, self.yl_speak_up.id))) then
|
||||
-- show a formspec so that the player knows that he may come back later
|
||||
minetest.show_formspec(pname, "yl_spaek_up:ignore",
|
||||
"size[6,2]"..
|
||||
"label[1.2,0.0;"..minetest.formspec_escape((self.yl_speak_up.npc_name or "This NPC")..
|
||||
" [muted]").."]"..
|
||||
"label[0.2,0.5;Sorry! I'm currently busy learning new things.]"..
|
||||
"label[0.2,1.0;Please come back later.]"..
|
||||
"button_exit[2.5,1.5;1,0.9;ok;Ok]")
|
||||
return
|
||||
end
|
||||
-- allow the owner to edit (and subsequently unmute) the npc
|
||||
minetest.chat_send_player(pname, "This NPC is muted. It will only talk to you.")
|
||||
end
|
||||
|
||||
local npc_id = self.yl_speak_up.id
|
||||
local n_id = "n_" .. npc_id
|
||||
local pname = clicker:get_player_name()
|
||||
|
||||
yl_speak_up.speak_to[pname] = {}
|
||||
yl_speak_up.speak_to[pname].n_id = n_id -- Memorize which player talks to which NPC
|
||||
|
Loading…
Reference in New Issue
Block a user