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

How do I stop this from being hardwired?

Started by bloodless2010, 15 July 2012 - 11:34 AM
bloodless2010 #1
Posted 15 July 2012 - 01:34 PM
OK, So this is my door lock setup:


And here's the program code;
os.pullEvent = os.PullEventRaw – Stops CTRL + T termination
local side = "right" – Change left to whatever side your door / redstone is on, E.G: left, right, front, back, bottom, top. Be sure to leave the "s around it, though
local password = "bacon" – Change bacon to what you want your password to be. Be sure to leave the "s around it, though
local opentime = 5 – Change 5 to how long (in seconds) you want the redstone current to be on. Don't put "s around it, though
term.clear() – Clears the screen
term.setCursorPos(1,1) – Fixes the cursor position
write("Password: ") – Prints 'Password: ' to the screen
local input = read("*") – Makes the variable 'input' have the contents of what the user types in, the "*" part sensors out the password
if input == password then – Checks if the user inputted the correct password
term.clear() – Already explained up top
term.setCursorPos(1,1)
print("Password correct!") – Prints 'Password correct!' to the screen
rs.setOutput(side,true) – Output a redstone current to the side you specified
sleep(opentime) – Wait the amount of seconds you specifed, then..
rs.setOutput(side,false) – Stop outputting a redstone current
os.reboot() – Reboot the computer, reopening the lock
else – Checks if the user didn't input the correct password
term.clear()
term.setCursorPos(1,1)
print("Password incorrect!") – Prints 'Password incorrect!' to the screen
sleep(2) – Waits 2 seconds
os.reboot() – Reboot the computer, reopening the lock
end
(Code found here: http://computercraft..._Protected_Door)
How do I stop people from just putting a redstone torch in front of the door to open it?
Thanks!
inventor2514 #2
Posted 15 July 2012 - 01:55 PM
Place the door so that it closes when it receives a redstone signal and modify your program accordingly.
bloodless2010 #3
Posted 15 July 2012 - 02:30 PM
Place the door so that it closes when it receives a redstone signal and modify your program accordingly.

Could you explain further please?
I want the door closed in the first place so nobody can just walk in, then when the password is entered it opens for 5 seconds,
would it be possible to check in the background if when the password isn't entered and when it's incorrect, that if there's a redstone signal, it will close the door?
Ponder #4
Posted 15 July 2012 - 03:51 PM
His point is, place the door in a way that it is open when unpowered and closed when powered. I'm not sure whether this works with Iron Doors, though.
Tiin57 #5
Posted 15 July 2012 - 05:52 PM
What you need to do is place the door so that when in its default, unpowered state, it will be open. You can accomplish this by standing to the left or right of the block the door will be on top of, place the door, and modify the code to output current accordingly. And Ponder, it works with any kind of door. Not trapdoors, etc.
MysticT #6
Posted 15 July 2012 - 08:36 PM
The only problem is that people could just turn the computer off (holding Ctrl+S) and the redstone will turn off, leaving the door open.
bloodless2010 #7
Posted 15 July 2012 - 08:52 PM
The only problem is that people could just turn the computer off (holding Ctrl+S) and the redstone will turn off, leaving the door open.
Exactly, I managed to get it all sorted out without changing anything, My friend WorldGuarded it for me so nobody could place a RS torch infront to open it, it works like a charm now! My Dark matter and red matter are safe! :P/>/>