Scripting help
Choosing with if and end
Let a character choose what to do with if, else if and else, the things it can check, and chances.
if lets a character choose. Under a when line, write if and something to check. The lines under it happen only when the check is true.
You can add more choices. else if checks something else when the checks above it weren't true. The lines under else happen when none of them were. Close it all with end.
When the if is the last thing in its rule, you can leave out its end.
What an if can check
These are the things a character's if can check:
| Check | What it means |
|---|---|
my health is under 50 | Enemies only. Instead of under, you can write over, at least, at most, or is for exactly. |
my opacitymy hue | Numbers, checked the same way as health. |
my look is darkmy effect is firemy direction is left | What the character shows now. |
the {Hero} is near | The hero is within 3 blocks. For another distance, write the {Hero} is within 5 blocks. |
the {Hero} is far | The hero is more than 3 blocks away: the other way round from near. far away works too. |
the {Door} is near meI am near the {Door} | A thing with that ID is within 3 blocks. See How near things are. |
my row is over 1my column is 4 | Where the character is. See Where a character is. |
I see the {Hero}the {Hero} is out of sight | Enemies only. The hero is in the enemy's view, or not. |
a 1 in 3 chance | True one time in three. You can also write a 1-in-3 chance or a 30% chance. |
An if can check a @variable too (see Using @variables to remember).
How near things are
An if can check how near two things are, by their IDs. near means within 3 blocks. For another distance, write within and the number of blocks.
| Check | What it means |
|---|---|
the {Door} is near methe {Door} is within 5 blocks of me | The thing with that ID is near this character. of me can be left out. |
I am near the {Door}I am within 5 blocks of the {Door} | The same, said the other way round. |
the {Door} is far from meI am far from the {Door} | The other way round from near: more than 3 blocks apart. far away from works too. |
the {Goblin} is near the {Door}the {Hero} is within 4 blocks of the {Door} | Two other things are near each other. Game and level scripts use these. |
my distance to the {Door} is under 5the {Door} distance from me is within 5 blocks | How far apart, as a number. After a distance, is within 5 blocks means is at most 5. |
Distances are measured in a straight line, in blocks, and rounded to one place after the dot, like 2.2. A thing that isn't here, like a beaten enemy or one in another level, is never near anything, so it's always far.
Checking values
An if can check a @variable, some math, or what a function gives back. Math can go on either side of the check.
| Check | What it means |
|---|---|
@count is 3 | The variable holds 3. @count equals 3 means the same. |
@count is not 3 | It holds something else. not @count equals 3 means the same. |
@count is at least 3 | You can also write under, over and at most. |
@door_open is yes | It holds yes. yes and no take no quotes. |
@door_open | On its own: the same as @door_open is yes. |
@key is nothing | Nothing has set it, or it was cleared with @key is nothing. |
@score + 1 is over @best * 2 | Math is worked out first, then checked. |
sum with 1, 2 is 3 | The function runs first, then what it gives back is checked. |
A @variable that holds a thing is checked like the thing: @door is locked, all @doors are locked, @slimy is in @ghosts. See Checking things.
To keep a check's answer for later, write @seen is whether I see the {Hero}. The variable gets yes or no. See Yes, no and nothing.
equals can't take at least or under after it: write is at least 3.
A function in an if is waited for, like any step. In an else if, it only runs when the script gets that far. See Functions that give back.
A when line can check a @variable or math the same way, as in when @coins * 2 is at least @goal. It can't use a function.
Ways to compare numbers
There are many ways to say bigger or smaller, and they all work. Every way in a row means the same thing, so pick the one that reads best to you.
| What it means | Ways to write it |
|---|---|
| Smaller | is under 3is below 3is less than 3is fewer than 3< 3 |
| Bigger | is over 3is above 3is more than 3is greater than 3> 3 |
| Smaller or the same | is at most 3<= 3 |
| Bigger or the same | is at least 3>= 3 |
These work anywhere a number is checked, like if my health is at most 50 or when @coins >= 10. With a sign, is can be left out.
No way of comparing has an or in it, so an or always joins two checks.
Joining checks
Join two checks with and when both must be true, or with or when either one will do. For example, if my health is under 50 and the {Hero} is near. One line can't have both and and or.
Once a line has named the hero, a later check on it can say they instead: if the {Hero} is near the {Old well} and they have at least 5 coins.
For the opposite of a check, put not in front of it, as in if not the {Chest} is open. Some checks have an opposite of their own: if the {Hero} is out of sight is the opposite of if I see the {Hero}, and if the game is offline of if the game is online.
Chances
A chance comes out differently each time, and in each new game, so the character doesn't always do the same thing.
Try again plays the same chances as before, and From start brings new ones. Online, every player sees the same result.

