﻿ Unreal Software - Thread: Tile Coordinates on table

# Forum

CS2D Scripts Tile Coordinates on table

# Tile Coordinates on table

3 replies
1

#### Tile Coordinates on table

Rhaast
User Offline

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

#### Re: Tile Coordinates on table

Rainoth
Moderator Offline

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:

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.

#### Re: Tile Coordinates on table

Gaios
Reviewer Offline

I recommend to use like
`my_table[x .. ' ' .. y] = val`
.
1
```my_table[(string) index]
```

#### Re: Tile Coordinates on table

Flacko
User Offline

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
```
1