Sorry for bad english
Forum
Scripts
Tile Coordinates on table
Tile Coordinates on table
3 replies
1

Sorry for bad english
1
2
3
4
5
6
7
2
3
4
5
6
7
myTable = {}
for x = 0,map("sizex") do
	myTable[x] = {}
	for y = 0,map("sizey") do
		myTable[x][y] = "Your value here"
	end
end
Result:
myTable[20][30] = "Your value here"
myTable[69][420] = "Your value here"
If you simply want to store every tile coordinate possible, you do
1
2
3
4
5
6
2
3
4
5
6
myTable = {}
for x = 0,map("sizex") do
	for y = 0,map("sizey") do
		myTable[#myTable] = {x,y}
	end
end
myTable[5] = {1,4}
myTable[33] = {6,27}
The result values are only an example, they depend on how big your map is.
my_table[x .. ' ' .. y] = val.
1
my_table[(string) index]
1
2
3
4
5
2
3
4
5
function getTileIdx(x,y)
	return y*map('xsize')+x
end
myTable[getTileIdx(x,y)] = 5
1

Offline