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

Issues with term.clear

Started by herrozerro, 22 March 2012 - 05:04 PM
herrozerro #1
Posted 22 March 2012 - 06:04 PM
I am trying to run a program that clears the screen between text but i keep having issues with it. here is my code:

term.clear

print("text blerb")
sleep(5)
term.clear
term.setCursorPos(1,1)
print("more text")

term.clear
term.setCursorPos(1,1)
write("Please enter your password")

input = read()


term.clear
term.setCursorPos(1,1)

if input == "pass" then
print("correct")
redstone.setOutput("back",true)
else
print("incorrect")
end
os.shutdown()

this this a get bios:206: [string "startup"]:3: '=' expected.

any help wouldbe great. thanks!
Liraal #2
Posted 22 March 2012 - 06:17 PM
term.clear()
Dirkus7 #3
Posted 25 March 2012 - 11:27 PM
Term.clear() is a function, not a variable so there must be brackets () after term.clear(). I prefer using shell.run('clear') because it's shorter and it does the same.
Espen #4
Posted 26 March 2012 - 05:41 AM
Term.clear() is a function, not a variable so there must be brackets () after term.clear(). I prefer using shell.run('clear') because it's shorter and it does the same.
But term.clear() has 12 characters, whereas shell.run('clear') has 18, i.e. it's definitely longer. :o/>/>
Except if you take into account that the program 'clear' also executes term.setCursorPos(1, 1), but you didn't explicitly say that. :o/>/>
Dirkus7 #5
Posted 26 March 2012 - 03:49 PM
Haha yeah you're right :o/>/> i mean the whole thing with term.setCursorPos :o/>/>
schrolock #6
Posted 29 March 2012 - 07:09 PM
You can write

shell.run("clear")

too
MrPiggles #7
Posted 29 March 2012 - 07:34 PM
Dirkus7 said:
Term.clear() is a function, not a variable so there must be brackets () after term.clear(). I prefer using shell.run('clear') because it's shorter and it does the same.


Haha yeah you're right i mean the whole thing with term.setCursorPos

Using this makes your program much less efficient, and opens your computer up for a "virus". It's a much better idea to use term.clear()

If you want it to act like the clear program but don't want to type that much, it would be a perfect time to use a function.


local function clear()
   term.setCursorPos(1,1)
   term.clear()
end

Using `clear()` is definitely less typing than `shell.run("clear")`
Dirkus7 #8
Posted 30 March 2012 - 03:18 PM
Using this makes your program much less efficient, and opens your computer up for a "virus". It's a much better idea to use term.clear()
You're completely right, the problem is: i play singleplayer only, i do have friends but they are never online on Minecraft. :)/>/> So i don't think i will have viruses on my computers :o/>/>

If you want it to act like the clear program but don't want to type that much, it would be a perfect time to use a function.


local function clear()
   term.setCursorPos(1,1)
   term.clear()
end

Using `clear()` is definitely less typing than `shell.run("clear")`
That's a good idea, but not efficient if you have a short program, but with a program where i have to write a lot of text on the screen, i will use this idea, thanks :o/>/>