I'm currently writing an ingame config for oUF_Diablo.
I set up 2 dropdown menus a user can choose tags from.
Lua Code:
--health tag list for dropdown
db.list.health_tag = {
{ value = "[diablo:healthorbtop]", key = "oUF_Diablo top default", },
{ value = "[diablo:healthorbbottom]", key = "oUF_Diablo bottom default", },
{ value = "[perhp]", key = "Health Percent", },
{ value = "[perhp]%", key = "Health percent + %", },
{ value = "[curhp]", key = "Current health", },
{ value = "[diablo:curhpshort]", key = "Current health short", },
{ value = "[maxhp]", key = "Max health", },
{ value = "[diablo:maxhpshort]", key = "Max health short", },
{ value = "[curhp]/[maxhp]", key = "Current/Max health", },
{ value = "[diablo:curhpshort]/[diablo:maxhpshort]", key = "Current/Max health short", },
{ value = "[diablo:empty]", key = "Empty", },
}
db.getListHealthTag = function() return db.list.health_tag end
---------------------------------------------
--LIST / POWER TAGs
---------------------------------------------
--power tag list for dropdown
db.list.power_tag = {
{ value = "[diablo:powerorbtop]", key = "oUF_Diablo top default", },
{ value = "[diablo:powerorbbottom]", key = "oUF_Diablo bottom default", },
{ value = "[perpp]", key = "Power Percent", },
{ value = "[perpp]%", key = "Power percent + %", },
{ value = "[curpp]", key = "Current power", },
{ value = "[diablo:curppshort]", key = "Current power short", },
{ value = "[maxpp]", key = "Max power", },
{ value = "[diablo:maxppshort]", key = "Max power short", },
{ value = "[curpp]/[maxpp]", key = "Current/Max power", },
{ value = "[diablo:curppshort]/[diablo:maxppshort]", key = "Current/Max power short", },
{ value = "[diablo:empty]", key = "Empty", },
}
db.getListPowerTag = function() return db.list.power_tag end
Currently I initiate my unitframes right on code execution.
I add the tag via:
Code:
self:Tag(fontString, tagName)
The problem that occured is the following.
I cannot "reset" the tag later on (on "VARIABLES_LOADED" event) to another tag. Or atleast I do not know how. Because I tried and it did not work.
Basically I initialize my unitframe with a default tag and rewrite it later if the savedVariables are loaded to the database values. Well that is my plan that I fail to succeed.
How do you handle unit tag initilization, especially with tags only available later on?
Actually I did not plan to suppress unit initilization until the database is loaded. Currently I run it with default values and have view functions that update stuff later on when needed.
Can I not add a tag on unitframe init and just add it once on VARIABLES_LOADED? That would be enough for my needs.
*edit*
Hmm...I think I have an idea. Why should I change the tag if I can change how the tag function reacts.
This may work out:
Lua Code:
---------------------------------------------
--HealthOrbTop
oUF.Tags.Methods["diablo:HealthOrbTop"] = function(unit)
local methodName = db.char["HEALTH"].value.top.tag
return oUF.Tags.Methods[methodName](unit) or ""
end
oUF.Tags.Events["diablo:HealthOrbTop"] = "UNIT_HEALTH UNIT_MAXHEALTH UNIT_CONNECTION"
---------------------------------------------
--HealthOrbBottom
oUF.Tags.Methods["diablo:HealthOrbBottom"] = function(unit)
local methodName = db.char["HEALTH"].value.bottom.tag
return oUF.Tags.Methods[methodName](unit) or ""
end
oUF.Tags.Events["diablo:HealthOrbBottom"] = "UNIT_HEALTH UNIT_MAXHEALTH UNIT_CONNECTION"
---------------------------------------------
--PowerOrbTop
oUF.Tags.Methods["diablo:PowerOrbTop"] = function(unit)
local methodName = db.char["POWER"].value.top.tag
return oUF.Tags.Methods[methodName](unit) or ""
end
oUF.Tags.Events["diablo:PowerOrbTop"] = "UNIT_DISPLAYPOWER UNIT_POWER UNIT_MAXPOWER UNIT_CONNECTION"
---------------------------------------------
--PowerOrbBottom
oUF.Tags.Methods["diablo:PowerOrbBottom"] = function(unit)
local methodName = db.char["POWER"].value.bottom.tag
return oUF.Tags.Methods[methodName](unit) or ""
end
oUF.Tags.Events["diablo:PowerOrbBottom"] = "UNIT_DISPLAYPOWER UNIT_POWER UNIT_MAXPOWER UNIT_CONNECTION"
---------------------------------------------
Basically on my orbs I have 2 value strings each. Thus I run 4 tags. Each of those tags can be set to any methodName. The choosen method is then loaded on tag update by itself.
Going to test it later.