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

Advanced password door with multi user's and passwords

Started by sicet7, 10 June 2012 - 12:06 AM
sicet7 #1
Posted 10 June 2012 - 02:06 AM
hey
I've seen tutorial after tutorial on youtube and now has finally learned how to make a good password door. so I've made it here from what I know.


username1 = "user"
password1 = "pass"
function clear()
term.clear()
term.setCursorPos(1,1)
write("sicet7's Lock System v2.2")
term.setCursorPos(1,2)
end
repeat
clear()
write("Username: ")
user = read()
until user == username1
repeat
clear()
write("Password: ")
pass = read("X")
until pass == password1
sleep(1)
write("Welcome User")
rs.setOutput("left",true")
sleep(3)
rs.setOutput("left",false)
os.shutdown()

but i would like to know how to lock out the command Ctrl+T

and it would also be nice if it was possible to have unlimited user with specefic passwords for each user
so if
user1 + pass1 = access

user2 + pass2 = access

user3 + pass3 = access

user4 + pass4 = access

user5 + pass5 = access

user1 + pass2 = denied

user2 + pass1 =denied

and so on to infinity

P.S and 2.2 means 22 trys to make a lock system xD

Edited 10-06-2012

in dont know how to input the table for users i don't mean to make you make my program but if you would mind to just put in so it would be possible to make 5 diffrend user and password.
MysticT #2
Posted 10 June 2012 - 02:47 AM
To prevent termination (Ctrl-T) you can use this:

local oldPullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
-- Your program code here
os.pullEvent = oldPullEvent
And for the users, you can use a table:

local tUsers = {
"user1" = "password1"
"John" = "Apples"
"MysticT" = "MyPassword"
}
-- To verify if the user-pass:
if tUsers[usr] == pass then
  -- correct password
end
And you could save them to a file if you want to be able to change, add and remove users and passwords. But that requires a little more work, so start with the tables first.
cant_delete_account #3
Posted 10 June 2012 - 03:17 AM
To prevent termination (Ctrl-T) you can use this:

local oldPullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
-- Your program code here
os.pullEvent = oldPullEvent
Instead of overriding os.pullEvent (as sometimes that can mess up) I would use this instead:

while true do
if os.pullEvent() == "terminate" then
  term.clear()
  term.setCursorPos(1,1)
  print("Nope.")
  sleep(1)
  term.clear()
  term.setCursorPos(1,1)
end
--CODE
end
sicet7 #4
Posted 10 June 2012 - 10:26 AM
thx man i got my question answerd
MysticT #5
Posted 10 June 2012 - 03:12 PM
To prevent termination (Ctrl-T) you can use this:

local oldPullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
-- Your program code here
os.pullEvent = oldPullEvent
Instead of overriding os.pullEvent (as sometimes that can mess up) I would use this instead:

while true do
if os.pullEvent() == "terminate" then
  term.clear()
  term.setCursorPos(1,1)
  print("Nope.")
  sleep(1)
  term.clear()
  term.setCursorPos(1,1)
end
--CODE
end
That wouldn't work, you would need to use pullEventRaw, since pullEvent throws an error and ends the program when it receives the "terminate" event.
It's better to do what I said, since it also prevents termination when calling sleep, read, etc.
SupersonicXX9 #6
Posted 22 June 2012 - 10:00 PM
To prevent termination (Ctrl-T) you can use this:

local oldPullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
-- Your program code here
os.pullEvent = oldPullEvent
Instead of overriding os.pullEvent (as sometimes that can mess up) I would use this instead:

while true do
if os.pullEvent() == "terminate" then
  term.clear()
  term.setCursorPos(1,1)
  print("Nope.")
  sleep(1)
  term.clear()
  term.setCursorPos(1,1)
end
--CODE
end
That wouldn't work, you would need to use pullEventRaw, since pullEvent throws an error and ends the program when it receives the "terminate" event.
It's better to do what I said, since it also prevents termination when calling sleep, read, etc.
BUT, you could have the CTRL keys restart the computer, to prevent exiting.
MysticT #7
Posted 22 June 2012 - 10:16 PM
BUT, you could have the CTRL keys restart the computer, to prevent exiting.
???
Sorry, but I don't understand what you mean.
Ctrl-T can be prevented, Ctrl-R and Ctrl-S can't.