SHOW:
|
|
- or go back to the newest paste.
1 | - | local message = "Random test Message -- " |
1 | + | local function scroll(str,maxlen) |
2 | - | local tBuffer = {} |
2 | + | str=str:sub(-1,-1)==" " and str or str.." " |
3 | - | local termX = term.getSize() |
3 | + | local scrolled=0 |
4 | - | local place = 1 |
4 | + | while true do |
5 | - | local function addBuffer() |
5 | + | scrolled=scrolled%#str+1 |
6 | - | table.insert(tBuffer,string.sub(message,place,place)) |
6 | + | term.setCursorPos(1,1) |
7 | - | place = place == #message and 1 or place + 1 |
7 | + | write(str:rep(math.ceil((maxlen+scrolled)/str:len())):sub(scrolled,maxlen+scrolled)) |
8 | sleep(0.1) | |
9 | - | repeat addBuffer() |
9 | + | end |
10 | - | until #tBuffer == termX |
10 | + | |
11 | - | while true do |
11 | + | |
12 | - | term.setCursorPos(1,1) |
12 | + | scroll("hello, this is a test",10) |