You'll need:
Add per-level scripts in a level object:
{
"levels": [
// …,
"script": "data/scripts/level1.lua",
// …,
],
// …
}
Create a file data/scripts/level1.lua folder in your project and put the
following content:
TRX.Events.Listen(TRX.EventType.LEVEL_LOAD, function(level)
TRX.Log.Info("hello from level 1!")
end)
Start the game. In the logs, you should see the following:
INF | 2025-10-04 12:12:23.155 [cfg/tr1/level1.lua:4:?] hello from caves
Optionally, you can also load a global script by adding a global property to your game flow configuration:
{
// Optional global Lua script file
"main_script": "data/scripts/global.lua",
}
You can also try out short lua commands in-game with the /lua console command:
/lua