Thread Tools Display Modes
10-30-11, 06:45 AM   #1
Egoplant
A Defias Bandit
Join Date: Oct 2011
Posts: 3
Interval

Is there a function to call a function every x. Like, if I wanted to perform a function every 100 ms or something.
  Reply With Quote
10-30-11, 07:46 AM   #2
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
You have to use a Frame that you put a OnUpdate script to do the calling for you.

For example;
Code:
local f = CreateFrame("Frame")
local count = 0
f:SetScript("OnUpdate", function(self, elapsed)
  count = count + elapsed
  if count >= 100 then
    count = 0 -- reset to we wait another 100ms before printing
    print("We do this each 100ms.")
  end
end)
There are many other ways too, using the animation system and even the lua threading I reckon, but I am not so god with threading in lua. You can also look up the widget API here: http://wowprogramming.com/docs
  Reply With Quote
10-30-11, 08:04 AM   #3
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
elapsed is in seconds, so count >= 0.1
  Reply With Quote
10-30-11, 08:54 AM   #4
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
I made a typo.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Interval


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off