Skip to content

New library: timer

dounai2333 edited this page Jan 12, 2025 · 1 revision

Introduction

The timer library is a very useful set of functions which allow you to run a function periodically or after a given delay.

Adjust

dounai_lib.timer.Adjust(name, delay, repetitions, func)

Adjusts a previously created timer with the given identifier.

Return: bool

name: string

delay: number

repetitions: number

func: function

AdjustTick

dounai_lib.timer.AdjustTick(name, tick, repetitions, func)

Adjusts a previously created tickrate-based timer with the given identifier.

Return: bool

name: string

tick: number

repetitions: number

func: function

Create

dounai_lib.timer.Create(name, delay, repetitions, func)

Creates a new timer that will repeat its function given amount of times.

name: string

delay: number

repetitions: number

func: function

CreateTick

dounai_lib.timer.CreateTick(name, tick, repetitions, func)

Creates a new tickrate-based timer that will repeat its function given amount of ticks.

name: string

tick: number

repetitions: number

func: function

Exists

dounai_lib.timer.Exists(name)

Returns whenever the given timer exists or not.

Return: bool

name: string

Pause

dounai_lib.timer.Pause(name)

Pauses the given timer.

name: string

Remove

dounai_lib.timer.Remove(name)

Stops and removes a timer.

name: string

RepsLeft

dounai_lib.timer.RepsLeft(name)

Returns amount of repetitions/executions left before the timer destroys itself.

Return: number

name: string

Simple

dounai_lib.timer.Simple(delay, func)

Creates a simple timer that runs the given function after a specified delay.

delay: number

func: function

SimpleNextTick

dounai_lib.timer.SimpleNextTick(func)

Creates a simple timer that runs in the next tick.

func: function

TickLeft

dounai_lib.timer.TickLeft(name)

Returns amount of ticks left before the timer executes its function.

If the timer is paused, the amount will be negative.

Return: number

name: string

TimeLeft

dounai_lib.timer.TimeLeft(name)

Returns amount of time left (in seconds) before the timer executes its function.

If the timer is paused, the amount will be negative.

Return: number

name: string

Toggle

dounai_lib.timer.Toggle(name)

Runs either dounai_lib.timer.Pause() or dounai_lib.timer.UnPause() based on the timer's current status.

name: string

UnPause

dounai_lib.timer.UnPause(name)

Unpauses the timer.

name: string

Clone this wiki locally