Need syntax check. Why doesn't this work?

SexigeOpe

Virgin
Joined
Sep 6, 2002
Posts
37
Here's a snippet from what I'm currently writing.
What I want to happen in this stitch is:
  1. The four first choices are presented.
  2. Player picks a choice.
  3. The choice is executed.
  4. "Text 1" is displayed above the remaining choices.
  5. Player picks a second choice.
  6. The choice is executed.
  7. Global variable "GotBeer" is set, "Text 2" is displayed, redirection to tunnel "flirtJ".
As coded "Text 1" shows up as expected.
"Text 2" does not show up!
I try implementing the "Advanced" instructions from Github.
I've tried different comparators to the boothloop check; ==, =, <. Seems to make no difference. The text doesn't show up!
Code:
= boothloop
{boothloop == 2:
~ GotBeer = true
"Text 2"
-> flirtJ ->
}
* I look closer at the woman at the bar.
-> GoTunnel ->
* I look closer at the trio.
-> GoTunnel ->
* I look closer at the woman in the booth.
-> GoTunnel ->
* I wait for my {Hungry:food and} beer.
+ {GotBeer}I'm done in this booth.
-> WhereTo
- {!"Text 1"}
-> boothloop
Where
 
Player picks a choice.
I assume it's the "I wait..." choice, since the others divert out of the loop.

Player picks a second choice.
Which one? At this point, if I'm not mistaken, the only remaining choices are the first three that divert to GoTunnel. The "I wait..." has just been expended, and GotBeer is still false since boothloop equals to 1 at this point.

I think what you meant is to set GotBeer to true when the "I wait..." option is chosen:

Code:
* I wait for my {Hungry:food and} beer.
~ GotBeer = true

but then I'm not sure how you want to handle the WhereTo diversion which also requires GotBeer.
 
I assume it's the "I wait..." choice, since the others divert out of the loop.
No, the others divert to (different, I changed their names for this thread) tunnels, leading right back to the same line (after events). Those work as intended.
[ The command "-> TunnelX ->" means: First arrow diverts to (tunnel) knot/stitch named "TunnelX". Second arrow acts as landing point, returning from from "TunnelX".]
The basic idea with my code snippet is to have this list of choices (diverting to temporary detours) to go through one after another in random order.
After concluding two of them there's a possibility to to take another detour (diverted from "Text 2" and not listed) before returning to the list and either do the remaining choices or leave.
 
No, the others divert to (different, I changed their names for this thread) tunnels, leading right back to the same line (after events). Those work as intended.
[ The command "-> TunnelX ->" means: First arrow diverts to (tunnel) knot/stitch named "TunnelX". Second arrow acts as landing point, returning from from "TunnelX".]
The basic idea with my code snippet is to have this list of choices (diverting to temporary detours) to go through one after another in random order.
After concluding two of them there's a possibility to to take another detour (diverted from "Text 2" and not listed) before returning to the list and either do the remaining choices or leave.
Ah, got it; that was the part I must've missed reading through the docs you linked. So, -> Foo -> is basically a procedure call to Foo.

In this case, I suspect the problem might be right there: these temporary diversions may not count as visiting bootloop again, so it never reaches 2. I'd just add copious {bootloop} statements at every branch to track the state of the variable (or use some other debugging facilities of Ink to watch variables, if it has any) to figure out if that's the case.
 
EDITED:
I figured out what the problem is:
When using NameOfStitch as a variable one must use the form NameOfKnot.NameOfStitch, even inside the knot. {<- Edit: Possibly, but wasn't the real problem.}
Main problem is that the variable NameOfStitch doesn't go up when called recursive, only when called from another stitch/knot.
My code call for a variable that stay constant and therefore doesn't work.
Working solution shown in next post.
 
Last edited:
Corrected (working) code:
Code:
(previous stitch)
-> boothloop(0) // Sets x=0.

= boothloop(x) // Start of stitch.
{x == 2: // Activates when x=2.
~ GotBeer = true
"Text 2"
-> flirtJ ->
}
* I look closer at the woman at the bar.
-> GoTunnel ->
* I look closer at the trio.
-> GoTunnel ->
* I look closer at the woman in the booth.
-> GoTunnel ->
* I wait for my {Hungry:food and} beer.
+ {GotBeer}I'm done in this booth.  //  This choice becomes visible after running "flirtJ"
-> WhereTo
- {!"Text 1"} // Prints "Text 1" after processing first pick.
-> boothloop(x+1)  // Adds 1 to x and runs stitch again.
 
Last edited:
Back
Top