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

scrolling text in terminal

Started by Waitdev_, 03 July 2015 - 08:23 AM
Waitdev_ #1
Posted 03 July 2015 - 10:23 AM
i wanna make a terminal scrolling thing to show items in a table, but how do i do that?
for an example


table1 = {"item1","item2","item3"}
function scroll(table)
--scroll through items on a table
end
scroll(table1)
that will output

item1 | item2 | item3 | item1 | item2 | item3 | ite

and continue scrolling like that.
Lupus590 #2
Posted 03 July 2015 - 12:23 PM

function scroll(tab) --#table is a global variable, so I will use tab
  start.x, start.y = term.getCursorPosition() --#this is in 1.74 only (I think). An alternative is to pass these as parameters. Also I may be getting the function names slightly wrong
  for i, #tab do
	term.setCursorPosition(unpack(start))
	print(tab[i]) --#this may leave some leftover characters from the previous string
	--#a solution to above comment would be to print spaces till this combined string is the same length as the longest one in your table
	sleep(1000)--#wait one second so we can see it
  end--#for loop
end--#function
Edited on 03 July 2015 - 10:23 AM
Waitdev_ #3
Posted 03 July 2015 - 12:43 PM
didn't work :/
i'm using CC 1.73
Edited on 03 July 2015 - 10:44 AM
Waitdev_ #4
Posted 03 July 2015 - 01:41 PM
nvm, i found out a way to do it :)/>
Lupus590 #5
Posted 03 July 2015 - 01:44 PM
try this, also I did say in the other one that some of the function calls may be wrong (the wiki helps when you use it)

function scroll(tab) --#table is a global variable, so I will use tab
  start.x, start.y = term.getCursorPos() --#this is in 1.74 only (I think). An alternative is to pass these as parameters.
  for i, #tab do
		term.setCursorPos(unpack(start))
		print(tab[i]) --#this may leave some leftover characters from the previous string
		--#a solution to above comment would be to print spaces till this combined string is the same length as the longest one in your table
		sleep(1000)--#wait one second so we can see it
  end--#for loop
end--#function

edit: :ph34r:/>
Edited on 03 July 2015 - 11:44 AM
TheOddByte #6
Posted 04 July 2015 - 11:43 PM
- snip -
Just want to point out that in both of your code-snippets you put this

sleep( 1000 )
That wouldn't sleep 1 second, it would sleep 1000 seconds, remember that it works differently in ComputerCraft :P/>
Lupus590 #7
Posted 05 July 2015 - 12:48 AM
- snip -
Just want to point out that in both of your code-snippets you put this

sleep( 1000 )
That wouldn't sleep 1 second, it would sleep 1000 seconds, remember that it works differently in ComputerCraft :P/>

oh yeah, opps
meigrafd #8
Posted 06 July 2015 - 12:52 PM
nvm, i found out a way to do it :)/>/>

How?