Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local offset = 0
- local lines = {} -- load all lines you want to display here
- local termw, termh = term.getSize()
- -- for testing
- for i = 64, 69 + termh do lines[#lines + 1] = string.char(i) end
- local redraw = function()
- term.clear()
- for i = 1, termh do
- term.setCursorPos(1, i)
- term.write(lines[i + offset])
- end
- end
- redraw()
- local running = true
- while running do
- local event, p1 = os.pullEvent()
- if event == "mouse_scroll" then
- if p1 == 1 and offset < math.max(#lines - termh, 0) then
- offset = offset + 1
- redraw()
- end
- if p1 == -1 and offset > 0 then
- offset = offset - 1
- redraw()
- end
- end
- if event == "key" and p1 == 157 then running = false end -- rigth control stops the program
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement