SimStatus check failed in dialogue entry script

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

SimStatus check failed in dialogue entry script

Post by joeylu »

Hi Tony
Say that I have a conversation, has a serials dialogue entries
if I add something in the "script" input field in any dialogue entry like

Code: Select all

if (Dialog[thisID].SimStatus =="Untouched") then Variable["test"] = Variable["test"] + 1 end;
it does not work, but if I take out the simstatus condition check, the variable adds 1 correctly

I have tried restarted Unity project and deleted library, still no working

so am I doing anything wrong by checking the SimStatus in the script field? or am I missing anything from the setting?
another question is that how do I do unity debug logging from the script field? can I call Debug.Log(Dialog[thisID].SimStatus) or something similar? so I can get the status in console

tks
User avatar
Tony Li
Posts: 21049
Joined: Thu Jul 18, 2013 1:27 pm

Re: SimStatus check failed in dialogue entry script

Post by Tony Li »

Hi,

Are there any errors or warnings in the Console window when that dialogue entry node runs?
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

Re: SimStatus check failed in dialogue entry script

Post by joeylu »

no error, nor warning

let me give me a few details and my debug data:

I have created a simple conversation as in the attachment screenshot
both in "How are you" and "ok" nodes, i added following script:

Code: Select all

if (Dialog[thisID].SimStatus =="Untouched") then Variable["test"] = Variable["test"] + 1 end;
the result is the variable "test" value doesn't get increased
however, if I take out the condidtion, just use

Code: Select all

Variable["test"] = Variable["test"] + 1
it works.

I also tried doing some debugs from unity script (I don't know how to add logging directly from the dialogue entry script field)

I added following line inside OnConversationLine() function

Code: Select all

Debug.Log(subtitle.dialogueEntry.outgoingLinks[0].destinationDialogueID + " : " + DialogueLua.GetSimStatus(subtitle.dialogueEntry.outgoingLinks[0].destinationConversationID, subtitle.dialogueEntry.outgoingLinks[0].destinationDialogueID));
reason I use destinationConversationID and destinationDialogueID is that in OnConversationLine() method, checking current dialogue entry simstatus always returns "WasDisplayed", guess the simstatus was updated before executing the OnConversationLine()

result of my debug is, both returns "WasOffered", even the entry hasn't played yet.

so I went back to the dialogue editor, replace the above script from condition "Untouched" to "WasOffered", still not working

lastly, if I replace the condition to "WasDisplayed", it's working, but obliviously, this is not what I want

am I missing anything? tks
Attachments
temp.jpg
temp.jpg (22.44 KiB) Viewed 1080 times
User avatar
Tony Li
Posts: 21049
Joined: Thu Jul 18, 2013 1:27 pm

Re: SimStatus check failed in dialogue entry script

Post by Tony Li »

Hi,

That all works correctly for me. I tested with "WasOffered" since blue nodes (player responses) are always marked WasOffered as soon as they're shown in a response menu. Maybe I'm failing to understand some step that we're doing differently. Would you please send a reproduction project to tony (at) pixelcrushers.com along with reproduction steps that I should follow?
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

Re: SimStatus check failed in dialogue entry script

Post by joeylu »

Hi Tony, I have sent you the project to support (at) pixelcrushers.com, tks
User avatar
Tony Li
Posts: 21049
Joined: Thu Jul 18, 2013 1:27 pm

Re: SimStatus check failed in dialogue entry script

Post by Tony Li »

Thanks for sending the repro project. The dialogue entry node's Script won't run until you've clicked on the response. Since you've clicked on the response, the SimStatus will have changed to WasDisplayed. This is why you need to use WasDisplayed.
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

Re: SimStatus check failed in dialogue entry script

Post by joeylu »

Understood now, I was thinking to use simstatus to do the following logic:
When a response menu was chosen, conditionally check if this menu has been chosen before, if yes, don't run the script (in my case, add some value to a variable), and if no, add value to that variable.
According to your explanation, if the menu is chosen, the SimStatus will always return WasDisplayed, therefore, using SimStatus as the condition seems not possible, would you provide me some alternative ways to achieve the logic? tks
User avatar
Tony Li
Posts: 21049
Joined: Thu Jul 18, 2013 1:27 pm

Re: SimStatus check failed in dialogue entry script

Post by Tony Li »

Hi,

Add a script with an OnConversationResponseMenu() method to your Dialogue Manager GameObject. This method is called before the response menu is shown. You can record a list of which responses haven't been chosen before. Then register a C# method with Lua that only does its work if the response is in the list of those that haven't been chosen before. Example:

Code: Select all

private List<DialogueEntry> notChosenBefore = new List<DialogueEntry>();
private DialogueEntry currentEntry;

void OnConversationResponseMenu(Response[] responses) // Called when preparing the menu.
{
    notChosenBefore.Clear();
    foreach (var response in responses)
    {
        if (DialogueLua.GetSimStatus(response.destinationEntry) != DialogueLua.WasDisplayed)
        {
            notChosenBefore.Add(reponse.destinationEntry);
        }
    }
}

void OnPrepareConversationLine(DialogueEntry entry) // Called when about to use an entry (e.g., selected from menu).
{
    currentEntry = entry;
}

void Awake()
{
    Lua.RegisterFunction(nameof(DoTheThing), this, SymbolExtensions.GetMethodInfo(() => DoTheThing()));
}

void DoTheThing()
{
    if (!notChosenBefore.Contains(currentEntry))
    {
        // do the thing
    }
}
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

Re: SimStatus check failed in dialogue entry script

Post by joeylu »

tks for the idea :)
one last thing, the example you gave is a slightly different against the doc for registering Lua, so I don't know how to pass parameters like in the doc example, any idea that if I can pass parameter with your SymbolExtensions.GetMethodInfo()? tks

ref: https://www.pixelcrushers.com/dialogue_ ... ripts.html
User avatar
Tony Li
Posts: 21049
Joined: Thu Jul 18, 2013 1:27 pm

Re: SimStatus check failed in dialogue entry script

Post by Tony Li »

Yes, you can pass parameters exactly like in the docs. The example C# method that I used just happened to not have any parameters, so I didn't include any. Also, I use nameof(DoTheThing) instead of "DoTheThing" to help prevent typos. The documentation is written for maximum compatibility with older versions of Unity that use .NET versions that don't support nameof(). But either way is fine.
Post Reply