Lua Observer not running Delegate

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Strig
Posts: 40
Joined: Fri Aug 21, 2020 12:33 pm

Lua Observer not running Delegate

Post by Strig »

Hello, I'm trying to implement a system that detects where an NPC is supposed to be and places them in the correct area. The system works fine, but now I want to implement a symple fadeout in conjunction with Playmaker.

In order to do that, I added a Lua Observer to a simple script on the NPC:
Captura de Tela (47).png
Captura de Tela (47).png (18.73 KiB) Viewed 363 times
It gets the NPC's "CurrentLocation" field every time a conversation ends and then sends to the delegate:
Captura de Tela (48).png
Captura de Tela (48).png (19.34 KiB) Viewed 363 times
Which in turn is supposed to send an event to the FSM in Playmaker. But the delegate is doing nothing at all: even the Debug Log isn't appearing. The documentation didn't give me any answers in regards to this, so I wonder if I'm invoking the delegate in a wrong way.

I can also confirm that the Actor Field isn't the problem, as it's used for other functions and works just fine for those. The change being undetected is also a possibility, but I do know that the Field is changing because it's also being used for other things. Additionally, running it on Update also gave me no results.
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Lua Observer not running Delegate

Post by Tony Li »

Hi,

Try this line:

Code: Select all

DialogueManager.AddLuaObserver($"Actor[\"{DialogueLua.StringToTableIndex(nameNPC)}\"].CurrentLocation", LuaWatchFrequency.EndOfConversation, LocationChanged);
(Edit: Adding missing quotes.)
Strig
Posts: 40
Joined: Fri Aug 21, 2020 12:33 pm

Re: Lua Observer not running Delegate

Post by Strig »

Hi, thanks for the quick answer!

I tried the code, but it throws an exception, as if the variable isn't on the Actor FIelds. But not only it is there, it even gets printed by other scripts without any problem.

Code: Select all

Dialogue System: Lua code 'return Actor[NPC.CurrentLocation]' threw exception 'Lookup of field 'CurrentLocation' in the table element failed because the table element itself isn't in the table.'
UnityEngine.Debug:LogError(Object)
PixelCrushers.DialogueSystem.Lua:RunRaw(String, Boolean, Boolean) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:226)
PixelCrushers.DialogueSystem.Lua:Run(String, Boolean, Boolean) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:127)
PixelCrushers.DialogueSystem.Lua:Run(String) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:146)
PixelCrushers.DialogueSystem.LuaWatchItem:Check() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Utility/LuaWatchItem.cs:78)
PixelCrushers.DialogueSystem.LuaWatchList:NotifyObservers() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Utility/LuaWatchList.cs:65)
PixelCrushers.DialogueSystem.LuaWatchers:NotifyObservers(LuaWatchFrequency) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/LuaWatchers.cs:153)
PixelCrushers.DialogueSystem.DialogueSystemController:OnEndConversation(ConversationController) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/DialogueSystemController.cs:1023)
PixelCrushers.DialogueSystem.ConversationController:Close() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Controller/ConversationController.cs:172)
PixelCrushers.DialogueSystem.ConversationController:OnFinishedSubtitle(Object, EventArgs) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Controller/ConversationController.cs:281)
PixelCrushers.DialogueSystem.ConversationView:FinishSubtitle() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:397)
PixelCrushers.DialogueSystem.ConversationView:HandleContinueButtonClick() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:369)
PixelCrushers.DialogueSystem.ConversationView:OnConversationContinue(IDialogueUI) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:352)
UnityEngine.Component:SendMessage(String, Object, SendMessageOptions)
PixelCrushers.DialogueSystem.AbstractDialogueUI:OnContinueConversation() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/UI/Abstract/Dialogue/AbstractDialogueUI.cs:366)
PixelCrushers.DialogueSystem.StandardUISubtitlePanel:OnContinue() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/UI/Standard/Dialogue/StandardUISubtitlePanel.cs:390)
Febucci.UI.TextAnimatorPlayer:CustomSkip() (at Assets/Plugins/Febucci/Text Animator/TextAnimatorPlayer.cs:59)
UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
PixelCrushers.<SimulateButtonClick>d__11:MoveNext() (at Assets/Plugins/Pixel Crushers/Common/Scripts/UI/UIButtonKeyTrigger.cs:81)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Lua Observer not running Delegate

Post by Tony Li »

I forgot to add the quotes. Just fixed in my post above.
Post Reply