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

How do i make a program wait before x == true

Started by AnDwHaT5, 21 March 2013 - 11:53 AM
AnDwHaT5 #1
Posted 21 March 2013 - 12:53 PM
So im making a door into a mall with cc. I am using a i/o of redstone to make it. It checks for a redstone signal on the bottom and if it is true then it turns pistons off. My question. How do i make the program wait until there is a redstone signal.
Lyqyd #2
Posted 21 March 2013 - 01:07 PM
os.pullEvent("redstone") will wait for any redstone change.
ebernerd #3
Posted 21 March 2013 - 01:09 PM
Just so you know, you can do this with a "Memory Cell" in redstone logic…
Like this:


x = false
while x == false do
  input = rs.getInput("SIDE")
  if input == true then
	x = true
	while x == true do
	rs.setOutput("SIDE TO PISTON", true)
	b = rs.getInput("SAME SIDE AS INPUT")
	if b == true then -- have a seperate wire that connects to this side, as with the INPUT variable
	shell.run("programname")
	end
	end
  end
end
AnDwHaT5 #4
Posted 21 March 2013 - 01:30 PM
os.pullEvent("redstone") will wait for any redstone change.
Thank you thats all i needed. So with that i dont even need a redstone.getInput?
SuicidalSTDz #5
Posted 21 March 2013 - 01:31 PM
No, once any redstone current is detected on ANY side, it will fire the event and return the parameters if any are specified.
immibis #6
Posted 21 March 2013 - 03:24 PM
os.pullEvent("redstone") only waits for any redstone signal change, so you need to keep calling it, and check the signal each time, until you get the signal you want.