Dialogue System Trigger On Start not registering LUA variables on load

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Dialogue System Trigger On Start not registering LUA variables on load

Post by cptscrimshaw »

Hi Tony,

I'm running into an issue where I have a Dialogue System Trigger that has a couple of LUA conditions to start a conversation (this conversation should happen at the beginning of the game and no other time). I set my own LUA variable "GameStart" to true in the conversation. But when I quit and reload the game, it seems to check the state of the variable before LUA has initialized it (see screenshot of my watch showing the variable true, but the dialogue system trigger registering it as false). Any ideas why this might be happening?

I also am attaching a screenshot of my script execution order, as I know we messed with this in the past to fix things up. Hoping I'm just doing something stupid. :)

Thanks!

https://ibb.co/VT3vFw1
https://ibb.co/PzF9R9Z
https://ibb.co/1zLLzg1
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System Trigger On Start not registering LUA variables on load

Post by Tony Li »

Hi,

Try changing your Dialogue System Trigger from OnStart to OnSaveDataApplied.

When loading a saved game or changing scenes, it can take one or more frames to apply the saved data to the scene. If you set the Dialogue System Trigger to OnSaveDataApplied, it will wait until the save data has been applied (e.g., variable values have been restored). If you're not loading a game or changing scenes, it will wait the same number of frames as applying data would take, which is specified in the Save System component's Frames To Wait Before Apply Data field.
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Re: Dialogue System Trigger On Start not registering LUA variables on load

Post by cptscrimshaw »

I don't see OnSaveDataApplied as a possible option for the Dialogue System Trigger:
https://ibb.co/7bkcZ8x

I'm on version 2.2.19.
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System Trigger On Start not registering LUA variables on load

Post by Tony Li »

The Package Manager is broken in some versions of Unity. Please check the file Plugins / Pixel Crushers / Dialogue System / _README.txt to confirm that it really downloaded version 2.2.19. If not, see: How To: Download Updates With Broken Package Manager.
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Re: Dialogue System Trigger On Start not registering LUA variables on load

Post by cptscrimshaw »

Thanks, you are correct that the package manager was lying to me about to me about the version :)

Quick question. Every time I import a new version of DS, it overwrites my custom prefab of the Dialogue Manager (that is saved outside of the DS plugin folder). All the settings are back to default, added components are missing, and any child gameobjects are gone too. Is there something I can do to prevent this?
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System Trigger On Start not registering LUA variables on load

Post by Tony Li »

Save your customized Dialogue Manager prefab as a prefab variant or a new prefab.

Unity keeps track of files by internal identifiers called GUIDs. It doesn't matter where the file is located. If you've just moved the Dialogue Manager prefab to your own folder, it will still have the same GUID, so updates will still overwrite it.

If it's a prefab variant or new prefab, it will have a different GUID, so updates won't touch it.
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Re: Dialogue System Trigger On Start not registering LUA variables on load

Post by cptscrimshaw »

Thanks Tony - The prefab variant didn't work, but duplicating the prefab and renaming worked fine.

Back to the initial problem - I set the dialogue system trigger to "On Save Data Applied" and the conversation is still popping up at the start when I load from a save file. From what I can tell from the debug info, the following is happening:

1. Start game for the first time which plays the conversation. Set the variable "IntroConversationOver" to true at the end of the conversation. The game then switches to a new scene.
2. Quit game.
3. Start game from a saved file. The game starts and briefly starts the conversation before it transitions to load the next scene, "IntroConversationOver" is showing some interesting behavior in the debug info: https://ibb.co/5jMBJKs
4. Then when the scene loads, it continues the conversation it started already and I see the following in the debug info: https://ibb.co/R0W7GpJ

There are several Dialogue System Triggers on the NPC:
- One to turn off the other dialogue system trigger components on save data applied (which seems to be happening too late to be helpful): https://ibb.co/JtzRVgV
- Another to start the conversation the first time the game loads: https://ibb.co/9vGwTJG
- A final one to change scenes after the conversation is over (this is probably not important for this issue and seems to work fine): https://ibb.co/hs84LVk

Thanks for the help so far!
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System Trigger On Start not registering LUA variables on load

Post by Tony Li »

Hi,

Make sure your Dialogue Manager has a Dialogue System Saver component.

If you temporarily set the Dialogue Manager's Other Settings > Debug Level to Info, then when you load a game or change scenes the Dialogue System Saver will log what it's restoring, something like:

Code: Select all

Dialogue System: Lua(Variable={Alert="", enemiesKilled=0, hasLaunchCodes=false, password="", 
Actor="", Conversant="", ActorIndex="", ConversantIndex=""}; 
Item["Get_the_Launch_Codes"].State="unassigned"; Item["Get_the_Launch_Codes"].Track=true; ...
That should help you identify when the variable values are being restored, and hopefully pinpoint the timing issue.

If that doesn't help, please feel free to send a reproduction project to tony (at) pixelcrushers.com.
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System Trigger On Start not registering LUA variables on load

Post by Tony Li »

Hi Rick,

Thanks for sending the reproduction project. I replied with what appears to be going on. The TL;DR is: Put the Pixel Crushers Save System in a scene that doesn't have Dialogue System Triggers set to OnStart/OnSaveDataApplied, and play that scene to resume your saved game.
Post Reply