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

Door Opening and Secrurity Override Code

Started by Cobalt, 04 March 2012 - 02:59 AM
Cobalt #1
Posted 04 March 2012 - 03:59 AM
I have not been able to download the mod yet, however, I will during April.

I've seen videos of how to make a locked door that requires a password. But, for my server. I want there to be a secrurity overide code that I will be able to use to unlock any door on the server with a password.

I've taken some notes and this is the jist of what I think MIGHT be good for what I'm looking for. I haven't used code before so forgive me if I have this totally wrong.

> edit Startup
[ print ("Enter Password") ]
> edit blah blah blah
[ print ("Correct Password")
redstone.setOutput("left/right", true )
sleep(6)
redstone.setOutput("left", false ) ]
>edit Secrurity Override
[ print ("Enter Security Overide Code") ]
>edit topsecretsecuritycode
[ print ("Door Open")
redstone.setOutput("left/right", true )
sleep(6)
redstone.setOutpit("left", false ) ]

Anything written in "[blah]" is in its respective edit.

Tell me what would be better and if I have anything wrong at all.
Chub1337 #2
Posted 04 March 2012 - 08:22 AM
But keep using edit, you're making multiple programs, while you only need one. And if you want to save something as a file that's auto-loaded on startup, I'd suggest naming it startup, not Startup (no capital s).

Other than that there is a whole load more that probably won't work but so far you seem to get the idea of how stuff works.

For example: redstone.setOutput("left/right",true) would be rs.setOutput("left",true) rs.setOutput("right",true). You can't say both left and right at once, also you can replace redstone with rs.

An little example of a password check would be:

local pass = "DerpyBird"
local override = "MasterCode"
local input = " "
write("Please enter the password: ")
input = io.read("*")
if input == pass then
    rs.setOutput("left",true)
    print("Correct password entered.")
    sleep(6)
    rs.setOutput("left",false)
    os.shutdown()
elseif input == override then
    rs.setOutput("left",true)
    print("Override code entered")
    sleep(6)
    rs.setOutput("left",false)
else
    print("Wrong password!")
    sleep(1)
    os.shutdown()
end

Note, I've written this from memory, I haven't tested it.

-Chub1337
Leo Verto #3
Posted 06 March 2012 - 12:09 PM
I've coded something like this too.
I also tried to have a file for the password but I got a strange error. :unsure:/>/>
At the moment I can't show you the code but next week I'll be able to.