Methods
Timer:after(delay: number, func: fun())
Runs a function after a given amount of time has passed.
@param delay — The time, in seconds, to wait before executing the function.
@param func — The function to execute.
Arguments:
| delay: number | The time, in seconds, to wait before executing the function. |
| func: fun() | The function to execute. |
Returns:
| handle: table |
Timer:afterCond(condition: fun()boolean, func: fun())
Runs a function once a given condition is met.
@param condition — The condition function. Should return the value of the condition to check.
@param func — The function to execute once the condition is true.
Arguments:
| condition: fun()boolean | The condition function. Should return the value of the condition to check. |
| func: fun() | The function to execute once the condition is |
Returns:
| handle: table |
Timer:approach(time: number, from: number, to: number, callback: fun( number), easing: ("in-back"|"in-bounce"|"in-circ"|"in-cubic"|"in-elastic"...(+66))?, after: fun()?)
Tweens from one number to another over a period of time.
@param time — The time it will take to complete the tween, measured in seconds.
@param from — The starting value.
@param to — The target value.
@param callback — A function that gets called every frame during the tween. The current value of the tween is passed in as an argument to this function.
@param easing — The easing type to use.
@param after — A callback to run when the tween is finished.
easing:
| "linear"
| "in-quad"
| "in-cubic"
| "in-quart"
| "in-quint"
| "in-sine"
| "in-expo"
| "in-circ"
| "in-back"
| "in-bounce"
| "in-elastic"
| "out-quad"
| "out-cubic"
| "out-quart"
| "out-quint"
| "out-sine"
| "out-expo"
| "out-circ"
| "out-back"
| "out-bounce"
| "out-elastic"
| "in-out-quad"
| "in-out-cubic"
| "in-out-quart"
| "in-out-quint"
| "in-out-sine"
| "in-out-expo"
| "in-out-circ"
| "in-out-back"
| "in-out-bounce"
| "in-out-elastic"
| "inQuad"
| "outQuad"
| "inOutQuad"
| "outInQuad"
| "inCubic"
| "outCubic"
| "inOutCubic"
| "outInCubic"
| "inQuart"
| "outQuart"
| "inOutQuart"
| "outInQuart"
| "inQuint"
| "outQuint"
| "inOutQuint"
| "outInQuint"
| "inSine"
| "outSine"
| "inOutSine"
| "outInSine"
| "inExpo"
| "outExpo"
| "inOutExpo"
| "outInExpo"
| "inCirc"
| "outCirc"
| "inOutCirc"
| "outInCirc"
| "inElastic"
| "outElastic"
| "inOutElastic"
| "outInElastic"
| "inBack"
| "outBack"
| "inOutBack"
| "outInBack"
| "inBounce"
| "outBounce"
| "inOutBounce"
| "outInBounce"
Arguments:
| time: number | The time it will take to complete the tween, measured in seconds. |
| from: number | The starting value. |
| to: number | The target value. |
| callback: fun( number) | A function that gets called every frame during the tween. The current value of the tween is passed in as an argument to this function. |
| easing: ("in-back"|"in-bounce"|"in-circ"|"in-cubic"|"in-elastic"...(+66))? | The easing type to use. |
| after: fun()? | A callback to run when the tween is finished. |
Returns:
| handle: table |
Timer:cancel(handle: table)
Cancels a timer completely.
@param handle — The handle of the timer to cancel.
Arguments:
| handle: table | The handle of the timer to cancel. |
Timer:clear()
Resets this timer, removing all attached handles.
Timer:doWhile(condition: fun()boolean, func: fun(), after: fun()?)
Runs a function every frame while a given condition is true.
@param condition — The condition function. Should return the value of the condition to check.
@param func — The function to execute.
@param after — A function to execute when the condition stops being true.
Arguments:
| condition: fun()boolean | The condition function. Should return the value of the condition to check. |
| func: fun() | The function to execute. |
| after: fun()? | A function to execute when the condition stops being |
Returns:
| handle: table |
Timer:during(delay: number, func: fun()boolean?, after: fun()?)
Runs a function every frame for a given interval.
@param delay — The time to run this function for, in seconds.
@param func — The function to execute. If this returns false, it will stop this timer early.
@param after — A function to execute when this timer finishes.
Arguments:
| delay: number | The time to run this function for, in seconds. |
| func: fun()boolean? | The function to execute. If this returns |
| after: fun()? | A function to execute when this timer finishes. |
Returns:
| handle: table |
Timer:every(delay: number, func: fun()boolean?, count: number?)
Runs a function at fixed intervals.
@param delay — The time between calls to the function, in seconds.
@param func — The function to execute. If this returns false, it will stop this timer.
@param count — The total number of times the function will run, if provided.
Arguments:
| delay: number | The time between calls to the function, in seconds. |
| func: fun()boolean? | The function to execute. If this returns |
| count: number? | The total number of times the function will run, if provided. |
Returns:
| handle: table |
Timer:everyInstant(delay: number, func: fun()boolean?, count: number?)
Runs a function at fixed intervals, as well as once instantly.
@param delay — The time between calls to the function, in seconds.
@param func — The function to execute. If this returns false, it will stop this timer.
@param count — The total number of times the function will run, if provided.
Arguments:
| delay: number | The time between calls to the function, in seconds. |
| func: fun()boolean? | The function to execute. If this returns |
| count: number? | The total number of times the function will run, if provided. |
Returns:
| handle: table |
Timer:pause(handle: table)
Pauses a specific timer indefinitely. It can be unpaused with Timer:unpause(handle).
@param handle — The handle of the timer to pause.
Arguments:
| handle: table | The handle of the timer to pause. |
Timer:script(func: fun( fun(seconds? number)))
Runs a function as a coroutine.
@param func — The function to execute. The wait parameter of this function can be called to pause the coroutine of this script.
Arguments:
| func: fun( fun(seconds? number)) | The function to execute. The |
Returns:
| handle: table |
Timer:tween(duration: number, subject: table, target: string, value, method: ("in-back"|"in-bounce"|"in-circ"|"in-cubic"|"in-elastic"...(+66))?, after: fun()?, : unknown)
Performs in-betweening (tweening) of a value on an object from its current value to another.
@param duration — The time the tween will take place over, in seconds.
@param subject — The object to be tweened.
@param target — A table containing the keys in the subject table that should be tweened, and their target values.
@param method — The easing method to use, defaults to linear.
@param after — A function to run once the tween has finished.
@param ... — Additional arguments to the tweening function.
method:
| "linear"
| "in-quad"
| "in-cubic"
| "in-quart"
| "in-quint"
| "in-sine"
| "in-expo"
| "in-circ"
| "in-back"
| "in-bounce"
| "in-elastic"
| "out-quad"
| "out-cubic"
| "out-quart"
| "out-quint"
| "out-sine"
| "out-expo"
| "out-circ"
| "out-back"
| "out-bounce"
| "out-elastic"
| "in-out-quad"
| "in-out-cubic"
| "in-out-quart"
| "in-out-quint"
| "in-out-sine"
| "in-out-expo"
| "in-out-circ"
| "in-out-back"
| "in-out-bounce"
| "in-out-elastic"
| "inQuad"
| "outQuad"
| "inOutQuad"
| "outInQuad"
| "inCubic"
| "outCubic"
| "inOutCubic"
| "outInCubic"
| "inQuart"
| "outQuart"
| "inOutQuart"
| "outInQuart"
| "inQuint"
| "outQuint"
| "inOutQuint"
| "outInQuint"
| "inSine"
| "outSine"
| "inOutSine"
| "outInSine"
| "inExpo"
| "outExpo"
| "inOutExpo"
| "outInExpo"
| "inCirc"
| "outCirc"
| "inOutCirc"
| "outInCirc"
| "inElastic"
| "outElastic"
| "inOutElastic"
| "outInElastic"
| "inBack"
| "outBack"
| "inOutBack"
| "outInBack"
| "inBounce"
| "outBounce"
| "inOutBounce"
| "outInBounce"
Arguments:
| duration: number | The time the tween will take place over, in seconds. |
| subject: table | The object to be tweened. |
| target: string, value | A table containing the keys in the |
| method: ("in-back"|"in-bounce"|"in-circ"|"in-cubic"|"in-elastic"...(+66))? | The easing method to use, defaults to |
| after: fun()? | A function to run once the tween has finished. |
| : unknown | Additional arguments to the tweening function. |
Returns:
| handle: table |
Timer:unpause(handle: table)
Resumes a timer previously paused with Timer:pause(handle).
@param handle — The handle of the timer to resume.
Arguments:
| handle: table | The handle of the timer to resume. |