7. Finding errors and keeping order
When nothing happens

- Open the console (Tab) and look for red messages. Lua usually names the script and the line.
- Use
printto check whether the function is called at all. - Look in
messages.logif the console is already gone.
The most common errors
| Symptom | Cause |
|---|---|
| Error message on access, or nothing happens at all | The name in Conditions["..."] or Values["..."] is wrong, often upper and lower case, or the displayed name instead of the internal one. |
| Function unknown | The script is not a definition script, or the function was declared with local. |
| Check is always true | A = instead of ==, or return is missing in "If lua result". |
| "'end' expected" | An if, for or function is missing its end. |
| The game gets slow | Too much work in a "mainLoop" handler. |
Order that pays off
- One definition script per topic:
cellar,hints,tools. - A comment above every function: what it does and what it returns.
- One function, one job. Three short ones are better than one long one.
- Understand code from the internet before you use it. Check every command in the official reference.
Rule to remember
Read the error message in full. It almost always names the line you need to look at.
Your task
Deliberately put a typo into a name, read the message in the console and fix it.