I can't seem to get more than 2 ifs working in a statement. I want to re-use passages a lot so I need more complex if checks.
If I'm using a single passage where different events occur at different hours of the day or within a window of a number of hours and a default display if no events are occurring.
If I have a morning event to be triggered before 9:00 and an afternoon event from
15:00, I can just put something like -
<<if $day is 1 and $time is lt 10>>display am<<elseif if $day is 1 and $time is gte 15>>display pm<<else>>display generic<<endif>>
...and that works fine but if I then want a specific window such as between 15:00 and 20:00, I can't work out how to do it.
I've tried various possibilities, including:
<<elseif if $day is 1 and $time gte 15 and lte 20>>display pm
<<elseif if $day is 1 and $time gte 15 and $time lte 20>>display pm
but neither seem to work. Please tell me what I'm doing wrong and what is the best way to ask multiple if's?
There are a couple of syntax errors in your examples:
1. If you are using operates like lt and gte you don't use the is operator.
2. There is no extra if keyword in an <<elseif>> macro.
Try the following:
3. When checking if a variable's value is between two values, you need to include the variable's name in both sub-expressions.
So sorry for not specifying my story format. It is Sugarcane. I thought putting that as a tag would be enough. I'll make sure to do both from now on.
I'll return with results. Thanks!
Now because there are more story formats (like SugarCube and Harlowe) and because people are using different versions of a particular story format, and each version can have different features it has become more complex.
I would suggest using a story format name based tag (eg. harlowe1, sugarcube2, jonah, ,,,) to help with searching via tags, as well as including the story format name and version number somewhere within your original post.