Lua dynamic class name possible ?
Hello everyone;
I'm new in LUA, i want to set a dynamic name class, for exemple : Lua Code:
It's not work ! :'( But this, is good : Lua Code:
How to dynamically assign the name of a class after the first object ? Ex Test.About._G[Test], Test.About.(Test), Test.About.{Test} ? |
You need a simpler example
local a = {} --a is a table a.a = 1 a.b = 2 c = "a" print(a[c]) --should print 1 c = "b" print(a[c]) --should print 2 |
I don't really understand what you're looking for, but I can tell you that this:
Code:
Test.About._G[Test] Code:
Test["About"]["_G"][Test] You probably want this: Code:
Test.About[_G[Test]] |
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:
All good, no problem ! I have ImagineTestFrame0, ImagineTestFrame1, ImagineTestFrame2, ImagineTestFrame3 ... If I want to use class, i can this, ex : Lua Code:
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:
I have "attempt to index field '_G' (a nil value)" error. Thank for your help. |
Lua Code:
|
Quote:
You have solve my problem, thank so much :). |
Beside that you should unterstand what _G is, that is the global table in lua holding all the global stuff, there is no need at all to ever attach it like you did
|
Also this part:
Code:
Imagine["TestFrame"..i] = CreateFrame("Frame",Imagine["TestFrame"..i],UIParent) Code:
Imagine["TestFrame"..i] = CreateFrame("Frame",nil,UIParent) |
All times are GMT -6. The time now is 09:33 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI