Forum
![>](img/i_next.png)
![>](img/icons/cs2d.png)
![>](img/i_next.png)
![>](img/i_next.png)
Convert Tile in Pos
6 replies![To the start](img/i_first.png)
![Previous](img/i_prev.png)
![Next](img/i_next.png)
![To the start](img/i_last.png)
x=tilex*32
y=tiley*32
But I don't know, is it center of tile or top-left corner. So, if it is top-left corner, if you want to set pos to the center, then:
x=tilex*32+16
y=tiley*32+16
px and py = position in pixels
tx and ty = position in tiles
position in pixels -> tile position:
px/32 = tx
py/32 = ty
tile position -> position in pixels (top left of tile)
tx*32 = px
ty*32 = py
tile position -> position in pixels (center of tile)
tx*32+16 = px
ty*32+16 = py
1
2
3
4
5
6
7
2
3
4
5
6
7
function adm_teletile_admin(p, typ, cmd) 	cmd = args(cmd) 	local i = cmd[1] 	local x = cmd[2] 	local y = cmd[3] 	parse(string.format("setpos %s %s %s", i, x*32+16, y*32+16)) end
http://svn.cs2d.org/amx2d/core/basic.lua
![](img/smiles/sad.gif)
![](img/smiles/veryfrightened.gif)
Why this isnt work? :
addhook("projectile" , "ball_ground")
function ball_ground(id,x,y)
parse("strip "..id.." 75")
parse("spawnitem "..tx*32.." "..ty*32.." 75")
end
Do you know what variables are?
1
2
3
4
5
2
3
4
5
addhook("projectile" , "ball_ground") function ball_ground(id,x,y) parse("strip "..id.." 75") parse("spawnitem "..math.floor(x/32).." "..math.floor(y/32).." 75") end
![To the start](img/i_first.png)
![Previous](img/i_prev.png)
![Next](img/i_next.png)
![To the start](img/i_last.png)