- New Objects (Flexbox, Graph, Treeview) - Pluginsystem to add/remove functionality - Reworked the entire Object system, instead of one big Object Class we have multiple classes: Object, VisualObject, ChangeableObject - Instead of one big Frame Class we have multiple Frame Classes: BaseFrame, Frame, MovableFrame, ScrollableFrame, MonitorFrame, Flexbox - Removed the Animation Object, and added a animation plugin instead - Removed the Graphic Object and merged it's functionality with the image object - Updated currently existing objects
39 lines
1.2 KiB
Markdown
39 lines
1.2 KiB
Markdown
Timers are objects that allow you to execute code after a specified delay. Unlike Threads, Timers do not use coroutines for concurrency. They are designed to run a function once after the delay has passed.
|
|
|
|
In addition to the Object methods, Timers have the following methods:
|
|
|
|
| | |
|
|
|---|---|
|
|
|[setTime](objects/Timer/setTime.md)|Sets the time the timer should wait before calling your function
|
|
|[start](objects/Timer/start.md)|Starts the timer
|
|
|[cancel](objects/Timer/cancel.md)|Cancels the timer
|
|
|
|
## Events
|
|
|
|
| | |
|
|
|---|---|
|
|
|[onCall](objects/Timer/onCall.md)|A custom event which gets triggered as soon as the current timer has finished
|
|
|
|
## Example
|
|
|
|
Here's an example of how to create and use a Timer object:
|
|
|
|
```lua
|
|
-- Function that will be executed after the timer delay
|
|
local function delayedTask()
|
|
basalt.debug("This message will be displayed after a 5-second delay")
|
|
end
|
|
|
|
-- Create a new Timer object
|
|
local main = basalt.createFrame()
|
|
local myTimer = main:addTimer()
|
|
|
|
myTimer:onCall(delayedTask)
|
|
|
|
-- Set the time delay and start the timer
|
|
myTimer:setTime(5)
|
|
myTimer:start()
|
|
|
|
-- Optionally cancel the timer (not needed in this example, as the timer will finish on its own)
|
|
-- myTimer:cancel()
|
|
``` |