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

Redstone door with override button

Started by HoldenBurn, 08 January 2014 - 09:55 AM
HoldenBurn #1
Posted 08 January 2014 - 10:55 AM
Hi all,

First post and begging for help please. I only started CC yesterday!

I have made a bunker door (pistons) that opens with a password, all working great. the computer constantly outputs a signal and switches it off when I enter the word. All great.

But now I need to get back out. A button on the other side is fine. Was going to run the redstone into the back of the computer to "override" the signal.

Now I have the below code, which in all honesty I am just making up as I go. I know its last half which is not working.

If anyone could help me see where I am going wrong I would really appreciate it.

http://pastebin.com/V1SNUr3u

I have messed around with the last bit loads and cant get it to work. Think I'm close…

Thanks guys.
wieselkatze #2
Posted 08 January 2014 - 11:18 AM
The

elseif
redstone.getInput ("back", true) then
redstone.setOutput ("bottom", false)
sleep(5)
redstone.setOutput ("bottom", true)
end
part will never happen, until you type a password, because this part is only then triggered.
This "issue" was also already talked about in another post.
http://www.computercraft.info/forums2/index.php?/topic/16626-making-if-read-or-rsgetinput-then/
6677 #3
Posted 08 January 2014 - 11:20 AM
Read is a blocking command (and a yielding one too if you eventually use the co-routine or parallel api's one day).

While the computer is waiting at read, it cannot do anything except wait for keypresses. It won't allow for any redstone events or anything like that.

Therefore your little check for the back redstone input is only going to be executed during the elseif routine *after* you input some text.


Some reading for you, hop over to the tutorials section and look up events.
robhol #4
Posted 08 January 2014 - 11:54 AM
You can also just hook it up with redstone, if you have the room to do it. What you need is a NOR/OR gate depending on how you wired the rest.
It's definitely doable programmatically too, though, but it's a bit complicated because you can't read input from the user AND listen for redstone events without either using coroutines, parallel, or writing your own logic for handling each key press individually. Parallel is probably the easiest by quite a margin.
HoldenBurn #5
Posted 08 January 2014 - 01:31 PM
Ahh ok thanks a lot guys. Will check out everything you have mentioned.

Will look into just sorting it through redstone for now (another area I'm not great!)

Just for my own piece of mind. Although it won't work due to the issues mentioned. Was I on the right lines? Was mainly guess work.

Thanks again.