Set a variable to new value before moving to next scene?

Twine Version: 2.8.1.0
Story Format: Sugarcube 2.36.1

Hello, newbie here. How do I change a variable value when user clicks on a choice before moving to the next node, especially when both nodes lead to the same destination

You decide your course of action.

<<set $unaware = false>>

// change value of $unaware before moving to next scene
[[nextScene<- You keep him unaware.]]
[[nextScene<- You keep him aware.]]

// so that I don't have to make separate nodes just for a quick branching
[[scene1Aware<- You keep him aware of what's happening.]]
[[scene1Unaware<- You keep him oblivious to what's happening.]]

Because ideally in the next scene I just want to do an if else statement to make the text dynamic (without having to write the same stuff in the other node). I only have experience in Choicescript so this one’s much less easy to grasp than the former. Thanks for any help!

You can do it in links:

[[Text|Passage][$var to true]]

You can find it in the documentation here

Otherwise, you have the <<link>> macro, inside of which you can use the <<set>> macro

1 Like

Hi

You can add a ‘setter’ to a link to set any variables. See also the SugarCube docs on links: SugarCube v2 Documentation (motoslave.net)

Then you can create links setting your variable, e.g.

[[You keep him unaware.|nextScene][$unaware to true]]
[[You keep him aware.|nextScene][$unaware to false]]

Ack Manon beat me to it lol ah well…

1 Like

You might find this guide helpful then :wink:

1 Like