What I need to do is loop through the table so that the index table[1][1] is grabbed, and then index table[2][1], and so on. Then, I need to loop through the next so that index table[1][2] is grabbed and then index table[2][2].
Let me know if you need any other information for how this should work.
Right now I have a system that loops through the array vertically:
for i, column in pairs(table) do
for j, space in pairs(column) do
local index = Vector2.new(i, j)
return index
end
end
Essentially I just need help understanding how to make a function that would do the same thing horizontally across the table, looping through each row instead of each column.
You could probably make a table called scraps, which any unneeded values can be stored in, and eventually cleared when the loop is broken or has been breaked.
Right. So you are saying store those values in a table. What do I do with them though? I am attempting to loop through the table in a certain way, I just don’t know how. That is what I need help understanding. How should I loop through the table so that the order is like so:
index[1][1], index[2][1], index[1][2], index[2][2], -- and so on
You could probably make your own algorithm for looping. By the looks of it, it looks like your second table value goes up by one each two logs. For your first table, it looks like it goes back to back.
I ended up figuring this out on my own, but thank you for your help.
For those wondering (literally no one) here is what I did:
for i = 1, #grid_table[1] do
for j = 1, #grid_table do
local index = Vector2.new(j, i)
return index
end
end
This iterates through the number of rows (#table[1]) and then for each row, iterates through the number of spaces in each row (#table). The index would then be the column, j, and the space, i.
You told me to make my own looping algorithm. How is that helpful? There was no instruction at all other than essentially saying “make your own loop”.