docs update
Updated some docs stuff
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
You question yourself how you can execute your own logic while basalt is also active? There are multiple ways of doing that:
|
||||
|
||||
## Parallel
|
||||
|
||||
Using parallel.waitForAll or parallel.waitForAny
|
||||
|
||||
```lua
|
||||
@@ -21,9 +22,11 @@ end
|
||||
|
||||
parallel.waitForAll(basalt.autoUpdate, yourCustomHandler) -- here it will handle your function (yourCustomHandler) and basalt's handlers at the same time using parallel's API
|
||||
```
|
||||
|
||||
[Here (tweaked.cc)](https://tweaked.cc/module/parallel.html) you can find out more about the parallel API.
|
||||
|
||||
## Threads
|
||||
|
||||
Using basalt's thread implementation.
|
||||
|
||||
```lua
|
||||
@@ -47,6 +50,7 @@ thread:start(yourCustomHandler) -- here we start the thread and pass the functio
|
||||
```
|
||||
|
||||
## Timers
|
||||
|
||||
Using basalt's implementation of timers.
|
||||
Remember, timers don't run asynchronly which means if you're using sleep somewhere this will freeze basalt's event system too.
|
||||
|
||||
@@ -67,4 +71,25 @@ end
|
||||
timer:onCall(yourCustomHandler)
|
||||
:setTime(1, -1)
|
||||
:start() -- this will call your function every second until you :cancel() the timer
|
||||
```
|
||||
```
|
||||
|
||||
## Schedule
|
||||
|
||||
Using basalt's schedule implementation.
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main = basalt.createFrame() -- we need a base frame
|
||||
main:addButton() -- just a button
|
||||
:onClick(function()
|
||||
basalt.debug("Button got clicked")
|
||||
end)
|
||||
|
||||
local yourCustomHandler = basalt.schedule(function() -- create a new schedule task
|
||||
-- add your logic here
|
||||
end)
|
||||
|
||||
yourCustomHandler() -- execute the schedule task
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user