The following code uses LuaObserver to monitor variables and quest states, and execute common delegates
There are two questions.
1. Is it correct to use this code to monitor multiple variables and do the same thing?
2. The delegate is not executed when the quest is changed. Is there a wrong way to write it?
Thank you in advance for your help.
Monitoring quests with LuaObserver
Re: Monitoring quests with LuaObserver
Hi,
That's fine to observe the variable value. Since you've set the frequency to EndOfConversation, it will only check the value at the end of conversations, which is efficient.
To observe the quest state, change the expression to: Quest['FindtheFirstKey'].State
Alternatively, you can add a script to the Dialogue Manager that has an OnQuestStateChange(title) method, or add a Dialogue System Events component and use the OnQuestStateChange() UnityEvent.
That's fine to observe the variable value. Since you've set the frequency to EndOfConversation, it will only check the value at the end of conversations, which is efficient.
To observe the quest state, change the expression to: Quest['FindtheFirstKey'].State
Alternatively, you can add a script to the Dialogue Manager that has an OnQuestStateChange(title) method, or add a Dialogue System Events component and use the OnQuestStateChange() UnityEvent.
Re: Monitoring quests with LuaObserver
I was able to run the delegate even when I changed the Quest!
However, when I delete the delegate, I get an error.
The order of "AddLuaObserver" changes the way the error occurs.
If I write Quest first, an error occurs when I delete the variable when it changes.
When Variable is written first, an error occurs if it is deleted when the quest changes.
However, when I delete the delegate, I get an error.
The order of "AddLuaObserver" changes the way the error occurs.
If I write Quest first, an error occurs when I delete the variable when it changes.
When Variable is written first, an error occurs if it is deleted when the quest changes.
Re: Monitoring quests with LuaObserver
Hi,
By "delete the delegate" do you mean DialogueManager.RemoveLuaObserver?
Would you please click on the error, press Ctrl+C (Cmd+C on Mac) to copy it to the clipboard, and paste it into a reply? This will help me confirm what I think the error is so I can provide a fix.
By "delete the delegate" do you mean DialogueManager.RemoveLuaObserver?
Would you please click on the error, press Ctrl+C (Cmd+C on Mac) to copy it to the clipboard, and paste it into a reply? This will help me confirm what I think the error is so I can provide a fix.
Re: Monitoring quests with LuaObserver
Yes, I get an error when I run DialogueManager.RemoveLuaObserver.
Code: Select all
ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <695d1cc93cca45069c528c15c9fdd749>:0)
PixelCrushers.DialogueSystem.LuaWatchList.NotifyObservers () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Utility/LuaWatchList.cs:65)
PixelCrushers.DialogueSystem.LuaWatchers.NotifyObservers (PixelCrushers.DialogueSystem.LuaWatchFrequency frequency) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/LuaWatchers.cs:153)
PixelCrushers.DialogueSystem.DialogueSystemController.OnEndConversation (PixelCrushers.DialogueSystem.ConversationController endingConversationController) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/DialogueSystemController.cs:1302)
PixelCrushers.DialogueSystem.ConversationController.Close () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Controller/ConversationController.cs:174)
PixelCrushers.DialogueSystem.ConversationController.OnFinishedSubtitle (System.Object sender, System.EventArgs e) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Controller/ConversationController.cs:287)
PixelCrushers.DialogueSystem.ConversationView.FinishSubtitle () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:418)
PixelCrushers.DialogueSystem.ConversationView.HandleContinueButtonClick () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:390)
PixelCrushers.DialogueSystem.ConversationView.OnConversationContinue (PixelCrushers.DialogueSystem.IDialogueUI dialogueUI) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:373)
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.AbstractDialogueUI:OnContinue() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/UI/Abstract/Dialogue/AbstractDialogueUI.cs:356)
PixelCrushers.DialogueSystem.TextAnimatorContinueButtonFastForward:OnFastForward() (at Assets/Plugins/Pixel Crushers/Dialogue System/Third Party Support/Text Animator Support/TextAnimatorContinueButtonFastForward.cs:62)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)
Re: Monitoring quests with LuaObserver
Thank you. That confirms that issue. I'll provide a fix by tomorrow.
Re: Monitoring quests with LuaObserver
You work fast!
It worked exactly right!
Thank you!
It worked exactly right!
Thank you!
Re: Monitoring quests with LuaObserver
Glad to help! Thanks for confirming that it works in your project.