# How to find a table inside a table instantly?

``````seed.assignpart = function(t, x, y, n, newt)
if t[x] ~= nil then
if t[x][y+1] ~= nil and t[x][y+1].Visited.Value == false then
local part1 = t[x][y+1]
seed.changeproperty(part1, n)
table.insert(newt, {x, y+1})
end
end
if t[x] ~= nil then
if t[x][y-1] ~= nil and t[x][y-1].Visited.Value == false then
local part2 = t[x][y-1]
seed.changeproperty(part2, n)
table.insert(newt, {x, y-1})
end
end
if t[x-1] ~= nil then
if t[x-1][y] ~= nil and t[x-1][y].Visited.Value == false then
local part3 = t[x-1][y]
seed.changeproperty(part3, n)
table.insert(newt, {x-1, y})
end
end
if t[x+1] ~= nil then
if t[x+1][y] ~= nil and t[x+1][y].Visited.Value == false then
local part4 = t[x+1][y]
seed.changeproperty(part4, n)
table.insert(newt, {x+1, y})
end
end

for i,v in pairs(newt) do
if v[1] == x and v[2] == y then
table.remove(newt, i)
end
end
end
``````

The key is saved in a table as a table to retrieve the grid coordinate info later. Is it possible to instantly find the specific table (ex : {1,5}) instead of constantly checking the whole parent table?

You could probably set the index to a string containing the coordinates, and then have the value be a table with the actual x y cords.

Something like this:

``````local t = {}
local x = 5
local y = 2

t[x..","..y] = {x,y}

print(t[x..","..y])
``````

There could be a better way to do this but this is what I came up with.