Hi, I am trying to write get a variable from another file. But I have a question about it.
suppose I have 2 files, “main.lua” and “stage1.lua”, I am trying to get the defined constant from stage.lua to main.lua. Please look at the sample code below, if I use “x = stage1.level1.varX” it works fine, but x = “stage” …stage… “.level” … level … “.varX” doesn’t work at all. Would you please give me some suggestion ??
Hope you understand what I am trying to ask…sorry about my English isn’t too good.
stage1.lua
level1 =
{
varX = 300,
varY = 300,
}
main.lua
local stage = 1
local level = 1
local x,y
x = stage1.level1.varX – This Works !
y = stage1.level1.varY – This Works !
x = “stage” …stage… “.level” … level … “.varX” --This doesn’t
y = “stage” …stage… “.level” … level … “.varY” --This doesn’t
[import]uid: 38556 topic_id: 12889 reply_id: 312889[/import]
[import]uid: 3826 topic_id: 12889 reply_id: 47326[/import]