Page 1 of 1

Unable to correctly check the active dialogue node via OnExecute and change its field value

Posted: Fri Jul 18, 2025 4:39 am
by SongsForgotten
Hello,

I have some issues related to the notification system in my game. On specific dialogue entry nodes, I will use the Scene Event On Execute() method to instantiate notifications via a gameobject's C# script. What I would like to do is to be able to check if a notification has already been instantiated previously on that node, and in such case, ignore the function to instantiate a notification. I have tried to pursue this by adding a new boolean field (notificationWasShown) on those specific nodes and checking it whenever a notification is to be instantiated.

I am having two issues with this:

1) It seems that the OnExecute() method is called before the system actually knows that it has switched from the previous node to the current one. Because of this, I am unable to use the

Code: Select all

DialogueManager.currentConversationState.subtitle.dialogueEntry
method to get the currently active conversation node and check its boolean field value.

2) Secondly, I couldn't find any clear documentation on how the change a boolean on a dialogue node field via C#. Of course I can use other methods, but this would be cleanest, as the code is run anyways. I've looked into the

Code: Select all

DialogueLua.SetVariable()
and

Code: Select all

Field.SetValue
methods, but neither seems to be valid in my case?

Thank you in advance for your response.

Re: Unable to correctly check the active dialogue node via OnExecute and change its field value

Posted: Fri Jul 18, 2025 9:38 am
by Tony Li
Hi,

You can use SimStatus tracking to keep track of which dialogue entries have already been displayed. To enable it, tick the Dialogue Manager GameObject's Other Settings > Include SimStatus.

The Dialogue System updates DialogueManager.currentConversationState to the current dialogue entry after the dialogue entry's OnExecute() event and Script field because OnExecute()/Script may change what ends up in DialogueManager.currentConversationState -- for example, changing some variable values that are included in the Dialogue Text. However, the Dialogue System does set the Lua variable "thisID" to the dialogue entry's ID before OnExecute()/Script.

Within a Script field, to check if a dialogue entry has been displayed previously, check Dialog[thisID].SimStatus == "WasDisplayed". Example:

Code: Select all

if (Dialog[thisID].SimStatus ~= "WasDisplayed") then
    ShowNotification()
end
The Script above only calls ShowNotification() if the dialogue entry has not been previously displayed. It assumes ShowNotification() is a C# method that's been registered with Lua.

Within OnExecute(), to check if a dialogue entry has been displayed previously:

Code: Select all

int thisID = Lua.Run("return thisID").asInt;
bool wasDisplayed = DialogueLua.GetSimStatus(DialogueManager.lastConversationID, thisID) == DialogueLua.WasDisplayed;
if (!wasDisplayed) ShowNotification();