Hi, all!
I'm using Twine 2.1.3 and SugarCube 2.18.0.
This doesn't work:
<<set _outcome to 0>>
<<for _outcome == 0>>
Loop
<<if _outcome == 1>>
$victory
<<goto $victory>>
<</if>>
<<set _outcome to 1>>
_outcome
<</for>>
Apparently, _outcome is set to 1 at the end of the first iteration, but the condition "_outcome == 1" is not recognized. Ridiculous syntax problem, of course, but where ?
Thanks in advance.
Comments
So your output looks like this:
... But the for loop only iterates once. Depending on what you want to do, you can solve this a few different ways, for example:
Will probably do what you want. There may be other syntax issues; I didn't test this code.
Also, obviously I don't have the knack with SugarCube :-). But it will come...
Do you mean that this example code took several seconds? Or did you plug something like this into another chunk of code? If it's the latter and you're game, you can post the code if you want and maybe we can put our heads together and make it more efficient.
Thanks for your help, anyway :-)
I can't test it right now, but I guess since I didn't initially terminate the for loop it kept running through even after the goto call since the macro never actually terminated. I'd imagine it hit the limit and then was able to complete the goto. It might have even thrown an error, but the error wouldn't be visible because of the immediate passage change. I don't know for sure, though.
Assuming this is a combat loop, or something similar, and _outcome will be 0 until victory (1) or defeat (2?) has been achieved, then I'd recommend something like the following: A bit redundant perhaps, however, it keeps the <<goto>> out of the line of fire—loop.
As an alternative. If $victory is simply the passage to send the player to, then I'd recommend simply using _outcome instead, as you only need one state variable in that case and you don't want to create story variables you don't need. For example: Again, the <<goto>> is kept separate from the loop.