Can't get multiple-condition IF statement to work

Hi!! This probably will be a noob question, because I’m new to “coding”, but here is:

I’m trying to make a simple conditional: If hour or weekday is X, the door will be locked, if not, the player can enter.
But everytime i try, with this code below,or with “is”, without " () ", everytime the door appear locked, no matter the $period or $day.

<<if ($period == 0 or 5) or ($day == 0 or 6) >>
<h4>The door is locked</h4>

All the <<elseif>> and <<else>> below that work fine, just that part is broken.
I will appreciate if you guys can help me solve that <3

English is not my primary language, sorry for any mistakes

ChatGPT solved the issue lol
He gave me this code, and it’s working now. However, I would appreciate it if you could confirm whether this is the most optimized way to write it.

<<if (($period === 0 || $period === 5) || ($day === 0 || $day === 6)) >>

  <h4>The door is locked</h4>

For future reference, the problem was that Sugarcube wants <<if $period == 0 or $period == 5>>, not <<if $period == 0 or 5>>. You can see this in the section of the documentation that deals with conditionals (here).

Anyway, your current code is fine, but that outer set of parentheses is doing nothing. ChatGPT also changed your “equivalent” operators into “strictly equal” ones (here’s an explanation of what that means), but I don’t think that matters in this case.

1 Like

Thanks for the explanation! If you hadn’t mentioned it, I would have never paid attention to the other $period .
Tyvm <3

1 Like

You don’t need all these parenthesis.

<<if $period === 0 || $period === 5 || $day === 0 || $day === 6 >>

  <h4>The door is locked</h4>

You will need parenthesis only if you mix ‘and’ or ‘or’ conditions.