forked from hkc/cc-stuff
1
0
Fork 0
cc-stuff/mess/scrolling-text.lua

43 lines
939 B
Lua

local lines = { "owo" }
for line in io.lines("cc-stuff/mess/scrolling-text.lua") do
table.insert(lines, line)
end
local function drawScrollingText(x, y, w, time, t)
term.setCursorPos(x, y)
if #t <= w then
term.write(t)
return
end
time = (time % (#t + 5)) + 1
term.write((t .. " ::: " .. t):sub(time, time + w - 1))
end
term.clear()
term.setCursorPos(1, 1)
term.setCursorBlink(false)
parallel.waitForAny(
function()
local time = 0
while true do
local tw, th = term.getSize()
for i = 1, th do
local txt = lines[((#lines - th + i - 1) % #lines) + 1]
drawScrollingText(math.floor(tw / 2) - i, i, i * 2, time, txt)
drawScrollingText(math.floor(tw / 2) - i, i, i * 2, time, txt)
end
time = time + 1
os.sleep(0.05)
end
end,
function()
os.pullEvent("key")
end,
function()
os.sleep(10)
end)
print("exited")