107 posts
Posted 24 June 2012 - 09:42 AM
Hello, first I want to say that I am no coder, I only know a few lines of code, please respect it.
I play on my server with friends and I wanted to password protect my computer. I did it very simple:
print("Password:")
input = io.read()
if input == "password" then
print("Password accepted")
else
os.shutdown()
end
The problem is that other people see my password after I typed it. I want to have a clean page without my password showing. Is it possible? If yes, how does the code have to look like?
1111 posts
Location
Portland OR
Posted 24 June 2012 - 10:17 AM
Try changing input = io.read() to:
local input = read("*")
and see if that helps.
107 posts
Posted 24 June 2012 - 10:23 AM
When I changed it to
local input = read("*")
It didn't work anymore
Edit:
Oh it worked! Thanks so much. I forgot to remove io.
9 posts
Posted 24 June 2012 - 03:10 PM
from what I can see from this, your password is "password"
Try the following code:
term.clear() -- this clears the screen, so no text is on screen
term.setCursorPos(1,1) -- this sets the cursor to line 1, char 1. aka top right
write("Password: ") -- this will type "Password: " on the screen, and set the cursor to the end of the line.
password = yourpasswordhere -- this sets the variable "password" to "yourpasswordhere" You can change it to what you like.
input = read("*") -- this sets the variable "input" to whatever you type, but exchanged for the * symbol. Stops others viewing what you type.
if input = password then -- this means if the variable "input" matches the variable "password" it will do the following lines of code
term.clear() -- cleans the screen. not needed just makes it tidier.
term.setCursorPos(1,1) -- again not needed but neatens things.
print "Welcome" -- this types "welcome" to your screen and starts a new line ready for input. you can change "welcome" to whatever you like.
else -- this is saying " if none of the previous requirments have been fulfilled, then do the next line(s) of code.
os.reboot() -- This restarts your pc.
end -- this tells the program that your last argument is closed.
After you get this to work, take a loot at removing ctrl + T functions, and you can have a pretty secure password system!