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

How do i clear a specific Line?

Started by madscientist712, 27 February 2015 - 07:08 PM
madscientist712 #1
Posted 27 February 2015 - 08:08 PM
I have a program to load up my computer and say "booting up, please wait…")
but I wanted it to go with the dots going up like "." ".." then "…" However When i used "clear line" it didn't and went on the other line
like this:
Booting Up, Please wait.
Booting Up, Please wait..
Booting Up, Please wait…
Is there a way to have this on the same line?
Here is the code i'm on about


print("Booting Up, Please wait.")
sleep(1)
term.clearLine()
print("Booting Up, Please wait..")
sleep(1)
term.clearLine()
print("Booting Up, Please wait…")
sleep(1)
term.clearLine()
Anavrins #2
Posted 27 February 2015 - 08:13 PM
Simple, put the cursor back on the line…

local x, y = term.getCursorPos()
print("Booting Up, Please wait.")
sleep(1)
term.setCursorPos(x,y)
term.clearLine()
print("Booting Up, Please wait..")
sleep(1)
term.setCursorPos(x,y)
term.clearLine()
print("Booting Up, Please wait...")
sleep(1)
term.clearLine()
Edited on 27 February 2015 - 07:13 PM
Quintuple Agent #3
Posted 27 February 2015 - 09:12 PM
Well, since you are just adding '.'s you could just do

write("Booting Up, Please Wait.")
sleep(1)
write(".")
sleep(1)
write(".")
Bomb Bloke #4
Posted 27 February 2015 - 10:22 PM
… which works because "write" doesn't perform a line break like "print" does. And you can trim it down further:

write("Booting Up, Please Wait.")
textutils.slowPrint("..", 1)

Seriously though, this kind of thing is annoying for your users.