Hi Twine community!
I started using Twine to prototype the investigation game I am developing.
I am pretty much a newbie when it comes to coding and I need your help as I want to have certain messages printed depending on the value of my variable
$trust.
My variable works. I tested it with a counter displaying how it evolves, and I can print messages when it is above or below a certain value.
I use this (if: $trust < X)[Bla bla bla...]
However, I cannot find the way to display a message when it is comprised between two values.
What would be the code to display something like "Your trust level is between 0 and 10" when my $trust is comprised 0 and 10?Thank you!
Comments
Anyway, it's fairly obvious that you're using Harlowe. The following should do what you want when
$trust
is in the range 010 (inclusive): By using theit
keyword, which is shorthand for the leftmost operand in an expression, you could write that more concisely as:Here is my code:
(if: $trust > 29)[Trust level above 29]
(if: $trust => 20 and $trust <= 29)[Trust level between 20 and 29]
(if: $trust => 10 and $trust <= 19)[Trust level between 10 and 19]
(if: $trust => 0 and $trust <= 9)[Trust level between 0 and 9]
(if: $trust < 0)[Trust level below 0]
I ran a test in which my $trust was worth 10, and I got this:
Trust level between 20 and 29
Trust level between 10 and 19
Trust level between 0 and 9
While I should only have "Trust level between 10 and 19"...
???
Try this: Because your conditional tests are mutually exculsive (eg. they don't over lap) you can use the (elseif:) macro on the second through fifth test.