Clock - truemedian/Discordia GitHub Wiki
Inherits Emitter
Used to periodically execute code according to the ticking of the system clock rather than an arbitrary interval.
Inherited from Emitter
on
once
onSync
onceSync
emit
getListeners
getListenerCount
removeListener
removeAllListeners
waitFor
Starts the main loop for the clock. If a truthy argument is passed, then UTC time is used; otherwise, local time is used. As the clock ticks, an event is emitted for every
os.date
value change. The event name is the key of the value that changed and the event argument is the corresponding date table.
Name Type Optional utc boolean x Returns: nil
Stops the main loop for the clock.
Returns: nil
Inherited from Emitter
Subscribes a callback to be called every time the named event is emitted. Callbacks registered with this method will automatically be wrapped as a new coroutine when they are called. Returns the original callback for convenience.
Name Type name string fn function Returns: function
Subscribes a callback to be called only the first time this event is emitted. Callbacks registered with this method will automatically be wrapped as a new coroutine when they are called. Returns the original callback for convenience.
Name Type name string fn function Returns: function
Subscribes a callback to be called every time the named event is emitted. Callbacks registered with this method are not automatically wrapped as a coroutine. Returns the original callback for convenience.
Name Type name string fn function Returns: function
Subscribes a callback to be called only the first time this event is emitted. Callbacks registered with this method are not automatically wrapped as a coroutine. Returns the original callback for convenience.
Name Type name string fn function Returns: function
Emits the named event and a variable number of arguments to pass to the event callbacks.
Name Type Optional name string ... * x Returns: nil
Returns an iterator for all callbacks registered to the named event.
Name Type name string Returns: function
Returns the number of callbacks registered to the named event.
Name Type name string Returns: number
Unregisters all instances of the callback from the named event.
Name Type name string Returns: nil
Unregisters all callbacks from the named event.
Name Type name string Returns: nil
When called inside of a coroutine, this will yield the coroutine until the specific named event is emitted or until a timeout (in milliseconds) expires. If the coroutine is resumed by the event, then
true
is returned with any event arguments. If the coroutine is resumed by the timeout's expiration, thenfalse
is returned without any other arguments.
Name Type Optional Optional name string timeout number x predicate function x Returns: boolean, ...