
This screenshot is represented by 4 x pixel version of






edited 2×, last 29.12.15 02:12:34 pm
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