Threads
The threads module allows you to run scripts that are not attached to any Scene, Actor, or Trigger. Threads are useful for background processes or situations where no specific actor or trigger is appropriate.
How Threads Work
A thread is a standalone script that runs alongside the rest of your game while the current scene is active. It is not tied to an actor or trigger. Running threads are cleared when the scene changes.
When a thread's script finishes executing, the thread stops. If you want a thread that runs continuously, place its logic inside a Loop event.
Thread Slots
By default, you can create up to 5 threads. This can be increased in the Maximum Elements settings.
Each thread slot is independent — you can have multiple threads running simultaneously, each with its own script.
When to Use Threads
Threads are best suited for:
- Background music control — Changing music based on game state without tying the logic to a specific actor.
- Counters or timers — Tracking time or score across actor interactions in the current scene.
- Monitoring conditions — Continuously checking if a condition is met (e.g., "if all enemies defeated, open the door").
- Cutscene orchestration — Coordinating multiple actors from a single script that doesn't belong to any one of them.
Threads vs Timers
Both threads and timers run scripts independently, but they serve different purposes:
- Threads run a script once (or continuously with a loop) and are good for ongoing background logic.
- Timers fire a script at regular intervals and are good for periodic actions on a fixed schedule.
Tips
- Always include an Idle or Wait in looping threads to avoid freezing the game.
- Threads are a good way to handle logic that doesn't belong to any particular actor.
- Running threads stop when the scene changes. Start a new thread in the next scene if that logic needs to continue.

