Rûn Errors and the Checker
Rûn finds mistakes in two places: the checker reads a script without running it, and a run stops at the first thing it cannot do. Both name the line and say what to do.
The checker
- The Text Editor
- Marks a broken line in the gutter the moment you type it, with the fix spelled out.
- The asset manager's Check panel
- Lists every error and warning in the open script, with its line. Click a row to edit that line.
check <event>at the console- Proofreads an event script and prints what it finds, or
clean, not a mark on it. - Export
- Every export checks the scripts it ships again (see Exporting Your Game).
An error is a line that cannot run as written. A warning is a line that may be fine: a villager or a prop the checker cannot see from the map that is open, or a file that is not there yet.
The checker reads programs with the same parser that runs them, so a program the checker passes will parse when it runs. It also checks every engine method's name and its count of arguments, the math functions' counts, and every rule block's event and parameters.
The checker on event scripts
[use]
giv cook_key 1
say This line is fine.ERROR line 2: no verb called "giv" - did you mean give?
1 finding(s)The checker on programs
on use {
Player.Giv("cook_key", 1)
print(round(1, 2, 3))
}ERROR line 2: Player has no method named Giv - it can do: Give Take Count Equip Unequip GrantXP LevelTo LearnSpell Knows
ERROR line 3: round takes 2 numbers at most, and was given 3 - round(x), round(x, places), like: n = round(random(0, 50))
2 finding(s)before damage(number amount, text weapon) {
amount = amount + 1
}ERROR line 1: damage hands no weapon. It hands: amount target source by type
1 finding(s)Errors while a program runs
A program stops at the first error, and the console prints it with its line: line 3: division by zero -> test the divisor before dividing. The part after -> is the fix. Lines before the error have already run; lines after it do not. When the world called the program (a prop, a zone, a rule block), the message starts with the script's name: barn_door.run: line 3: ....
These are the messages a maker meets most, and what to do about each:
- nothing is named X
- X is not a variable here. Declare it first (
number x = 0), check its spelling, and remember that a section does not see the program's top level and aforcounter ends with its loop. - nothing is named X to call
- No function X in this file and no built-in function X. Define it in the same file.
- X wants 2 arguments, got 1
- A call to your function gives too few or too many values.
- expected a value here
- Something is missing where a value should stand: often
+=,++, or an operator at the end of a line. Writex = x + 1. - this ( never closes, this call never closes
- A bracket is missing, or something stands between two arguments without a comma.
- if wants ( )
- Programs put the condition in brackets:
if (hp < 10). - a program writes and as &&
- Use
&&,||and!in programs;and,orandnotare for event scripts. - this arithmetic wants numbers on both sides
- A text or a toggle met
-,*,/,%,<or>. - division by zero
- Test the divisor before dividing.
- hp is declared number, and "full" is text
- A declaration's value is not of its type.
- index 3 is outside the list
- Lists count from 0; the last is
list.Count - 1. - this while ran 100000 laps
- The loop never ends. Make sure something in it changes its test.
- functions are calling themselves too deep
- More than 16 calls inside one another.
- Player has no method named X
- The method is misspelled or does not exist; the message lists what the object can do.
- needs a running game
- The method changes the game and the editor has none. Press Test (F5) and run it there.
- refuse() belongs in a before hook
refuseonly stops an event from abeforeblock.- plays out over time, and a hook has to answer now
- A rule block called
World.Fireor a camera move. Raise a flag instead.
number shares = 0
print("before")
print(10 / shares)
print("after")line 3: division by zero -> test the divisor before dividingMessages that mean something else
A few messages name what the parser or the checker met rather than what you meant. All five were measured:
a = b = 1gives "an assignment cannot be chained"- One line sets one variable. Write
b = 1and thena = b. number ngives "nothing is named number"- A declaration needs a value:
number n = 0. - A text of 160 bytes or more gives "this string never closes"
- The text is too long for a value (159 bytes). Split it.
print("say "hi"")gives "this call never closes"- A double quote cannot stand inside text.
run ev_luckin an event script gives "no event or program called "ev_luck""- Neither
assets/events/ev_luck.runnorassets/scripts/ev_luck.runis there.
number a = 0
number b = 0
a = b = 1line 3: an assignment cannot be chained -> one assignment per line: a = 1 then b = 1Errors in event scripts while they run
A line indented with a tab is inside the if above it, as a line indented with spaces is: a tab reaches the next multiple of four columns.
[use]
if 0
set tab_ran 1cleanA running game never stops for a broken event line: a line whose verb is unknown is skipped and the rest runs. A verb that cannot do what it was asked (taking an item she does not have, an item that does not exist, a change that needs a running game) says why in the console and in the Event Debugger's log, and changes nothing. A section that runs 20000 lines in one frame, which only a while that never ends does, is stopped there and its log says runaway script paused.