How do i make passwords look like this (****) when i enter it for my password door lock?
And how can i make it so you can't terminate it unless you enter the correct password?
Thanks
local oldPullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
-- Insert your code here
os.pullEvent = oldPullEvent
This way you prevent termination even using functions like sleep or read.Perfect got them two things to work.
If I enter my password wrong it goes to a blank screen, can i get it to automatically reset to startup if the password is wrong?
term.clear()
term.setCursorPos(1,1)--clear the screen
if read("*") == "your password" then
--whatever u want
else
print("Wrong!")
sleep(1)
shell.run("startup")
end
Only if you want to crash the computer. That's not the way to do it.Perfect got them two things to work.
If I enter my password wrong it goes to a blank screen, can i get it to automatically reset to startup if the password is wrong?
You can try this:term.clear() term.setCursorPos(1,1)--clear the screen if read("*") == "your password" then --whatever u want else print("Wrong!") sleep(1) shell.run("startup") end
while true do
term.clear()
term.setCursorPos(1, 1)
write("Enter password: ")
if read("*") == "YourPassword" then
print("Correct password")
else
print("Incorrect password")
end
end
Gotcha, one last thing, How do i copy my startup with my door lock onto a floppy?
copy *name of door lock* disk/
(Type that into the shell)
fs.copy("<PrograName>", "/disk/<ProgramName>")
while true do
term.clear()
term.setCursorPos(1, 1)
write("Enter password: ")
if read("*") == "YourPassword" then
print("Correct password")
break
else
print("Incorrect password")
end
end
That was just an example, and it can be terminated, so that's not the code he's using (or he shouldn't be using it). And I'm not Wolvan :(/>/>If you used Wolvan's code, he forgot a "break" so the loop will go forever. Try this:while true do term.clear() term.setCursorPos(1, 1) write("Enter password: ") if read("*") == "YourPassword" then print("Correct password") break else print("Incorrect password") end end
local oldPullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
local sUser = "YourUsername"
local sPass = "YourPassword"
local function clear()
term.clear()
term.setCursorPos(1, 1)
end
while true do
clear()
write("User: ")
local usr = read()
write("Password: ")
local pass = read("*")
if usr == sUser and pass == sPass then
print("Access granted")
break
else
print("Invalid username/password")
sleep(1)
end
end
os.pullEvent = oldPullEvent
It asks for the username and the password, and if they are correct you can use the computer.Where would this go inside my code?
edit, do you have a simple door lock i could have with that intergrated into it?
os.pullEvent = os.pullEventRaw
function pass()
print("Please Enter Password:")
t = read("*")
if t == "password" then --change password to whatever you want your password to be
print("Correct!") --a simple message telling the user they got the password right
redstone.setOutput("side", true) --change side to the side that your door is on relative to the console
sleep(#) --change # to however long you want the door to be open
redstone.setOutput("side", false) --side is the same as before
--you can add anything else you want the program to do if the password is correct here
else
print("Incorrect Password")
os.reboot() --this will reboot the console if the password was wrong.
end
end
pass()