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

Sliding door code program problem

Started by Robskin, 05 May 2013 - 01:55 AM
Robskin #1
Posted 05 May 2013 - 03:55 AM
Ok, so i'm making a slide door, that opens and closes with a computer. Easy! Done that (this is done in tekkit) then i came inside and had no idea how to get out… Sooo! I connected a button to the PC in another input, and tried to make it open from the inside aswell!


term.clear()
term.setCursorPos(1,1)
os.pullEvent = os.pullEventRaw

password = "1234"
editpassword = "4321"

print("Robskin's security door")
write "Please type Password: "
local input = read("X")

if input == (password) then
print("Correct!")
rs.setOutput("back", true)
sleep(0.5)
rs.setOutput("back", false)
sleep(0.5)
rs.setOutput("back", true)
sleep(0.5)
rs.setOutput("back", false)
sleep(4.0)
rs.setOutput("bottom", true)

sleep(0.5)
rs.setOutput("bottom", false)
sleep(0.5)
rs.setOutput("bottom", true)
sleep(0.5)
rs.setOutput("bottom", false)
sleep(4.0)
shell.run("startup")

elseif input == (editpassword) then
print("Welcome Robskin, unlocking terminal!")
sleep(2.0)
print("Feel free to edit me :D/>")

else
print("Wrong password, please try again")
sleep(3)
shell.run("startup")

end

--This is where I added the button part!

if rs.outPut("top", true) then

rs.setOutput("top", true)
sleep(0.5)
rs.setOutput("top", false)
sleep(0.5)
rs.setOutput("top", true)
sleep(0.5)
rs.setOutput("top", false)
sleep(4.0)
rs.setOutput("bottom", true)

sleep(0.5)
rs.setOutput("bottom", false)
sleep(0.5)
rs.setOutput("bottom", true)
sleep(0.5)
rs.setOutput("bottom", false)
sleep(4.0)
shell.run("startup")

end

I don't know what the problem is. No errors, just that it wont open with the button…
Edited by
Lyqyd #2
Posted 05 May 2013 - 12:17 PM
Split into new topic.
H4X0RZ #3
Posted 05 May 2013 - 01:49 PM
Robskin said:
-snip-

-Snip-
 if rs.outPut("top", true) then
-Snip
-Snip-

I think you mean

if rs.getInput("top", true)

:D/>/>
Robskin #4
Posted 05 May 2013 - 01:58 PM
Ok I did that, no errors accure. But it still wont open, nothing happends… Is it because alloy doesnt work on the computer? :s
jumpingjoran #5
Posted 05 May 2013 - 04:02 PM
Do u have the alloy ON the computer or leading to it?
Cuz u have to place the alloy ON the computer if u have the input on 'top' or else try to place redstonedust on top of the computer and then connect that to the alloy
diegodan1893 #6
Posted 05 May 2013 - 04:06 PM
Yes, alloy works on the computer, and RP2 bundled cable too.

Your problem is that you are checking if the button is pressed only when you open the program the first time and you don't check again. You need to use events.
In this case, replace your button code with this:


while true do
   os.pullEvent("redstone")
   if rs.getInput("top") then  --'or the side where your button is connected'
	  --'add here your code to open the door'
   end
end