0 votes
by (200 points)
Alright so in my current project I've got a number of variables that change based on player choices throughout the game, but I need help with something. To explain it, let's take the player's gold (as in coinage) count as an example ($gold).

Say they come to a toll bridge. The toll is 7 gold. Is there some other way besides a bunch of (if:) or (else-if:) statements to basically say "if $gold is 7 or more do X, if $gold is 6 or less do Y"?


1 Answer

0 votes
by (159k points)

For the specific range example you gave you could use an (else:) macro instead of an (else-if:) macro.

(if: $gold >= 7)[You have enough gold]\
(else:)[You need to find more gold]

When you need to check a variable against multiple ranges you can use a set of cascading (else-if:) macros like the following.

(if: $gold >= 15)[you can afford the 15 gold item]\
(else-if: $gold >= 10)[you can afford the 10 gold item]\
(else-if: $gold >= 5)[you can afford the 5 gold item]\
(else:)[you can't afford any item]

The above cascade works because the process of the set stops as soon as one of the conditional expressions evaluates to true.