I am wondering how you would go about making a array with two indexes. I am used to using int[,] for C# but in Lua i do not know how i can accomplish this?
I am using this to store information in a [x,y] grid array were i set a value like 1 or 5. This is to store information about a 2D terrain when generating for placing objects. I do not know if that helps with the question.
In Lua you can just make a table where each index is another table.
local array = {} for i = 1, 10 do local new = {} array[i] = new for j = 1, 10 do new[j] = (i-1)*10+j end end
If you want to set a value of some index higher than 10 in this case, you need to add another table first, e.g.
array[27] = {} array[27][16] = 5
accessing values is no surprise
print(array[5][2])
52
All a multidimensional array in Lua is is a table that has other tables inside of it.