Threads¶
Run Lua code repeatedly in the background without blocking the console.
Asterion.Thread¶
Starts a repeating background thread.
Parameters¶
| Argument | Type | Default | Description |
|---|---|---|---|
code |
string |
— | Lua source executed on every tick. |
interval |
integer |
500 |
Milliseconds between executions. |
Returns¶
| Type | Description |
|---|---|
integer |
A thread id you pass to StopThread. |
Example¶
code is an isolated string
The body runs on its own — locals declared outside the [[ ]] block are not
visible inside it. Keep everything the thread needs inside the string, and
save the returned id in your outer script so you can stop it later.
Asterion.StopThread¶
Stops the thread with the given id.
Parameters¶
| Argument | Type | Default | Description |
|---|---|---|---|
id |
integer |
nil |
The id returned by Thread. Pass nil or omit to stop all threads. |
Example¶
-- stop one specific thread
Asterion.StopThread(tid)
-- stop every running thread
Asterion.StopThread()
Panic button
A bare Asterion.StopThread() is the fastest way to kill every loop you
have started — handy while you are experimenting.