19 posts
Posted 14 May 2012 - 05:16 AM
Right, so I've made a password door(how creative of me) from a tutorial and im looking to customise it a bit, to make it more suited to what I want. I've made a few neat changes but I'm looking for a way to clear the screen of all text. Because every time someone uses it there's another few lines of text i.e.:
Please enter password:
********
Password Accepted!
After that's used it just stays there and it doesn't take long for the screen to fill up with all kinds of crap.
I am basically looking for the name of the function(or a line of code) that just clears the screen of all text, but does nothing else, just leaves the program as it is.
Thanks in advance!
Please check down for a further question which still needs answering!
718 posts
Location
Hawaii
Posted 14 May 2012 - 06:36 AM
do:
shell.run("clear")
or
term.clear()
term.setCursorPos(1,1)
19 posts
Posted 15 May 2012 - 04:17 AM
Thanks very much! I'm working on a computer-controlled/automated house and this is the first step towards the coding knowledge I need. Thank you. I have another question.
I atempted to make a passcode whereby the user has 3 attempts after that the program sleeps for 30 secs. However i keep getting multiple errors whatever i do. Here is my code:
function pass()
shell.run("clear")
print ("Please enter password here:")
t = read("*")
if t == "password" then
print ("Password Correct!")
redstone.setOutput("left", true)
sleep(3)
redstone.setOutput("left", false)
shell.run("clear")
pass()
end
end
pass()
else
print ("Password Incorrect. Two attempts reamaining.")
sleep(2)
t = read("*")
if t == "password" then
print ("Password Correct!")
redstone.setOutput("left", true)
sleep(3)
redstone.setOutput("left", false)
shell.run("clear")
pass()
end
end
pass()
else
print ("Password Incorrect. One attempt remaining.")
sleep(2)
t = read("*")
if t == "password" then
print ("Password Correct!")
redstone.setOutput("left", true)
sleep(3)
redstone.setOutput("left", false)
shell.run("clear")
pass()
end
end
pass()
else
print ("Password Incorrect. Locking for 30 seconds.")
sleep(10)
print ("Unlocking in 20 seconds.")
sleep(10)
print ("Unlocking in 10 seconds.")
sleep(10)
print ("Console unlocked.")
sleep(2)
shell.run("clear")
pass()
end
end
pass()
It keeps telling me <eof> is expected? What is eof?
I hope someone can help!
5 posts
Location
Tricity, Pomerania
Posted 15 May 2012 - 05:29 PM
Check out casper7562 interactive tutorial (it's on forum) it'll help you a lot.
Now about your program:
I dont' have right now a lot of time so I'll just write code for you.
side='left'
x=3
password="your password"
function pass()
term.clear() term.setCursorPos(1,1)
if x~=0 then
print('You have '..x..' attemps left')
write('Enter password: ')
pass=io.read()
if pass==password then
rs.setOutput(side, true)
sleep(3)
rs.setOutput(side, false)
else
x=x-1
end
else
print('You have 0 attemps left.\n Locking terminal for 920 seconds.')
sleep(920)
end
end
while true do
pass()
end
I hope someone will explain it to you.
351 posts
Posted 11 June 2012 - 04:24 PM
Check out casper7562 interactive tutorial (it's on forum) it'll help you a lot.
Now about your program:
I dont' have right now a lot of time so I'll just write code for you.
side='left'
x=3
password="your password"
function pass()
term.clear() term.setCursorPos(1,1)
if x~=0 then
print('You have '..x..' attemps left')
write('Enter password: ')
pass=io.read()
if pass==password then
rs.setOutput(side, true)
sleep(3)
rs.setOutput(side, false)
else
x=x-1
end
else
print('You have 0 attemps left.n Locking terminal for 920 seconds.')
sleep(920)
end
end
while true do
pass()
end
I hope someone will explain it to you.
That lockdown code is basically useless. Unless you have persistence, you can just restart it and bypass the lockdown.
686 posts
Posted 11 June 2012 - 05:36 PM
Don't use shell.run("clear"), use term.clear() instead. I'm not sure why somebody with somebody with 500 posts would suggest that, but it's a really terrible idea and the wrong way to do it.
474 posts
Posted 12 June 2012 - 03:30 AM
Don't use shell.run("clear"), use term.clear() instead. I'm not sure why somebody with somebody with 500 posts would suggest that, but it's a really terrible idea and the wrong way to do it.
somebody with somebody with 500 posts?
Incorrect grammar?
686 posts
Posted 12 June 2012 - 06:23 AM
Don't use shell.run("clear"), use term.clear() instead. I'm not sure why somebody with somebody with 500 posts would suggest that, but it's a really terrible idea and the wrong way to do it.
somebody with somebody with 500 posts?
Incorrect grammar?
Oh god, somebody made a typo on the internet! Save us!
2217 posts
Location
3232235883
Posted 12 June 2012 - 07:48 AM
Don't use shell.run("clear"), use term.clear() instead. I'm not sure why somebody with somebody with 500 posts would suggest that, but it's a really terrible idea and the wrong way to do it.
somebody with somebody with 500 posts?
Incorrect grammar?
Oh god, somebody made a typo on the internet! Save us!
classic D3matt not actually posting any evidence on why something is wrong.
shell.run(s) will run the file in the string,
and here is the clear program:
term.clear()
term.setCursorPos(1,1)
using it just saves space, thats all.
it was a grammatical error not a typo, a typo is a misspelled word due to keys being confused, your sentence was just a brain fart.
and i admire how you use capital letters to try to convince people that you can [acronym='purposely removed part of it so it becomes le troll/grammar nazi bait']grammar[/acronym].
1111 posts
Location
Portland OR
Posted 12 June 2012 - 08:19 AM
shell.run() will cause you problems is you start nesting the same program within itself.
There's a reason why it was put into CC. For example you can not create a program launcher without using it, and you can not launch any programs from your startup files without it either…
Just be smart on how you use it.
shell.run("clear") will obviously not cause any issues…. However if your trying to save space creating your own clear function would be more efficient if you are going to use it allot in your program.
718 posts
Location
Hawaii
Posted 12 June 2012 - 08:25 AM
Don't use shell.run("clear"), use term.clear() instead. I'm not sure why somebody with somebody with 500 posts would suggest that, but it's a really terrible idea and the wrong way to do it.
I posted that before I had 500 posts.
shell.run("clear") is more compact but also causes some security issues.
For example, if someone made a virus named "clear", it would run that virus when you do that.
But if you still wanna use shell.run("clear"), another way is:
shell.run("rom/programs/clear")
Because that will use a non-editable clear program and it will always be the same one every time.
2217 posts
Location
3232235883
Posted 12 June 2012 - 09:13 AM
Don't use shell.run("clear"), use term.clear() instead. I'm not sure why somebody with somebody with 500 posts would suggest that, but it's a really terrible idea and the wrong way to do it.
I posted that before I had 500 posts.
shell.run("clear") is more compact but also causes some security issues.
For example, if someone made a virus named "clear", it would run that virus when you do that.
But if you still wanna use shell.run("clear"), another way is:
shell.run("rom/programs/clear")
Because that will use a non-editable clear program and it will always be the same one every time.
if the virus was able to copy itself to the hd as clear then i think it has already done the damage
686 posts
Posted 12 June 2012 - 04:10 PM
clear already exists in the rom folder, putting another copy in the rom folder wouldn't help anything, because the computer's local HDD overrides the rom folder.
Don't use shell.run("clear"), use term.clear() instead. I'm not sure why somebody with somebody with 500 posts would suggest that, but it's a really terrible idea and the wrong way to do it.
somebody with somebody with 500 posts?
Incorrect grammar?
Oh god, somebody made a typo on the internet! Save us!
classic D3matt not actually posting any evidence on why something is wrong.
shell.run(s) will run the file in the string,
and here is the clear program:
term.clear()
term.setCursorPos(1,1)
using it just saves space, thats all.
it was a grammatical error not a typo, a typo is a misspelled word due to keys being confused, your sentence was just a brain fart.
and i admire how you use capital letters to try to convince people that you can [acronym='purposely removed part of it so it becomes le troll/grammar nazi bait']grammar[/acronym].
It was a typo. Obviously I know how grammar works, I just accidentally typed to same thing twice. But if it makes you feel better about yourself, think whatever you want.
2217 posts
Location
3232235883
Posted 12 June 2012 - 05:57 PM
clear already exists in the rom folder, putting another copy in the rom folder wouldn't help anything, because the computer's local HDD overrides the rom folder.
and who was going to put it in the rom folder?im still using shell.run("clear") because it dosent change how a computer gets infected ALTHOUGH…if your using a startup program on a floppy to remove a virus the virus could be in the clear so i would suggest you use shell.run("rom/programs/clear").lul thats a good idea for my virus, although i was going to copy every rom program to root and infect them anywayanother idea, if the startup part of the virus dosent load (it was bypassed by a floppy) it will fake the deletion of the virus
797 posts
Posted 25 June 2012 - 02:24 PM
use this code…it gives you 3 tries and when you have used them up it sleeps for 30 secs but if you get it right it opens a door for 5 secs
x = 3
while true do
term.clear()
term.setCursorPos(1,1)
print("you have ", x, " tries left")
if x >= 1 then
write("please put in your password: ")
password = read()
if password == "your password" then
print("password accepted")
rs.setOutput("-side-", true )
sleep(5)
rs.setOutput("-side-", false )
else
x = x-1
end
else
print("you have run out of attempts, sleeping for 30 secs...")
sleep(30)
end
end