Howdy, Stranger!

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

Using Switch in Sugarcube

I cannot figure out how to use <<switch>> in Sugarcube 2.0

Everytime I try, I get "Error: macro <<switch>> does not exist" followed "Error: macro <<case>> does not exist". I have no idea what I'm doing wrong. Here's a code sample.
Enter player name: <<textbox "$player.name" "" autofocus>>

Choose your pronoun: <<switch $pronoun>>

<<case "he, his">>
<<set $player.pronoun to 1>>

<<case "she, her">>
<<set $player.pronoun to 2>>

<<case "they, theirs">>
<<set $player.pronoun to 3>>
<</switch>>
Please advise

Comments

  • You are likely using an out of date version of SugarCube 2. The <<switch>> macro requires at least v2.7.2.
  • I'm using the version of Sugarcube that's online at the Twine online tool. But I can easily fix this. Thanks for the heads up.
  • housellama wrote: »
    I'm using the version of Sugarcube that's online at the Twine online tool.
    That is SugarCube 1, specifically v1.0.35, not any version of SugarCube 2.
  • You're right. I updated to Sugarcube 2 and it worked first time. Thank you.
Sign In or Register to comment.