2. Where Lua runs in Visionaire
Where Lua runs in Visionaire

You create scripts in the "Scripts" section of the editor. For every script you choose with the "definition script" option which kind it is:
| Kind | When it runs | What for |
|---|---|---|
| Definition script | once when the game starts | functions and global variables that are available throughout the game |
| Execution script | only when an action calls it | a sequence that should happen at one particular point |
Three action parts connect actions and Lua
- "Call script" starts an execution script from your list.
- "Execute a script" runs Lua code that you write directly into the action part. Ideal for a single line, for example calling a function.
- "If lua result" is an if/else check: the action parts below it only run if your Lua code returns
true.
Seeing what happens
With print("Hello") you write a message. It appears in the log file messages.log and in the player console, which you show and hide with the Tab key while testing. Lua error messages end up in the log as well. The console only exists while testing, not in the finished game.
-- definition script "test"
print("My first script is running")
Start the game and press Tab. If the sentence is there, everything is connected.
Rule to remember
Functions belong in definition scripts. They are called from the actions.
Your task
Create a definition script with a