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

Simple Door Lock with Monitor

Started by RustikGaming, 22 January 2013 - 06:24 AM
RustikGaming #1
Posted 22 January 2013 - 07:24 AM
This is a simple door lock program that I wrote that displays "Password Correct/Incorrect" on the monitor after typing the password and then opens the door. All feedback and comments are welcome.

Also you may insert this at the top of the code to disable the ability for the program to be terminated with CTRL - T. This is most useful in SMP.

local.pullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
then you can run
 os. pullEvent = pullEvent 
to re-enable terminating of the program

and finally here is the program
http://pastebin.com/57Qqy1K0

RUN THE COMMAND:

pastebin get 57Qqy1K0 (chosen filename)

TO INSTALL THE PROGRAM TO A COMPUTER IN MINECRAFT WHILE PLAYING MINECRAFT!!!


local side = "left"
local password = "password"
local opentime = 3
while true do
  term.clear()
  term.setCursorPos(1,1)
  write("Password: ")
  local input = read("*")
  if input == password then
	term.clear()
	term.setCursorPos(1,1)
	local monitor = peripheral.wrap("right")
	term.redirect( monitor)
	print("Password Correct!")
	sleep(2)
	term.clear()
	term.setCursorPos(1,1)
	term.restore()
	rs.setOutput(side,true)
	sleep(opentime)
	rs.setOutput(side,false)
	term.clear()
	term.setCursorPos(1,1)
  else
	local monitor = peripheral.wrap("right")
	term.redirect( monitor)
	print("Password Incorrect!")
	sleep(2)
	term.clear()
	term.setCursorPos(1,1)
	term.restore()
	sleep(2)
	term.clear()
	term.setCursorPos(1,1)
  end
end
SuicidalSTDz #2
Posted 22 January 2013 - 07:41 AM
Looks good but a pastebin link would be nice ;-)
RustikGaming #3
Posted 22 January 2013 - 08:17 AM
Looks good but a pastebin link would be nice ;-)
sure here you go
http://pastebin.com/57Qqy1K0
CorvixCrows #4
Posted 01 March 2013 - 02:12 AM
i have a problem:

Bios:338: [string "startup"] :32: '=' expected
How I resolve this problem?