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

Clear the screen on program ?

Started by A2Creativity, 16 June 2012 - 03:12 PM
A2Creativity #1
Posted 16 June 2012 - 05:12 PM
hi, i want to ask about my startup program… it just a regular door locking and the problem is after i enter the password it's open the door but it doesn't clear the screen

ex:
Please enter the password:

(after i enter the correct password)

Please enter the password:
****
Please enter the password:
_

any idea to clear previous text ? and where i should put them ?

here's my script
Spoilerfunction pass()
textutils.slowPrint("Welcome… please enter the password:")
x = io.read()
if x == "the password" then
redstone.setOutput("back",true)
sleep(2)
redstone.setOutput("back",false)
pass()
else
pass()
end
end
pass()
Pinkishu #2
Posted 16 June 2012 - 05:15 PM
term.clear()

will clear the terminal screen so put it before slowprint
you might also want to put a term.setCursorPos(1,1)
behind or before term.clear() as it sets the cursor back to the top left position
A2Creativity #3
Posted 16 June 2012 - 05:23 PM
term.clear()

will clear the terminal screen so put it before slowprint
you might also want to put a term.setCursorPos(1,1)
behind or before term.clear() as it sets the cursor back to the top left position
oh thanks…

but it makes the else text gone
ex.
Pass:

(i typed the wrong pass)

You entered the wrong password.

but with term.clear it will be restarted to 'pass:' not to 'You entered the blablabla'
any idea to fix it ?
cant_delete_account #4
Posted 16 June 2012 - 05:45 PM
Do this:

while true do
term.clear()
term.setCursorPos(1,1)
term.setCursorBlink(true)
textutils.slowWrite("Welcome... nPassword: ")
local ePass = read("*")
term.clear()
term.setCursorPos(1,1)
if ePass == "the password" then
redstone.setOutput("back",true)
sleep(2)
redstone.setOutput("back",false)
end
end
P.S: 'n' is a new line, it won't show.
A2Creativity #5
Posted 17 June 2012 - 03:28 AM
Do this:

while true do
term.clear()
term.setCursorPos(1,1)
term.setCursorBlink(true)
textutils.slowWrite("Welcome... nPassword: ")
local ePass = read("*")
term.clear()
term.setCursorPos(1,1)
if ePass == "the password" then
redstone.setOutput("back",true)
sleep(2)
redstone.setOutput("back",false)
end
end
P.S: 'n' is a new line, it won't show.

awesome ! it's fix my problem… anyway do you know guide of command that only on computercraft ? like redstone.setOutput (that probably only on computercraft)
and the last question..
what command on program to make the computer shutdown ?
MysticT #6
Posted 17 June 2012 - 03:39 AM
awesome ! it's fix my problem… anyway do you know guide of command that only on computercraft ? like redstone.setOutput (that probably only on computercraft)
and the last question..
what command on program to make the computer shutdown ?
That's what the wiki is for :(/>/>
A2Creativity #7
Posted 17 June 2012 - 03:43 AM
awesome ! it's fix my problem… anyway do you know guide of command that only on computercraft ? like redstone.setOutput (that probably only on computercraft)
and the last question..
what command on program to make the computer shutdown ?
That's what the wiki is for :(/>/>

Which one ? i only see the turtle not for the computer
deity12 #8
Posted 17 June 2012 - 08:20 AM

os.shutdown()
That will shut down the computer.
MysticT #9
Posted 17 June 2012 - 05:31 PM
awesome ! it's fix my problem… anyway do you know guide of command that only on computercraft ? like redstone.setOutput (that probably only on computercraft)
and the last question..
what command on program to make the computer shutdown ?
That's what the wiki is for :(/>/>

Which one ? i only see the turtle not for the computer
There's an APIs section where you can see all the commands. Most of them are for computers and turtles, only the turtle api is for turtles only.