1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
local playersZ = {} --// Height of players
local playersPos = {} --// {tileX, tileY}
local tiles = {} --// Height
local tilecount = map("tilecount")
for i=0,tilecount do
	if (i % 3 == 0) then
		tiles[i] = 0
	elseif (i % 3 == 1) then
		tiles[i] = -1
	else
		tiles[i] = 1
	end
end
--// Init height
for i=1,32 do
	playersZ[i] = 0
	playersPos[i] = {0, 0}
end
addhook("spawn", "spawnHook")
function spawnHook(id)
	playersPos[id] = {player(id, "tilex"), player(id, "tiley")}
	playersZ[id] = tiles[tile(player(id, "tilex"), player(id, "tiley"), "frame")]
end
--// A player looses damage on fall
addhook("movetile", "moveTileHook")
function moveTileHook(id, x, y)
	local tileHeight = tiles[tile(x, y, "frame")]
	local playerHeight = playersZ[id]
	local prevX = playersPos[id][1] * 32
	local prevY = playersPos[id][2] * 32
	if (playerHeight < tileHeight) then
		parse("setpos "..id.." "..(prevX+16).." "..(prevY+16)) --// center the player
	elseif (playerHeight > tileHeight) then
		parse("slap "..id)
		playersPos[id] = {x, y}
		playersZ[id] = tileHeight
	else
		playersPos[id] = {x, y}
	end
end