View Single Post
08/15/15, 05:01 PM   #12
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by haggen View Post
Look at this http://esodata.uesp.net/100011/data/...ForUpdate.html

You'll see a bunch of cases where the game code calls RegisterForUpdate function on a control. I'm only 90% sure of what it does, do you guys know ?

What I got from it is that it registers a callback for when a given UI is updated (more like a tick, and many times per second actually, maybe the same as frames per second) but I'm not sure about the second argument, which looks like a delay. Maybe it's something like, "on update call this, but only once every X seconds" ?
RegisterForUpdate is one of EVENT_MANAGER's methods which calls function in specified intervals.
Lua Code:
  1. EVENT_MANAGER:RegisterForUpdate(identifier, interval, function)

identifier (string) - unique identifier, you can use for example name of your addon or some kind of description. If you register the same identifier again, it will overwrite previous function call.
interval (integer) - interval in milliseconds between function calls
function (function) - function which will be called


Example - function OnUpdate is called every 5 seconds (5000ms):
Lua Code:
  1. EVENT_MANAGER:RegisterForUpdate("DurabilityWarner", 5000, OnUpdate)

If you want to unregister this function call, use:
Lua Code:
  1. EVENT_MANAGER:UnregisterForUpdate(identifier)

Last edited by Garkin : 08/15/15 at 05:05 PM.
  Reply With Quote