Hi!
Can someone help me spot the error in this code? I know an “invalid key to next” is something related to changing a table which you are currently running through in pairs(). But I can’t see where i am doing that
if message_id == hash("yourinfo")then
self.levelno = message[2]
self.mystatus = message[1]
self.levelplan = message[3]
if message[1] == 0 then--level is not available.
elseif message[1] > 0 then --level is available, make image!
for key, value in pairs(self.levelplan) do
self.placed = self.placed + 1
self.tiletype= {0,0,0,0}
self.yvalue = (((self.placed%10)*64)+128)+64
self.xvalue = (math.floor(self.placed/10)*64+128)
if value == 9 or value == 5 or value == 8 or value == 7 or value == 6 then
if self.levelplan[key-10] == nil or self.levelplan[key-10] == 0 then
self.tiletype[3] = 1 --(left)
end
if self.levelplan[key+10] == nil or self.levelplan[key+10] == 0 then
self.tiletype[4] = 1 (right)
end
if self.levelplan[key-1] == nil or self.levelplan[key-1] == 0 then
self.tiletype[2] = 1 --(down)
end
if self.levelplan[key+1] == nil or self.levelplan[key+1] == 0 then
self.tiletype[1] = 1 --(up)
end
self.props = { self.tiletype[1],self.tiletype[2],self.tiletype[3],self.tiletype[4] }
factory.create("#tile", vmath.vector3(self.xvalue, self.yvalue, 0), nil, self.props, vmath.vector3(self.tilescale ,self.tilescale ,1))
end
end
end
end