View Single Post
06/24/18, 05:47 AM   #3
manavortex
 
manavortex's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 138
Edit: I threw something into the wiki.

Lua Code:
  1. -- run for 5 seconds
  2. local withinInterval = true
  3. zo_callLater(function() withinInterval = false end, 5000)
  4.  
  5. while withinInterval do
  6.     -- something
  7. end

Or, more asynchronous - this should call the function around 10 times
Lua Code:
  1. -- run for 5 seconds
  2. local withinInterval = true
  3. zo_callLater(function() withinInterval = false end, 5400)
  4.  
  5. local function callWithinInterval()
  6.     if not withinInterval then return end
  7.     -- do something
  8.     return zo_callLater(callWithinInterval, 500)
  9. end
  10. -- now call it
  11. callWithinInterval()

Last edited by manavortex : 06/24/18 at 07:29 AM.
  Reply With Quote