Thread Tools Display Modes
07-16-10, 04:04 PM   #1
wellbeing
A Cliff Giant
Join Date: Oct 2009
Posts: 71
Naming a parent with a variable in LUA

this code works perfectly except for one thing.
the issue i am having is when trying to dynamically name the parent for the created frame.

i dont know how to do it. everything i can think to send it is a string.. and that just won't do. any ideas? if there isnt a built in solution, ill have to create another table of getparent data for some new otherwise useless frames and and do more for/do structure to generate the parent name per loop.. seems there has to be a better way.


Code:
function SMmainframe:PARTY_CONVERTED_TO_RAID()
    print("converted to raid")
        
    size_of_raid = GetNumRaidMembers()
    for i=1, size_of_raid do
    name, rank, subgroup, level, class = GetRaidRosterInfo(i)
    raid_data[i] = { name=name, rank=rank, subgroup=subgroup, level=level, class=class}
    raid_slot = ("SMraidslot"..i) -- this is where i am creating the string for the "parent" parameter of frame creation.
    print (raid_slot)
    raidunit = CreateFrame("FRAME", nil, raid_slot)
    raidunit:SetFrameStrata("BACKGROUND")
    raidunit:SetWidth(108)
    raidunit:SetHeight(14)
    raidunit:SetBackdrop(backdrop2)
    raidunittxt= raidunit:CreateFontString(nil, "ARTWORK")
    raidunittxt:SetPoint("CENTER", 0, 1)
    raidunittxt:SetFont("Fonts\\FRIZQT__.TTF", 8)
    raidunittxt:SetShadowOffset(2, -2)
    tt = raidunit:CreateTexture(nil, "ARTWORK")
    tt:SetTexture(0,0,0,1)
    tt:SetAllPoints(SMraidslot1)
    raidunittxt.texture = tt
    raidunittxt:SetText(name.." - "..class)
    raidunittxt:SetTextColor(1, 1, 1, 1) 
    raidunit:SetPoint("TOPLEFT", 1, -1)
    raidunit:Show()
    end
    
    
    -- do stuff here
end
  Reply With Quote
07-16-10, 04:09 PM   #2
wellbeing
A Cliff Giant
Join Date: Oct 2009
Posts: 71
Slakah just told me in irc"

use _G[raid_slot] in the createframe parameter. works.

YAY!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Naming a parent with a variable in LUA


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off