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

Use computer as securer door system with alarm.

Started by Jackster, 06 July 2012 - 11:54 PM
Jackster #1
Posted 07 July 2012 - 01:54 AM
Hi all!

I love the mod but as of many people don't code.

So I hope someone here would be able to help a bit.

I will return the favour as a MineCraft server for a month or link to your YouTube on mine.


What I want to do is use a terminal as a security system for a door into a secured location.

The user will click the computer and enter password that will open the doors for 5 seconds.

Doors will the close. To open from other side there is a button.

If a password is not entered correctly there needs to be a second output to a redstone alarm until the correct password is entered.

What I marked in green is extra and only needed if easy to code.

So if someone could do it for me I am happy to give them a MineCraft server for a month or a link to their YouTube from my YouTube channel.

Thanks and I hope I posted in the right place :P/>/>

Jack,
Pinkishu #2
Posted 07 July 2012 - 02:05 AM
Isn't that just something like


os.pullEvent = os.pullEventRaw

local doorSide = "left"
local alarmSide = "back"
local pw = "passw"

while true do
  term.clear() term.setCursorPos(1,1)
  print("Enter password:")
  local input = read("'")
  if input == pw then
    print("nValid PW!")
    rs.setOutput(alarmSide,false)
    rs.setOutput(doorSide,true)
    sleep(5)
    rs.setOutput(doorSide,false)
  else
    print("nWrong PW!")
    rs.setOutput(alarmSide,true)
  end
  sleep(0.05)
end


And If it is, I neither need a MC Server nor do I have a youtube and its a pretty easy script
MysticT #3
Posted 07 July 2012 - 02:06 AM
Well, there's a tutorial on the wiki with working code for the password lock. To add the alarm, we need more details on how it should work.
Here's an example, it sets the second output if the password is incorrect.

local doorSide = "<side>" -- change to the side of the door
local alarmSide = "<side>"-- change to the side of the alarm
local password = "PasswordHere"
local openTime = 5 -- the time the door is open, in seconds

os.pullEvent = os.pullEventRaw
while true do
  term.clear()
  term.setCursorPos(1, 1)
  local pass = read("*")
  if pass == password then
	print("Password Correct")
	print("Opening the door...")
	rs.setOutput(alarmSide, false)
	rs.setOutput(doorSide, true)
	sleep(openTime)
	rs.setOutput(doorSide, false)
  else
	rs.setOutput(alarmSide, true)
  end
end

EDIT:
just a minute late :P/>/>
Anyway, like Pinkishu, I don't need either, and it's a pretty easy program.
Jackster #4
Posted 07 July 2012 - 04:12 AM
Thank you both.

I saw the link to the wiki right after posting this and made the script.
[media]http://www.youtube.com/watch?v=ywhP58jRmzQ[/media]


I did not know how easy Lua is. I used to code Pawno or what ever it is called.

Not the same language but is one that you can build things quickly as it is basic and easy to take things from examples.

Where is code stored so can I get to it from my FTP to edit or read? Because having to type it out is tacking time :P/>/>


Oh and one thing would like to find out is when you have the startup script.
terminating the script allowing you go edit and find the password.

One thing I can't seam to find is a way to disable terminating (os.pullEvent = os.pullEventRaw) and being able to get back to the script editor to change something.

As I might want to add more features later I don't want to permanently lock the computer.

Thanks again.
Kolpa #5
Posted 07 July 2012 - 09:19 AM
Thank you both.

I saw the link to the wiki right after posting this and made the script.
[media]http://www.youtube.com/watch?v=ywhP58jRmzQ[/media]


I did not know how easy Lua is. I used to code Pawno or what ever it is called.

Not the same language but is one that you can build things quickly as it is basic and easy to take things from examples.

Where is code stored so can I get to it from my FTP to edit or read? Because having to type it out is tacking time :P/>/>


Oh and one thing would like to find out is when you have the startup script.
terminating the script allowing you go edit and find the password.

One thing I can't seam to find is a way to disable terminating (os.pullEvent = os.pullEventRaw) and being able to get back to the script editor to change something.

As I might want to add more features later I don't want to permanently lock the computer.

Thanks again.
for the text reading part use

local pass = read("*")
to blank out the password
Jackster #6
Posted 07 July 2012 - 10:09 AM
Thank you both.

I saw the link to the wiki right after posting this and made the script.
[media]http://www.youtube.com/watch?v=ywhP58jRmzQ[/media]


I did not know how easy Lua is. I used to code Pawno or what ever it is called.

Not the same language but is one that you can build things quickly as it is basic and easy to take things from examples.

Where is code stored so can I get to it from my FTP to edit or read? Because having to type it out is tacking time :P/>/>


Oh and one thing would like to find out is when you have the startup script.
terminating the script allowing you go edit and find the password.

One thing I can't seam to find is a way to disable terminating (os.pullEvent = os.pullEventRaw) and being able to get back to the script editor to change something.

As I might want to add more features later I don't want to permanently lock the computer.

Thanks again.
for the text reading part use

local pass = read("*")
to blank out the password

I had that but wanted to show on the video to people what I entered :)/>/>
MysticT #7
Posted 07 July 2012 - 06:35 PM
The files are stored inside the server folder, in world/computer/<ID>, where ID is the id of the computer.

There's no way to dissable termination, but allow it at the same time (obiously), but you can place a disk drive next to the computer and a floppy with a blank stratup file, that should give you access to the computer.