WoWInterface - View Single Post - Lua dynamic class name possible ?
View Single Post
03-04-15, 05:46 AM   #4
A Defias Bandit
Join Date: Mar 2015
Posts: 3
Hello and thanks for your reply.
Sorry, but you dont understand what i want.

Imagine i want to create ten frame each with a different name, ex:

Lua Code:
  1. for i=0,10 do
  2.     _G["ImagineTestFrame"..i] = CreateFrame("Frame","ImagineTestFrame"..i,UIPanelButtonTemplate)
  3. end

All good, no problem !
I have ImagineTestFrame0, ImagineTestFrame1, ImagineTestFrame2, ImagineTestFrame3 ...

If I want to use class, i can this, ex :

Lua Code:
  1. Imagine = CreateFrame("Frame",Imagine,UIParent)
  2. Imagine.TestFrame0 = CreateFrame("Frame",Imagine.TestFrame0,UIParent)
  3. Imagine.TestFrame1 = CreateFrame("Frame",Imagine.TestFrame1,UIParent)
  4. Imagine.TestFrame2 = CreateFrame("Frame",Imagine.TestFrame2,UIParent)
  5. Imagine.TestFrame3 = CreateFrame("Frame",Imagine.TestFrame3,UIParent)

All good, i have Imagine.TestFrame0,Imagine.TestFrame1,Imagine.TestFrame2,Imagine.TestFrame3

But if i want use my for function to automatical create lots of TestFrame with class system, how can i do ?
For exemple what i want and not work :'( :

Lua Code:
  1. Imagine = CreateFrame("Frame",Imagine,UIParent)
  2. for i=0,10 do
  3.     Imagine._G["TestFrame"..i] = CreateFrame("Frame",Imagine._G["TestFrame"..i],UIParent)
  4. end

I have "attempt to index field '_G' (a nil value)" error.

Thank for your help.
  Reply With Quote