mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-08 14:50:51 -04:00
Updated API Event (markdown)
parent
dd9948c4b5
commit
684aa8ec00
@ -6,7 +6,8 @@ This API provides a rudimentary event system. It is primarily intended to be use
|
||||
Unregister a previously registered event listener. Returns `true` if the event listener was removed, `false` if the listener was not registered.
|
||||
- `event.timer(interval: number, callback: function[, times: number]): number`
|
||||
Starts a new timer that will be called after the time specified in `interval`. Per default, timers only fire once. Pass `times` with a value larger than one to have it fire as often as that number specifies. Pass `math.huge` to create an infinitely repeating interval.
|
||||
This returns a number that identifies the created timer, and can be used in `timer.cancel` to destroy it, possibly before it even ran once.
|
||||
This returns a number that identifies the created timer, and can be used in `timer.cancel` to destroy it, possibly before it even ran once.
|
||||
*Note*: the timer resolution can vary. If the computer is idle and enters sleep mode, it will only be woken in a game tick, so the time the callback is called may be up to 0.05 seconds off.
|
||||
**Important**: timers are driven by the `event.pull` function. If you always pull signals directly from `os.pullSignal` and never call `event.pull`, timers will not work!
|
||||
- `event.cancel(timerId: function): boolean`
|
||||
Cancels a timer previously created with `event.timer`. Returns `true` if the timer was stopped, `false` if there was no timer with the specified ID.
|
||||
|
Loading…
x
Reference in New Issue
Block a user