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0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,},
{"a" ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,"b" ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,},
{0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,"c" ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,},}
I tried to atleast save "a", "b" and "c" to a table but i cant even do that, as the print() function returns nil.
Code: Select all
for y, xs in ipairs(grid ) do
for x, value in ipairs(xs) do
if value == "a" then
print("a is at x/y:" .. x .. "/" .. y)
local a = {aX = x, aY = y}
table.insert(aTable, a)
end
if value == "b" then
print("b is at x/y:" .. x .. "/" .. y)
local b = {bX = x, bY = y}
table.insert(bTable, b)
end
if value == "c" then
print("c is at x/y:" .. x .. "/" .. y)
local c = {cX = x, cY = y}
table.insert(cTable, a)
end
end
end
print(aTable[1][1])
Thanks