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

[Question] Clear text and make new text in its spot?

Started by Edman, 07 October 2012 - 06:46 PM
Edman #1
Posted 07 October 2012 - 08:46 PM
I tried something like
print "Hello"
cls
print "potato"
cls
print "cow"

But apparently it doesnt work like that. So I found out about term.clear. That does the job but how do I set a delay to it?

Edit: Found out about os.sleep, sorry!
Goof #2
Posted 07 October 2012 - 08:52 PM
You Are programming in lua. That you need is : term.setCursorPos(1,1) to set the Mouse at the top left corner.
Term.clear() is clearing the screen, and term.setCursorPos() is setting the Mouse position..


cls is not existing in lua/minecraft. So if you want any other help, type 'help (program)'
brett122798 #3
Posted 07 October 2012 - 09:19 PM
Here's how you'd do something like that:


function cls() -- This is optional, you could just type 'term.clear()' but I suppose it's more comfortable for you to do this.   '
term.clear()
end

cls() -- Executes the function cls()
term.setCursorPos(1, 1) -- Sets the cursor to the upper left corner
print("Hello")
sleep(1)  -- Computer waits 1 second before it moves on
cls()
term.setCursorPos(1, 1)
print("potato")
sleep(1)
cls()
term.setCursorPos(1, 1)
print("cow")
sleep(1)
Edman #4
Posted 07 October 2012 - 09:20 PM
Thanks guys!
remiX #5
Posted 07 October 2012 - 09:33 PM
to make the code smaller you can do this


function cls(string)
  term.clear()
  term.setCursorPos(1,1)
  print(string)
end

cls("Hello")
sleep(1)
cls("potato")
sleep(1)
cls("cow")