How to Get Current Dialogue Entry ID?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
JonGear
Posts: 6
Joined: Mon Jul 15, 2024 8:04 am

How to Get Current Dialogue Entry ID?

Post 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?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to Get Current Dialogue Entry ID?

Post 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.
JonGear
Posts: 6
Joined: Mon Jul 15, 2024 8:04 am

Re: How to Get Current Dialogue Entry ID?

Post by JonGear »

Thank you very much, Toni!
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to Get Current Dialogue Entry ID?

Post by Tony Li »

Glad to help!
Post Reply