0 votes
by (120 points)
edited by

Hi, I'm using Harlowe 2.0.1 and I'm trying to create an object that will make the game easier by using different links (to the same places) based on the object's value. Here's what I have:

You are in a wasteland. You cannot see beyond the tip of your nose because of all the smog in the air. Do you go:
(if: $map is false or 0)[[[Forwards]]]
(if: $map is false or 0)[[[Backwards]]]
(if: $map is false or 0)[[[To the left]]]
(if: $map is false or 0)[[[To the right]]]
(if: $map is false or 0)[[[Forwards and to the left]]]
(if: $map is false or 0)[[[Forwards and to the right]]]
(if: $map is false or 0)[[[Backwards and to the left]]]
(if: $map is false or 0)[[[Backwards and to the right]]]

(if: $map is true)[The magic map says you are in the middle, facing north.]

Do I need more brackets or something? Thanks!

1 Answer

0 votes
by (1.3k points)

Others can correct me if I'm wrong, but I'm pretty sure a variable can't be both false and 0. A variable can be true/false or it can be a number.

Also, it seems like this code is asking the program to do 8 different things if one thing is true? Or maybe you can clean things up a little? Something like this:

(if: $map is false)[

[[Left]]
[[Right]]
[[Up]]
[[Down]]
[[etc.]]
]
(else:)[You know where you are.]

 

by (159k points)

@hkfto is mostly correct, although a better (more valid) way to test if a variable is equal to either true or false is as follows.

(set: $map to true)\
(if: $map)[The map story variable is equal to true.]

(set: $map to false)\
(if: not $map)[The map story variable is equal to false.]

... notice the lack of an is operator and the usage of the not operator to (temporarily) reverse the value of $map.

by (63.1k points)

Just to cap this off, if you're checking for true, you can also just attach the variable directly to the hook, and if it's true it'll display: 

(set: $var to true)\
$var[This text shows if the variable $var is true. If it's false, nothing will be shown here.]

This can be a useful shortcut in some situations. 

...