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

Sweetly Simple Door lock to verify there human

Started by Deathknight0897, 04 July 2012 - 07:02 AM
Deathknight0897 #1
Posted 04 July 2012 - 09:02 AM
This is a really simple but un-secure method of locking a Door Enjoy

Code
Those who know what there doing

Put that into your start up

print ("Please Enter The Door Code")
Create Program called IamHuman

print ("Thankyou the door will open in 3 seconds")
sleep(1)
print ("3")
sleep(1)
print ("2")
sleep(1)
print ("1")
sleep(1)
print ("door opening")
sleep(1)
redstone.setOutput("left", true)
sleep(7)
redstone.setOutput("left", false)
sleep(1)
os.shutdown()

Guide
Just in case your a little unsure

This is an incredibly un-secure method however a great starting point for all those new
to computer craft i will at the end suggest a couple of methods in which you can secure the OS a little better.

Step 1

Placing the console is really simple in my example i placed it like so
Key
D - door
C - Computer
A - Irrelevant
[D][C]
[D][A]



Step 2

To begin we need to prompt the user for a action ie to enter the password so type "edit startup"
now enter this section of code make sure to copy it exactly as it can be case sensitive.

print ("Please Enter The Door Code")
now click Ctrl + S then Ctrl + E
awesome now lets quickly test that either type reboot or hold Ctrl + R

Step 3

We know need a Password for the door in this example it is IamHuman however you can change it to what ever you
want.
now lets create a program type "edit Iamhuman" remember what ever you type there will be your password now we
need to put the code in remember to change the IamHuman to what ever your password is.

also please change left to which ever side your door is on ie right,left,back

print ("Thankyou the door will open in 3 seconds")
sleep(1)
print ("3")
sleep(1)
print ("2")
sleep(1)
print ("1")
sleep(1)
print ("door opening")
sleep(1)
redstone.setOutput("left", true)
sleep(7)
redstone.setOutput("left", false)
sleep(1)
os.shutdown()

now click Ctrl + S then Ctrl + E
awesome now lets quickly test that either type reboot or hold Ctrl + R


Well done you just created a door lock with a nice user interface and the system instructs the user the whole time
this may seem simple now and it is but this is the fundamental's


Stage 4

Improvement no matter how simple the code or how complex there is always a way to improve your system
and although i am not saying that everyone has to bring there code to near perfection there is a basic algorithm
you should follow.

1)What is the problem
2)What is the solution
3)what is the solution in its simplest form
4)make solution in its simplest form
5)does solution solve problem

The most important lesson you will take from this guide today is that the most fancy dancy solution isn't always the best
and sometimes the best solution is the simplest.

However there are a few security features that are quite easy to implement to make this console more secure however do not
get under the false imprecision that it will be un-hackable because that is near in impossible to accomplish.

1) Delete all the security risk programs such as edit and programs (remember once u have deleted edit the only way to get it back is
to copy it from a floppy.

2) If you have access to the Rom in the mods files place your program in the secret folder (this will hide it from programs)
or
just delete programs much easier

3) Make a better Lock this one is a mere starting point

Please feel free to ask me any questions in the comment section regarding anything in this guide enjoy :P/>/>
D3matt #2
Posted 04 July 2012 - 05:10 PM
It's not really a good starting point for a lock, because it's been done completely the wrong way, and only gives a rather poor illusion of being a password program. read() is not hard to use, and is useful in a wide variety of programs, and making a door lock tutorial (or any program requiring input) without it is not being a good teacher.

Further, you can't delete edit, or any of the other programs in ROM.

Since it's not really a secure lock at all, and the point seems to be to test if you're human, a simple button would perform the function just as well.
Deathknight0897 #3
Posted 05 July 2012 - 02:46 AM
It's not really a good starting point for a lock, because it's been done completely the wrong way, and only gives a rather poor illusion of being a password program. read() is not hard to use, and is useful in a wide variety of programs, and making a door lock tutorial (or any program requiring input) without it is not being a good teacher.

Further, you can't delete edit, or any of the other programs in ROM.

Since it's not really a secure lock at all, and the point seems to be to test if you're human, a simple button would perform the function just as well.

this is all true and at no point do i specify its a good lock yes a button would do the same function however a button doesn't teach you how how to create a program edit the startup file or to run a a program through code therefore this program does fit its function in teaching a incredibly basic lock as specified throughout it wasn't attempting to be secure as stated "Improvement no matter how simple the code or how complex there is always a way to improve your system and although i am not saying that everyone has to bring there code to near perfection" i stated throughout that its a starting point and not a fully functional pass worded door also ps: you can delete from the rom i double tested on my server it may be a setting
D3matt #4
Posted 07 July 2012 - 12:30 AM
It fulfils its function in teaching people incredibly basic programming, but teaches the bad habit of using seperate programs instead of using read(), which is more complicated than anything you put here while still being a fairly mandatory function to understand for any sort of program.