Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to make a chance for a passage to appear or not appear?

I am trying to make some kind of dynamic passages, so that it's a different kind of passage that pops up. I tried this, but i failed horribly at even making something this simple xP

(set: $test to (random: 1,2))
(if: $test = 1)You roll a 1]
(else:)You roll a 2]

Are there any comprehensive guides on the syntax out there? Is Harlowe even the thing to use?

Comments

  • You made one small mistake in your code, you use a (single) equal sign in your (if:) macro. In Javascript (which is what Harlowe is based on) a single equals sign = represents an assignment and a double (or triple) equals sign == (or ===) is used for comparison.

    Because it is a common mistake (that even professional programmers make) to use the wrong number of equals signs (eg. to do an assignment when you meant to do a comparison) the developer of Harlowe recommends using the to and is operators instead.

    So your code should be:
    (set: $test to (random: 1,2))
    (if: $test is 1)[ [[You roll the dice...|You roll a 1]]]
    (else:)[[[You roll the dice...|You roll a 2]]]
    

    note: The examples included in the documentation of the (set:) and (if:) macros shows the usage of the to and is operators.
Sign In or Register to comment.