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

Multi door locking system with multi password & Admin override.

Started by xxangel17xx, 01 November 2012 - 08:55 PM
xxangel17xx #1
Posted 01 November 2012 - 09:55 PM
This is my first program what it dose is allow you to password up to sixteen doors each with a different password

to install you must have Http enabled or it will be a lot of writing

first open your computer and type pastebin get SeuWv1EN startup
now just reboot the computer and your done.

for the people the don't have http access heres the code
to unlock the console use the admin password witch you should set
Spoiler


os.pullEvent = os.pullEventRaw
term.clear()
term.setCursorPos(1,1)

local side = "bottom"--change bottom to the bundeledwire output
local pass1 = "opendoor1"--Change to door 1's password
local pass2 = "opendoor2"--Change to door 2's password
local pass3 = "opendoor3"--Change to door 3's password
local pass4 = "opendoor4"--Change to door 4's password
local pass5 = "opendoor5"--Change to door 5's password
local pass6 = "opendoor6"--Change to door 6's password
local pass7 = "opendoor7"--Change to door 7's password
local pass8 = "opendoor8"--Change to door 8's password
local pass9 = "opendoor9"--Change to door 9's password
local passwordadmin = "passadmin"--change to admins password

print("Welcome to Evolution-Lock v.1.0")
print("Please Enter a Door password")
print("=[roomname]=[roomname]=[roomname]=")--Change [roomname] to the name of your room's
print("=[roomname]=[roomname]=[roomname]=")--Change [roomname] to the name of your room's
print("=[roomname]=[roomname]=[roomname]=")--Change [roomname] to the name of your room's
write("Password: ")

local input = read("*")

if input == pass1 then
rs.setBundledOutput(side, colors.red)--change red to your wire color
sleep(7)
shell.run ("reboot")
end
if input == pass2 then
rs.setBundledOutput(side, colors.green)--change green to your wire color
sleep(7)
shell.run ("reboot")
end
if input == pass3 then
rs.setBundledOutput(side, colors.blue)--change blue to your wire color
sleep(7)
shell.run ("reboot")
end
if input == pass4 then
rs.setBundledOutput(side, colors.yellow)--change yellow to your wire color
sleep(7)
shell.run ("reboot")
end
if input == pass5 then
rs.setBundledOutput(side, colors.lime)--change lime to your wire color
sleep(7)
shell.run ("reboot")
end
if input == pass6 then
rs.setBundledOutput(side, colors.white)--change white to your wire color
sleep(7)
shell.run ("reboot")
end
if input == pass7 then
rs.setBundledOutput(side, colors.pink)--change pink to your wire color
sleep(7)
shell.run ("reboot")
end
if input == pass8 then
rs.setBundledOutput(side, colors.black)--change black to your wire color
sleep(7)
shell.run ("reboot")
end
if input == pass9 then
rs.setBundledOutput(side, colors.brown)--change brown to your wire color
sleep(7)
shell.run ("reboot")
end
if input == passwordadmin then
term.clear()
term.setCursorPos(1,1)
print("Password correct!")
print("Computer unlocking...")
print("Please type 'reboot' or 'shutdown' before leaving")
os.pullEvent(terminate)

else
term.clear()
term.setCursorPos(1,1)
print("Goodbye!")
sleep(2)
os.reboot()
end
you may use and edit this in any way
BUT DONOT repost this code without my permission
I would like to thank
luanub
for helping me fix a bug in the code.
jag #2
Posted 01 November 2012 - 11:36 PM
Could've been done smaller, but otherwise; Nice program!
jag #3
Posted 01 November 2012 - 11:38 PM
And you got there on a line
os.pullEvent(terminate)
Where does the variable terminate come from?

Another thing: How do you turn it off?
xxangel17xx #4
Posted 02 November 2012 - 12:44 AM
to turn it off you enter the admin password witch is defined along with the other passwords
os.pullEvent(terminate) is something i seen a friend do and when i asked it function he just said it will allow you to stop the program
so my best bet is to say thats what allows the admin pass to return you to the console main page
jag #5
Posted 02 November 2012 - 01:04 AM
I tried to remake it:
Spoiler

oldPull = os.pullEvent
os.pullEvent = os.pullEventRaw

local input = ""
local side = "bottom"
local pass = {
  pass1 = "opendoor1", pass1color = colors.red,
  pass2 = "opendoor2", pass2color = colors.green,
  pass3 = "opendoor3", pass3color = colors.blue,
  pass4 = "opendoor4", pass4color = colors.yellow,
  pass5 = "opendoor5", pass5color = colors.lime,
  pass6 = "opendoor6", pass6color = colors.white,
  pass7 = "opendoor7", pass7color = colors.pink,
  pass8 = "opendoor8", pass8color = colors.black,
  pass9 = "opendoor9", pass9color = colors.brown,
  admin = "passadmin"
}

function checkPass(password)
  for id,value in pairs(pass) do
	if password == value then
	  if id ~= "admin" then
		return true, id
	  else
		return "admin"
	  end
	end
  end
  return false
end

while true do
  term.clear()
  term.setCursorPos(1,1)

  print("Welcome to Evolution-Lock v.1.0")
  print("Please Enter a Door password")
  print("=[roomname]=[roomname]=[roomname]=")
  print("=[roomname]=[roomname]=[roomname]=")
  print("=[roomname]=[roomname]=[roomname]=")
  write("Password: ")

  input, passID = checkPass(read("*"))

  if input == true then
	rs.setBundledOutput(side, pass[passID.."color"])
	print()
	local x,y = term.getCursorPos()
	for time = 7, 1, -1 do
	  term.setCursorPos(x,y)
	  term.clearLine()
	  write("Closing door in "..time.." seconds!")
	  sleep(1)
	end
	rs.setBundledOutput(side, 0)
  elseif input == "admin" then
	term.clear()
	term.setCursorPos(1,1)
	print("Password correct!")
	print("Computer unlocking...")
	print("Please type 'reboot' or 'shutdown' before leaving")
	break
  else
	term.clear()
	term.setCursorPos(1,1)
	print("Incorrect password!")
	sleep(2)
  end
end

os.pullEvent = oldPull
xxangel17xx #6
Posted 02 November 2012 - 01:44 AM
nice i'm not that experienced in Lua this was just me learning small things