0 votes
by (120 points)
im doing an enounter-matic 2000 and i need to get random numbers and use them in an ifelse statement.

an outline of what im trying to do is this:

(set: $variable to (random: 1, 2))
(if: $variable = 1) [
do this
] (else-if: $variable = 2) [
do that
]

when i try to run it, i get this error: (if:)'s 1st value is a 'to' or 'into' expression, but should be a boolean.

what do i do?

1 Answer

0 votes
by (159k points)

Please use the "Insert Code Snippet" button in the toolbar when including code examples with your comments.

A single equals sign "=" represents assigment, where as double or triple equals signs ("==" or "===") represent comparision. So your (if: $variable = 1) statement is actually telling Harlowe to assign the number 1 to the $variable story variable, and then to check if the over all result of that is true(ish).

The common confusion of using the wrong number of equals signs is one reason the to (assignment) and is (comparision) keyword operators exist. I suggest you use them instead of the equal signed.

A modified copy of your example

(set: $variable to (random: 1, 2))
(if: $variable is 1)[
do this
]
(else-if: $variable is 2)[
do that
]

note: you may notice in the above example that there is no white-space between the close parentheses ")" of the macro call and the open square bracket "[" of it's associated hook.

...