Minecraft ComputerCraft Wiki


46pages on
this wiki
2011-12-27 20.26.49
Example of a Classic Lock with Tries function.
Block46Added by Block46

Locks are computer programs used to lock doors (usually iron doors to prevent forced entry). The most common lock programs require a password in order to gain entry.

The most common lock code is this (Thanks to Hydrogen on Minecraft Forums) :

  1. --Title: TangentLockLite
  2. --Version: 1
  3. --Last Revised: N/A
  4. --Last Revised By: N/A
  5. --Author: TangentDelta (alias Hydrogen)
  6. --Platform: ComputerCraft LUA Virtual Machine
  7. --Notes: Please don't claim this as yours, give me credit!
  8. password = "hello" --this is your password to "unlock" the door
  9. print "TangentLockLite Ver. 1" --tells you what version it is
  10. write "Password: " --puts a pretty "Password: " on the screen, so you know what you're doing
  11. input = read("*") --make a prompt where you can type stuff in, and stores it to the "input" variable EDIT: By DJZ07728. I made it so text you type is hidden.
  12. if input == password then --if what you type in is equal to your password, it does the following
  13. redstone.setOutput ("back", true) --makes the back of the computer turn on a redstone pulse
  14. sleep (5) --pause for 5 seconds
  15. os.shutdown() --makes the computer turn off
  16. else --but if the password isn't correct
  17. print "Incorrect Password" --let's you know that the password is wrong
  18. sleep (2) --pause for 2 seconds
  19. os.shutdown() --makes the computer turn off
  20. end --the end of the program

Advertisement | Your ad here

Around Wikia's network

Random Wiki