How to track if a line is read already?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Simon C
Posts: 4
Joined: Sun Mar 09, 2025 6:58 pm

How to track if a line is read already?

Post by Simon C »

Hi, I am implementing two features that need some mechanic to memorize if a line is read already:
1. A skip-through feature that allows the player to jump to the next unread line.
2. Reading some lines will cost player's resource. However, if the line is already read (i.e. the player already paid to read), the player doesn't need to "pay" twice.

I want the line's read/unread status also be savable along with other data as well. Does Dialogue System for Unity provide such metadata on lines to keep track of? Or do I need to implement my own system to do so? Any suggestions?

Thank you!
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to track if a line is read already?

Post by Tony Li »

If you want to track all lines (all dialogue entries) use SimStatus. In code, you can check DialogueLua.GetSimStatus().

If you only need to track a much smaller subset of lines, you might find it easier to use DS variables for those specific dialogue entries.
Simon C
Posts: 4
Joined: Sun Mar 09, 2025 6:58 pm

Re: How to track if a line is read already?

Post by Simon C »

Thanks Tony, this is the script I appended to a node, but it seems raising some syntax errors:

Variable["Option_1_energy_cost"] = -3;
Variable["Option_2_energy_cost"] = -3;
Variable["Option_3_energy_cost"] = 0;
if Dialogue[203].SimStatus == "WasDisplayed" then Variable["Option_2_energy_cost"] = 0

I am not sure which part went wrong as I am very new to Lua... Though I am pretty sure it's line 4 causing the problem. Could you help me to take a look? Thanks!
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to track if a line is read already?

Post by Tony Li »

Hi,

Try this:

Code: Select all

if Dialog[203].SimStatus == "WasDisplayed" then Variable["Option_2_energy_cost"] = 0 end
Lua, unlike C#, expects "end" at the end of an "if" statement, like;

Code: Select all

if (condition) then
  your_code
end
Also, use "Dialog[]", not "Dialogue[]". It's inconsistent with the spelling of "dialogue" elsewhere in the Dialogue System, but this naming convention is a precedent carried over from Chat Mapper. (The Dialogue System shares the same internal data structure as Chat Mapper.)
Post Reply