DE EN FR ES IT CZ

2. Where Lua runs in Visionaire

Where Lua runs in Visionaire

Pia shines a torch into an open control box

You create scripts in the "Scripts" section of the editor. For every script you choose with the "definition script" option which kind it is:

KindWhen it runsWhat for
Definition scriptonce when the game startsfunctions and global variables that are available throughout the game
Execution scriptonly when an action calls ita 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 print line, start the game and find the message in the console.