Jump to content




scrolling text in terminal


  • You cannot reply to this topic
7 replies to this topic

#1 Waitdev_

  • Members
  • 432 posts
  • LocationAdelaide

Posted 03 July 2015 - 09: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.

#2 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

Posted 03 July 2015 - 11:23 AM

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 by Lupus590, 03 July 2015 - 11:23 AM.


#3 Waitdev_

  • Members
  • 432 posts
  • LocationAdelaide

Posted 03 July 2015 - 11:43 AM

didn't work :/
i'm using CC 1.73

Edited by Wait_, 03 July 2015 - 11:44 AM.


#4 Waitdev_

  • Members
  • 432 posts
  • LocationAdelaide

Posted 03 July 2015 - 12:41 PM

nvm, i found out a way to do it :)

#5 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

Posted 03 July 2015 - 12: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 by Lupus590, 03 July 2015 - 12:44 PM.


#6 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 04 July 2015 - 10:43 PM

View PostLupus590, on 03 July 2015 - 12:44 PM, said:

- 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

#7 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

Posted 04 July 2015 - 11:48 PM

View PostTheOddByte, on 04 July 2015 - 10:43 PM, said:

View PostLupus590, on 03 July 2015 - 12:44 PM, said:

- 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

#8 meigrafd

  • Members
  • 17 posts
  • LocationGermany

Posted 06 July 2015 - 11:52 AM

View PostWait_, on 03 July 2015 - 12:41 PM, said:

nvm, i found out a way to do it :)/>

How?





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users