Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

in passage link

I have the following in a passage called Sandbox:
<<print "$case1_done = " + $case1_done>> [[Toggle|Sandbox][<<if $case1_done is true>><<set $case1_done = false>><<else>><<set $case1_done = true>><<endif>>]]

The idea is a simple true/false debug/toggle for key milestones in the story.

It doesn't work.  It always stays false which is the initial value.  What am i doing wrong?  Or is there a better way to toggle?

Comments

  • Based on the wiki, I believe that it does not support conditions, only the setting of variables.
  • yep, that's what I found.
    Pulling the condition out of the link works:
    <<print $case1_done>>
    <<if $case1_done is "true">>
    [[Toggle|Sandbox][$case1_done = "false"]]<<else>>
    [[Toggle|Sandbox][$case1_done = "true"]]<<endif>>

    (I changed the original "print" line to make it work also)
  • Can you not use <<display>> ?

    Create a passage called togglecheck or whatever, and set it's tag to nobr.  Put the code for the toggle check in that, and then when you need it simply use &lt;&lt;display &quot;togglecheck&quot;&gt;&gt;.

    Have a look at the attachment. :)
  • You can do what you wanted to initially, however, the setter component requires Twine JavaScript syntax, not Twine wiki syntax.

    As long as $case1_done is an actual boolean (true or false), then this should work:

    [[Toggle|Sandbox][$case1_done to not $case1_done]]
    If you're using a string, for some odd reason, then this should work:

    [[Toggle|Sandbox][$case1_done to ($case1_done is "true" ? "false" : "true")]]
Sign In or Register to comment.