Originally Posted by asett
Lua Code:
if tContains({...}, "MyMovingBarTemplate") then
|
On a side note, creating a bunch of single-use tables and using
tContains -- which, by the way, is not a real Lua or WoW API function, but is just a wrapper around a loop
written in Blizzard's Lua code for the default UI -- is pretty inefficient and will generate a lot of garbage, especially if you're making a lot of frames.
You should either create just one table from the arguments, at the beginning of the function, and refer to it for each check:
Code:
local templateList = { ... }
for i = 1, #templateList do
-- this enables us to do tbl["k"] instead of having
-- to loop over the table every time we want to see
-- if it contains something
templateList[templateList[i]] = true
end
if templateList["MyMovingBarTemplate"] then
-- add moving stuff
end
Also, if you end up adding more templates, you could split them out into their own functions to avoid having your
BuildFrame function be 500 lines of
if blocks:
Code:
-- outside of BuildFrame:
local templates = {
MyMovingBarTemplate = function(frame)
-- add moving stuff to frame
return frame
end
}
-- inside of BuildFrame, after creating the frame:
local templateList = { ... }
for i = 1, #templateList do
frame = templates[templateList[i]](frame)
end