The static global Timer class provides methods for executing functions at a later time or repeatedly. Timers have a unique user-supplied identifier to keep track of running Timers. Because the static Timer class is shared among all Object and Global scripts, make sure that you provide a unique identifier to avoid collisions. A good practice is to append the Object’s GUID to the end of the identifier string if a lot of Objects will be making similarly named Timers.
Return Value | Function Name | Description |
---|---|---|
bool | create(Table parameters) |
Creates a Timer. The Timer will delete itself when it’s number of repetitions has been reached. Parameters Table: local parameters = {} parameters.identifier = string identifier –Custom name so that you can refer to this Timer. Must be unique between all Objects and Global. parameters.function_name = string function_name parameters.function_owner = Object function_owner –Optional. Defaults to the calling Object. parameters.parameters = Table parameters –Optional. Parameters to pass to the function called with this Timer. parameters.delay = float delay –Optional. The delay in seconds before this function fires. Defaults to 0. parameters.repetitions = int repetitions –Optional. The number of times this function will be called. Use 0 for infinitely repeating. Defaults to 1. |
bool | destroy(string identifier) | Destroys an existing timer. Returns false on failure or if the Timer doesn’t exist. |