Page 1 of 1

How to Get Current Dialogue Entry ID?

Posted: Mon Jul 15, 2024 8:07 am
by JonGear
Context:

I have added two new fields to Dialogue Entries called "Points" and "Turn Cost".

I want to access the current dialog entry ID so that I can launch a Lua script.

====
AddPoints(Variable["Conversant"], GetEntryNumber(ID, "Points"));
DebugLog(GetEntryNumber(ID, "Points"));
====

Bonus Question: How to make each dialogue entry ALWAYS launch a Lua script?

Re: How to Get Current Dialogue Entry ID?

Posted: Mon Jul 15, 2024 3:42 pm
by Tony Li
Hi,

Add a C# script with an OnConversationLine(Subtitle) method to the Dialogue Manager. For example, something like:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    int ID = subtitle.dialogueEntry.id;
    Lua.Run($"AddPoints(Variable['Conversant'], GetEntryNumber(ID, 'Points')); DebugLog(GetEntryNumber({ID}, 'Points'))");
} 
Although if AddPoints(), GetEntryNumber(), etc., are already C# methods that you've registered with Lua, it might be simpler to just call those C# methods directly in your OnConversationLine() method instead of running them as Lua code.

The current dialogue entry ID is in subtitle.dialogueEntry.id.

Re: How to Get Current Dialogue Entry ID?

Posted: Mon Jul 15, 2024 11:44 pm
by JonGear
Thank you very much, Toni!

Re: How to Get Current Dialogue Entry ID?

Posted: Tue Jul 16, 2024 8:45 am
by Tony Li
Glad to help!