This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ExtendLord's profile picture

How can i scroll though printed texts

Started by ExtendLord, 12 September 2015 - 07:33 PM
ExtendLord #1
Posted 12 September 2015 - 09:33 PM
Ive created server that writes logs and i cant scroll up or down
how can i make a code that allows me to scroll though print()'s?
like term.scroll() but without erase print() texts
Edited on 13 September 2015 - 10:06 AM
KingofGamesYami #2
Posted 13 September 2015 - 12:21 AM
Just put it in a file and use the default 'edit' program. It's easier than (essentially) rewriting the edit program.
ExtendLord #3
Posted 13 September 2015 - 12:06 PM
Just put it in a file and use the default 'edit' program. It's easier than (essentially) rewriting the edit program.
I want to able to scroll up/down though print() inside script
I tryed to place edit's scroll up/down and its not working.
How can i term.scroll() without delete print()'s.
Konlab #4
Posted 20 September 2015 - 08:06 AM
Just put it in a file and use the default 'edit' program. It's easier than (essentially) rewriting the edit program.
I want to able to scroll up/down though print() inside script
I tryed to place edit's scroll up/down and its not working.
How can i term.scroll() without delete print()'s.
Instead of printing logs save them in a table. If you want to draw the contents:
for i=scroll, scroll+height do
print(tbl[i])
end
Where height is the term's height, scroll is a number which is changed while scrolling and tbl is the table containing lines.
LeDark Lua #5
Posted 20 September 2015 - 09:11 AM
And the print function is not the case:

for i=1, #textTable do
  term.setTextColor(colors.orange)
  term.setCursorPos(1,  i+scrollPoint-1)
  term.write(textTable[i])
end
Konlab #6
Posted 20 September 2015 - 03:30 PM
And the print function is not the case:

for i=1, #textTable do
  term.setTextColor(colors.orange)
  term.setCursorPos(1,  i+scrollPoint-1)
  term.write(textTable[i])
end
Your code will work too, but mine will only show from scroll to scroll+height -> only displaying 19 lines on computers, while yours is drawing everything, which is slower and it will cause flickering. (Mine will probably flicker too, i didnt tested it)
LeDark Lua #7
Posted 20 September 2015 - 03:36 PM
Well if you wan't to display only on the screen, use the code below:

scrollPoint=scrollPoint-event[2]
if scrollPoint>#text-1 then
scrollPoint=#text
end
if scrollPoint>1 then
scrollPoint=1
end
if scrollPoint+#text<19 then
scrollPoint=scrollPoint+1
end

EDIT: And "print" has its own string history and it will do weird stuff if you use it.
Edited on 20 September 2015 - 01:38 PM