img



img

libTimer


By: _ForgeUser140048
Addon | img 2,555




Description

___________________________________________________________________________________________________________________________

About

This is a simple timer implentation for Rift addons to use.

As jnwhiteh have pointed out, this is technically not the most optimum way of doing it,but it is simple, and it is also pretty fast. Fast enough for the majority of practical uses.

The main problems will be with extremely many and/or very small repeating timers, as it has to update the timers index every time a timer is added or removed.

In those cases you'd probably be better of writing your own custom timer, anyway.

Commands

(params marked with * are optional)

timer_reference = StartTimer(seconds, callback, data*, repeating*)

Creates a timer, which will run when "seconds" value of time has passed.

seconds - Seconds until the timer is run. Can be fractional numbers.

callback - The callback function to run when the timer is up

data - (Optional) Data to send to the callback

repeating - (Optional) If the timer shall be repeating

Function returns a reference to the timer created

StopTimer(timer_reference)

Will stop an existing timer.

timer_reference - The reference of the timer you want to stop

libTimer_SetDebug(int)

Will set the level of debug messages that will be shown.

int - Value from 0 to 10. 0 means no messages (default), 10 means a lot of messages.

Examples

Very basic example

	function myFunc()
		print("This is a delayed function")
	end

	StartTimer(10, myFunc)

Sending data to callback

	function myFunc(v)
		print("This function was called with "..v)
	end

	StartTimer(10, myFunc, "The Power of Time!")

Repeating timer

	function myFunc()
		print("I rise! ..again")
	end

	wicked = StartTimer(10, myFunc, nil, 1)

Stop that repeating timer

 

StopTimer(wicked)



About Project

Created: September 22nd 2023

Updated: September 22nd 2023

Project ID: 47564

License: All Rights Reserved

__________________________________________

Game Versions:

1.01.03

1.01.03

1.01.03

1.01.03

1.01.03

__________________________________________

Flavors:

WoW Retail

__________________________________________

Categories

Companions

Battle

__________________________________________

Main File

_ForgeUser140048_libTimer.zip
  • Release
  • September 22nd 2023

    __________________________________________

    Recent File

    _ForgeUser140048_libTimer.zip
  • Release
  • September 22nd 2023

    __________________________________________

    Members

    img
    _ForgeUser140048
    Owner

    __________________________________________

    Report