Originally Posted by Capadillo
EDIT: I am assuming that "EVENT_POWER_UPDATE" will return all of the information for updating the individual powers as well, so we would only need to use "GetUnitPower" to force an update, or during login?
|
Yes, exactly
First you have your event:
EVENT_POWER_UPDATE (
string unitTag,
luaindex powerIndex,
integer powerType,
integer powerValue,
integer powerMax,
integer powerEffectiveMax)
You have to register it before using it like this:
Lua Code:
EVENT_MANAGER:RegisterForEvent("YOUR_ADDON_NAME", EVENT_POWER_UPDATE, eventUpdatePower)
You can see a line like this at the beginning of almost every addon.
Then your first function will be:
Lua Code:
local function eventUpdatePower(eventCode, unit, powerIndex, powerType, powerCurrent, powerMax)
...
For what remains I think you are pretty much right.
You need more things (Controls, Anchor, etc...) but you are in the good way