Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

[Sugarcube 2] Is it possible to change a variable value without refreshing the passage?

$
0
0
I'm trying to do something like this:
(assuming $shipSpeed = "5s")
<<click "Faster">>
<<set $shipSpeed = "1s">>
<</click>>
<<click "Slower">>
<<set $shipSpeed = "10s">>
<</click>>

Distance from Earth: <span id="countdown">10</span> million miles
<<silently>>
<<timed $shipSpeed>><<replace "#countdown">>9<</replace>>
<<next>><<replace "#countdown">>8<</replace>>
<<next>><<replace "#countdown">>7<</replace>>
<<next>><<replace "#countdown">>6<</replace>>
<<next>><<replace "#countdown">>5<</replace>>
<<next>><<replace "#countdown">>4<</replace>>
<<next>><<replace "#countdown">>3<</replace>>
<<next>><<replace "#countdown">>2<</replace>>
<<next>><<replace "#countdown">>1<</replace>>
<<next>><<goto Earth>>
<</timed>>
<</silently>>

I understand this code would "work" if I put a <<goto "this passage">> inside the click macro, or using this: state.display(state.active.title, null, "back")
the problem is in both cases it goes back to 10 in the countdown, or if I had a bunch of click-replace it would undo all the "replaces", <<timedcontinue Xs>> text would disappear and start showing again, etc. It's the third time I hit this wall and I was wondering if there is a solution.

Viewing all articles
Browse latest Browse all 1844

Trending Articles