From c14fd79c48da2c9cf1fe112ff2210a171b02785d Mon Sep 17 00:00:00 2001 From: Sokomine Date: Mon, 10 May 2021 19:58:56 +0200 Subject: [PATCH] determine npc_owner ealier so that talking to muted owned npc works --- functions.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/functions.lua b/functions.lua index 6694f36..df56437 100644 --- a/functions.lua +++ b/functions.lua @@ -3104,6 +3104,12 @@ function yl_speak_up.talk(self, clicker) return end + local npc_id = self.yl_speak_up.id + local n_id = "n_" .. npc_id + + -- remember whom the npc belongs to (as long as we still have self.owner available for easy access) + yl_speak_up.npc_owner[ n_id ] = self.owner + 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 @@ -3123,9 +3129,6 @@ function yl_speak_up.talk(self, clicker) 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 - yl_speak_up.speak_to[pname] = {} yl_speak_up.speak_to[pname].n_id = n_id -- Memorize which player talks to which NPC yl_speak_up.speak_to[pname].dialog = load_dialog(n_id) -- Load the dialog and see what we can do with it @@ -3133,8 +3136,6 @@ function yl_speak_up.talk(self, clicker) yl_speak_up.speak_to[pname].option_index = 1 yl_speak_up.speak_to[pname].obj = self.object - -- remember whom the npc belongs to (as long as we still have self.owner available for easy access) - yl_speak_up.npc_owner[ n_id ] = self.owner minetest.show_formspec(pname, "yl_speak_up:talk", get_fs_talkdialog(clicker, n_id)) end