Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gpu = require("component").gpu
- require("term").clear()
- local function setResolution(columns)
- local mw, mh = gpu.maxResolution()
- for i = 1, mh do
- gpu.setResolution(mw, i)
- local w, h = gpu.getResolution()
- if h >= columns then return end
- end
- end
- local function scrollText(texts, speed, cBack, cFore)
- local positions = {}
- gpu.setBackground(cBack)
- gpu.setForeground(cFore)
- setResolution(#texts)
- for i = 1, #texts do positions[i] = 0 end
- local width, height = gpu.getResolution()
- while true do
- for i = 1, #texts do
- gpu.fill(1, i, width, 1, " ")
- for j = positions[i], width, string.len(texts[i]) do
- gpu.set(j, i, texts[i])
- end
- positions[i] = positions[i] - 1
- if positions[i] <= -string.len(texts[i]) then positions[i] = 0 end
- end
- os.sleep(speed)
- end
- end
- local texts = {
- "Dies ist ein Test"
- }
- scrollText(texts, 0.5, 0x000000, 0xFFFFFF)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement