Hey guys,
Here is what im trying to do…
I have my ‘gameplay.lua’ file for the gameplay scene
And I have ‘myData.lua’ for the levels data
In ‘myData.lua’ file there is a table like this that holds the level’s 0-100 data:
[lua]
local level0To100 = {
level0={
boardLevel = {
{1,3,3,1,5,2,1,2},
{3,2,3,3,2,2,3,4},
{2,5,5,6,4,6,4,6},
{4,4,1,3,2,5,1,1},
{4,4,2,1,1,3,1,3},
{3,3,5,6,2,2,3,2},
{6,2,2,6,2,5,2,4},
{1,1,4,5,1,4,4,1},
}
,BoardShapeID=2
,GameType = 0
,TimeLeft = 30
,GameTarget = 2
,MovesLeft = 0 }
,
level1={
boardLevel = {
{1,3,3,1,5,2,1,2},
{3,2,3,3,2,2,3,4},
{2,5,6,5,5,6,4,6},
{3,2,3,4,1,3,1,1},
{3,6,6,4,2,5,1,3},
{1,3,6,3,1,1,6,2},
{6,2,5,6,2,6,2,4},
{1,1,4,5,3,4,4,1},
}
,BoardShapeID=17
,GameType = 1
,TimeLeft = 60
,GameTarget = 1500
,MovesLeft = 0 }
,
level2={
boardLevel = {
{1,3,3,1,5,2,1,2},
{3,2,3,3,2,2,3,4},
{2,5,6,5,5,6,4,3},
{3,6,3,4,1,3,3,5},
{3,6,1,2,2,1,1,3},
{1,1,4,1,5,6,2,3},
{3,2,3,3,2,3,2,4},
{1,1,4,5,3,4,4,1},
}
,BoardShapeID=18
,GameType = 2
,TimeLeft = 5 – in seconds
,GameTarget = 2000
,MovesLeft=13 }
}
– … you got the point
[/lua]
In my gameplay scene I require the file:
[lua]local mydata = require(“mydata”) [/lua]
And then I try to grab the correct level data like so
[lua]
– in gameplay.lua file
local currGameData = mydata[“level0To100”][“level”…_levelNum]
– _levelNum is an integer with the value of the current level
[/lua]
This doesnt seems to work…I get the error
“attempt to index field ‘level0To100’ (a nil value)”
Any help?
Roy.
