32 lines
533 B
Lua
32 lines
533 B
Lua
|
return function(con)
|
||
|
|
||
|
con:on('res', function(w, h, cw, ch)
|
||
|
con.cw, con.ch = cw or con.cw, ch or con.ch
|
||
|
con.w, con.h =
|
||
|
math.floor(w / cw),
|
||
|
math.floor(h / ch)
|
||
|
con:emit('resT')
|
||
|
end)
|
||
|
|
||
|
con:on('resT', function()
|
||
|
local y = con.forText()
|
||
|
con.th = y * con.ch
|
||
|
end)
|
||
|
|
||
|
function con.down()
|
||
|
con.oy = 0
|
||
|
con.move(-math.huge)
|
||
|
end
|
||
|
|
||
|
function con.move(oy)
|
||
|
con.oy = con.oy + oy
|
||
|
con.oy = math.max(
|
||
|
-(con.th - con.ch * con.h / 1.2),
|
||
|
math.min(con.oy, 0)
|
||
|
)
|
||
|
if con.th < (con.ch - 1) * con.h
|
||
|
then con.oy = 0 end
|
||
|
end
|
||
|
|
||
|
end
|