-
Posted by Perfexion on Sun, 26 Jul 2009 02:03:17
Hello,
I am playing with chapter 13 in the book, I have finished the TargetText addon, now what I want to do is have a similar playerText frame as well. I would like to be able to do create functions (for example the TargetText:UpdateName function) which will accept a few arguments (In this case a frame and a Unit) and which will perform what that function would have done on the TargetText Frame, except do it on any frame which I send.
If that wasn't very clear (It wasn't), here is some code showing what I think I should do
this is the function:
function TargetText:UpdateName(thisFrame, thisUnit) thisFrameName.SetText(UnitName(thisUnit)) -- <--** end
I want to be able to call this function for instance under the TargetText:UpdateAll function and send it the frame and the unit like this:
self:UpdateName(TargetTextFrame, "target")
I realize the line with the commented out <--** will not work. I realize that I am telling it to set the text of thisFrameName which doesnt exist. What I want to be able to do is have it set the text of the font string called Name on the frame that I sent it, where that font string, when created in the XML, is named $parentName.
Anyone know how to do this?
``
-
Posted by Perfexion on Sun, 26 Jul 2009 02:08:03
The point of this is, if for instance I wanted to make a frame like the TargetTextFrame for my target, me, each of my party members, and each of my raid members, (I surely wouldn't do it for every raid member, but if I did)I would like to be able to for instance make a table with each frame name, and update information on every frame in the loop, instead of making an updateName, updateLevel, etc... function for each frame.
-
Posted by jnwhiteh on Sun, 26 Jul 2009 13:28:22
function TargetText:UpdateName(thisFrame, thisUnit) thisFrameName.SetText(UnitName(thisUnit)) -- <--** end
What you want instead is the following:
function TargetText:UpdateName(frame, unit) local name = _G[frame:GetName() .. "Name"] name:SetText(UnitName(unit)) end
The first line just queries the name of the frame you passed in, and then looks for BlahFrameName, setting the text on it.
Let me know if that doesn't make sense.
-
Posted by Perfexion on Sun, 26 Jul 2009 19:21:02
Thank you, this is what I was looking for.