Originally Posted by Kygo
Having a rough time following along in your example due to the use of "self"
|
There's nothing magical about "self" -- it's just a variable name. The only time it's somewhat magical is when you use method notation. If you've got this:
Code:
local addon = {}
addon.name = "My Addon"
Then these are effectively identical:
Code:
function addon.PrintName(self) -- dot
print("My name is:", self.name)
end
Code:
function addon:PrintName() -- colon
print("My name is:", self.name)
end
... and regardless of which way you constructed your function, you can call it either of these ways:
Code:
addon:PrintName()
addon.PrintName(addon)
The only difference is that when calling your function with a colon, "self" is automatically defined as a reference to "addon" inside the function, whereas when you call it with a dot, you have to pass the reference yourself.
In the two sections of my oUF layout I linked,
the section in Functions.lua defines a function (without a colon, so the "self" is explicitly named in the list of arguments it accepts) and
the section in Frames.lua attaches that function to the frame's Power element under the name "PostUpdate". Later, each time oUF updates the Power element, it checks if the element has a "PostUpdate" function and, if it does,
calls that function (with a colon, so "self" is automatically passed as the first argument).
Originally Posted by Kygo
I have a color table that the powerbar itself are using, not sure if that counts as the correct information needed tho?
|
That's part of it, but I can't actually find where you were even using the "ClassPowerText" table, so I can't actually give you an example of correct usage.
However, while I was looking, I noticed this:
Code:
oUF.Tags.Events["readycheckicon"] = "DoReadyCheck"
oUF.Tags.SharedEvents["IsInGroup"] = true
oUF.Tags.Methods["readycheckicon"] = function(unit)
if unit == "player" and IsInGroup() then
return [[|TInterface\RAIDFRAME\ReadyCheck-Ready|t]]
end
end
1. "DoReadyCheck" and "IsInGroup" are functions, not events, so your tag won't update properly. It'll only be updated at times when all elements get updated, like when you pass through a loading screen.
2. Your tag function checks for the "player" unit, so your tag would never display anything on other units, which rather defeats the point of a ready check icon.
3. There's not really any need to check if you're in a group, since there can't be a ready check if you're not in a group.
4. Your current code will cause an icon to be displayed all the time while you're in a group, since you're not actually checking the unit's ready check status.
5. oUF already provides a ReadyCheck element that will show not just the green "ready" icon, but also the red "not ready" and yellow "waiting" icons. It looks like you may have borrowed some tags from my layout -- most of those aren't strictly necessary since oUF already provides icon elements for most of that stuff, and I'm just using tags so I can put them all in a row that auto-adjusts without having to reposition texture objects. For static icons that always appear in the same place, just use the real elements.