Monday, 26 August 2013

Error: main.lua:22: attempt to index field '?' (a nil value)

Error: main.lua:22: attempt to index field '?' (a nil value)

I'm trying to get some 0 and 1 inside a multidimensional table but I can't
get it to work. I've searched through a lot of posts but I couldn't find a
way of solving it. This is the code:
generatedTerrain={
{0,0,0,0,0},
{0,0,0,0,0}
}
x=0
y=0
function mapGen()
for y=1,67 do
generatedTerrain[y]={}
for x=1,89 do
generatedTerrain[x][y] = math.random(0,1) --This doesn't work
end
end
end
mapGen()
end

No comments:

Post a Comment