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

simple password lock

Started by gimp21, 12 December 2012 - 09:46 PM
gimp21 #1
Posted 12 December 2012 - 10:46 PM
hi this is my first post and my first program so go easy on me.

computercraft is a little difficult for me as i don't really know lua.
but this is a simple computer password lock that asks your to input your password before you can access your computer and if you input the wrong one it will shutdown until you enter the correct password.

ps. sorry for the sloppy writing, i don't usually post or write much.

anyway here is the program/code.[attachment=772:password_lock.txt]


1.shell.run("startup")
2. term.clear()
3. term.setCursorPos(1,1)
4. print("please enter your password: ")
5.   a = read("*")
6.		if a == "" then  --insert the password you want here
7.		print("Access Granted")
8.   else
9.		print("Access Denied")
10.	sleep(2)
11.		print("shutting down until you can remember your password")
12.	sleep(2)
13.  os.shutdown()
14.end
Goof #2
Posted 13 December 2012 - 12:13 AM
Try adding this on top of your code:

os.pullEvent = os.pullEventRaw

then you prevent ctrl-t termination
And, if you just name your program "startup" then you dont need

shell.run("startup")

_
a good code for a beginner:D


Im typin on my phone, so dont blame me xD
_____________________
-mikk809h

AdvLock - lock your computer with advanced technology :D/>/>/>/>
Tiin57 #3
Posted 13 December 2012 - 01:02 AM
Indentation is weird. Also, this code won't work. Remove the line numbers and it will.
Dlcruz129 #4
Posted 13 December 2012 - 04:15 AM
No ones ever gonna download a simple program. Use pastebin.com to post your code, and remove the line numbers.
gimp21 #5
Posted 13 December 2012 - 09:42 AM
No ones ever gonna download a simple program. Use pastebin.com to post your code, and remove the line numbers.
i do have this also on pastebin and the line numbers are just from copy and paste and as i said before i'm not really used to lua yet.
so it might be a simple program to you but to me its an acomplishment. so :P/> :lol:/>
rhyleymaster #6
Posted 13 December 2012 - 12:11 PM
Its okay. Try something like this.

pass = () --Password
while true do -- Makes a loop so you don't have to do Os.reboot()
term.clear()
term.setCursorPos(1,1)
	 while true do
	 write("Password:")]
	  local p = read("*")
	  if p == pass
	  then
	  term.clear()
	  term.setCursorPos(1,1)
	  sleep(1)
	  print("Logged in.")
	  shell.run("shell")
	  else
	  print("Wrong Password.")
	  sleep(3)
	  end.
end -- CLOSE TEH LOOP
Dlcruz129 #7
Posted 13 December 2012 - 01:53 PM
No ones ever gonna download a simple program. Use pastebin.com to post your code, and remove the line numbers.
i do have this also on pastebin and the line numbers are just from copy and paste and as i said before i'm not really used to lua yet.
so it might be a simple program to you but to me its an acomplishment. so :P/> :lol:/>

Then post the link to the Pastebin in your main post.