Fandom

Minecraft ComputerCraft Wiki

Locks

47pages on
this wiki
Add New Page
Comments89 Share
2011-12-27 20.26.49

Example of a Classic Lock with Tries function.

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. edit lock
  9. password

= "hello" --this is your password to "unlock" the door

  1. print "TangentLockLite Ver. 1" --tells you what version it is
  2. write "Password: " --puts a pretty "Password: " on the screen, so you know what you're doing
  3. 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.

  1. if input

== password then --if what you type in is equal to your password, it does the following

  1. redstone.setOutput ("back", true) --makes the back of the computer turn on a redstone pulse
  2. sleep (5) --pause for 5 seconds
  3. os.shutdown() --makes the computer turn off
  4. else --but if the password isn't correct
  5. print "Incorrect Password" --let's you know that the password is wrong
  6. sleep (2) --pause for 2 seconds
  7. os.shutdown() --makes the computer turn off
  8. end --the end of the program

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki