Apply Effect after click on continue on the last dialogue node

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
AJWantsToSleep
Posts: 18
Joined: Wed Jun 19, 2024 2:44 pm

Apply Effect after click on continue on the last dialogue node

Post by AJWantsToSleep »

Hey, this will hopefully be my last question for today:

On the last node of the conversation i added the following Effect to the script section.

Code: Select all

AddVisitor(1);
Variable["Alert"] = "Visitor 
+1"
My problem is that I have a cancel and a back button. If I have reached the last node and use these buttons and then go to the last node again, the effect will be applied multiple times.
The effect should only be applied once after I have pressed the Continue Button on the last part of the Dialogue.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Apply Effect after click on continue on the last dialogue node

Post by Tony Li »

Hi,

You can use another variable in your Script:

Code: Select all

if (Variable["AddedVisitor"] ~= true) then
  Variable["AddedVisitor"] = true
  AddVisitor(1)
  Variable["Alert"] = "Visitor +1"
end
Since a Lua variable defaults to nil if it isn't defined yet, you don't even need to add this "AddedVisitor" variable to your dialogue database ahead of time.
Post Reply