Howdy, Stranger!

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

"or" command in Sugarcube, for different possible variable sums?

I'm having a bit of a problem with Sugarcube.

I want the same piece of information to display, even if the variable has multiple outcomes.

If you set the variable $rbcheck to "1", you can make visible a certain paragraph. However, if you decide to enter "4" instead of "1", the same paragraph should still display.

Ordinarily, this would work.

<<if $rbcheck is 1>>
Here's the same special paragraph.
<<elseif $rbcheck is 4>>
Here's the same special paragrah.

However, that's very inefficient, especially with a lot of variables. I want it to be in the same command, like...

<<if $rbcheck is 1 or 4>>
Here's the same special paragraph.

I also want some pieces of code to respond to the same variable answer.

<<if $rbcheck is 1 or 4 or 7>>
Here's a sentence you get if you input a certain number.
<<elseif $rbcheck is 1 or 2 or 8>>
Here's a sentence you get if you input a certain number.
<<elseif $rbcheck is 1 or 5 or 8>>
Here's a sentence you get if you input a certain number.

All three sentences would show if you set $rbcheck to "1", two sentences would show if you set it to "8", and only one sentence would show if you set it to "2", "4", 5" or "7"

Is there a way to code what I'm describing properly? Any help is greatly appreciated.

Comments

  • Try:
    <<if $rbcheck is 1 or $rbcheck is 4>>
    

    Think of the boolean operators logical-and/-or as linking conditional sub-expressions. Each sub-expression must be complete and valid separately before they can be valid together.
  • Try:
    <<if $rbcheck is 1 or $rbcheck is 4>>
    

    Think of the boolean operators logical-and/-or as linking conditional sub-expressions. Each sub-expression must be complete and valid separately before they can be valid together.

    Thank you very much. As someone very passionate about program, I really admire the accuracy of information and prompt help whenever I have a question within this community.
Sign In or Register to comment.