Hi,
I'm very new to Twine. I have some bugs in my first story, and I think they MIGHT be because I'm using goto incorrectly. I assumed that when goto takes you to another passage, it forgets about any instructions that come after the goto. So you wouldn't need to use (else:) because it would never read that line anyway. But now I'm wondering if that's wrong? Might it eventually come back and execute code after the goto?
Just for reference, here's a simplified version of what I'm trying to do. It loops back to the "Test Whose Turn" passage multiple times:
TEST WHOSE TURN
(if:$badguyhp<1)[(goto:"You Win")]
(if:$hitpoints<1)[(goto:"Aargh You Lose")]
(if:((random:1,10)+$whoseturn)<5)[(goto:"Enemy Turn")]
Attack Bad Guy!
Run Away!
ENEMY TURN
(if:$whoseturn<0)[(set:whoseturn to 0)]
(set:$whoseturn to $whoseturn+1)
(set:$hitpoints to $hitpoints-(random:1,5))
(goto:"Test Whose Turn")
ATTACK BAD GUY
(if:$whoseturn>0)[(set:whoseturn to 0)]
(set:$whoseturn to $whoseturn-1)
(set:$badguyhp to $badguyhp-(random:1,5))
(goto:"Test Whose Turn")
... i.e. with every loop where the bad guy gets two turns, or three turns, etc., it becomes more likely that the player gets to go next (and vice-versa).
There's a lot of other code involved so the problems might be something else entirely, but this is my best guess so far! Thank you in advance!
Comments
a. Start b. Result ... and as expected the output was: Var equals: A
So based on the above it would appear that the (goto:) macro interrupts the processing of the current passage and instantly moves the Reader to the target passage.