Sequencer Increment Variable

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
michaelheiml
Posts: 46
Joined: Thu Nov 08, 2018 5:47 am

Sequencer Increment Variable

Post by michaelheiml »

Hi Tony,

please help - I'd like to increment an INT with the sequencer but cannot figure out the right syntax.

Based on the documentation and forum I already tried:

SetVariable("mGuessCounter",GetVariable("mGuessCounter")+1);
SetVariable("mGuessCounter",GetVariable("mGuessCounter").AsInt+1);
SetVariable("mGuessCounter",[var.mGuessCounter]+1);
SetVariable("mGuessCounter",[var=mGuessCounter]+1);
SetVariable("mGuessCounter",mGuessCounter+1);
SetVariable("mGuessCounter","mGuessCounter"+1);

How can I achieve this?

Thanks, Michael

(Sidenote, the Variables View in the DSFU editor does not reflect changes during Runtime so it's a bit hard to debug whether the value is not increased properly or the syntax for checking the value is wrong; is there a reason why the Variables View is not updated during Runtime?)
michaelheiml
Posts: 46
Joined: Thu Nov 08, 2018 5:47 am

Re: Sequencer Increment Variable

Post by michaelheiml »

Hi, I managed to work around it with a custom Lua script that does the incrementation (via DialogueLua.GetVariable), but I think its more complicate than necessary. So if there is still a simpler way with SetVariable in Sequencer, please let me know.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sequencer Increment Variable

Post by Tony Li »

Hi Michael,
michaelheiml wrote: Fri Dec 10, 2021 3:57 amplease help - I'd like to increment an INT with the sequencer but cannot figure out the right syntax.
In general, use the Script field to increment DS variables. Click the "..." button and use the dropdowns to set up the expression. For example (screenshot taken from tutorial):

Image

Or type it directly like this if you don't want to use the point-and-click dropdowns:

Code: Select all

Variable["mGuessCounter"] = Variable["mGuessCounter"] + 1
The Conversation Conditions Tutorial covers this in more detail.

The SetVariable() sequencer command is just a convenience for writers who are writing a sequence and want to quickly set a simple variable value. But the Conditions and Script fields are the main ways to work with DS Variables.
michaelheiml wrote: Fri Dec 10, 2021 3:57 am(Sidenote, the Variables View in the DSFU editor does not reflect changes during Runtime so it's a bit hard to debug whether the value is not increased properly or the syntax for checking the value is wrong; is there a reason why the Variables View is not updated during Runtime?)
The Variables section shows the Initial Value of variables. To see runtime values, use the Watches section. You can set watches on variables, quest states, and any Lua expression you want.
michaelheiml
Posts: 46
Joined: Thu Nov 08, 2018 5:47 am

Re: Sequencer Increment Variable

Post by michaelheiml »

Great - works -thanks!
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sequencer Increment Variable

Post by Tony Li »

Happy to help!
Post Reply