Howdy, Stranger!

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

[Sugarcube] Can I do a statement to ask "if $variable is x or y"?

I'd like to hide a link if the user is on certain pages, Currently I'm doing this like so:
<<if passage() isnot "Inventory">><<if passage() isnot "Info">>[[Appearance]]<</if>><</if>>

So the "Appearance" passage link will only appear if the user is not on the "Info" or "Inventory" screen. It works but it is going to get really messy when I need to add 7 or 8 different links.

I was hoping there was a way to write it so that I could just add an "or" and the game would check if the user was on either passage.

Comments

  • You should always specify the version of the story format you're using, as, yes, it can make a difference.


    Regardless. Try the following:
    <<if passage() isnot "Inventory" and passage() isnot "Info">>[[Appearance]]<</if>>
    
  • Thanks that worked. I didn't even think to include the version of sugarcube I was using because I just thought it was assumed that I would be using the latest version. Anyway thanks.
  • You might want to set a 'special passage' variable when you enter one of those passages and then clear it when you leave. Then check for the variable not being null rather than specific passage names.

    In the special passages:
    <<set $special to 1>>
    

    Then in the passageHeader:
    <<set $special to 0>>
    

    Then if your link code:
    <<if $special neq 1>>[[Appearance]]<</if>>
    

    How's it work? PassageHeader always sets $special to 0, the set in the special passages sets it to 1, then the link code checks it.
Sign In or Register to comment.