Forum

> > CS2D > Scripts > Tile Coordinates on table
Forums overviewCS2D overview Scripts overviewLog in to reply

English Tile Coordinates on table

3 replies
To the start Previous 1 Next To the start

old Tile Coordinates on table

Rhaast
User Off Offline

Quote
Hello USGN'ers! Sorry to bother you. How can I put a tile coordinates on a table script?

Sorry for bad english

old Re: Tile Coordinates on table

Rainoth
Moderator Off Offline

Quote
1
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
If you want to store values based on tiles.
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
myTable = {}
for x = 0,map("sizex") do
	for y = 0,map("sizey") do
		myTable[#myTable] = {x,y}
	end
end
Result:
myTable[5] = {1,4}
myTable[33] = {6,27}
The result values are only an example, they depend on how big your map is.

old Re: Tile Coordinates on table

Flacko
User Off Offline

Quote
Using the array part of the table is probably the most efficient method. You need a function to map (X,Y) coords to table index:

1
2
3
4
5
function getTileIdx(x,y)
	return y*map('xsize')+x
end

myTable[getTileIdx(x,y)] = 5
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview