Page 1 of 1

Apply Effect after click on continue on the last dialogue node

Posted: Wed Jul 03, 2024 11:39 am
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.

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

Posted: Wed Jul 03, 2024 3:30 pm
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.