Page 1 of 1

Sequencer Increment Variable

Posted: Fri Dec 10, 2021 3:57 am
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?)

Re: Sequencer Increment Variable

Posted: Fri Dec 10, 2021 6:58 am
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.

Re: Sequencer Increment Variable

Posted: Fri Dec 10, 2021 9:29 am
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.

Re: Sequencer Increment Variable

Posted: Fri Dec 10, 2021 9:40 am
by michaelheiml
Great - works -thanks!

Re: Sequencer Increment Variable

Posted: Fri Dec 10, 2021 9:45 am
by Tony Li
Happy to help!