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

rs.output 2 ways

Started by Xixili, 21 April 2014 - 04:06 PM
Xixili #1
Posted 21 April 2014 - 06:06 PM
Hello everyone.

Is it possible to have a redstone output on 2 sides the same moment?

For example the code below.
When the reactor turns online it sends a signal up (to turn on the reactor)
But I also want a output on the bottom the same moment.

I wonder if thats possible.


rednet.open("bottom") -- set rednet side
console = 314 -- enter ID of computer attached to the touch screen
nir = 313 -- enter ID of computer attached to the Nuclear information reader
maxTemp = 5000
temp = 1000
rctrStatus = "off"

while true do
  a,b = rednet.receive()
    if a == console then
	  if b == "on" then
	    rs.setOutput("top", true)
	    rctrStatus = "on"
	    break
	  elseif b == "off" then
	    break
	  end
    end
end		   

while true do
  if temp >= maxTemp then
    rs.setOutput("top", false)
--  elseif temp >= 7500 then
--    rs.setOutput("back" ,false)
  end
  a,b = rednet.receive()
  if a == nir then
    temp = tonumber(B)/>
  elseif a == console then
    if b == "maxTemp" then
	  rednet.send(console, "ping")
	  id, message = rednet.receive()
	  message = tonumber(message)
	  --if message < 7500 and
	    if id == console then
	    maxTemp = message
	    rednet.send(console, "true")
	  else
	    rednet.send(console, "false")
	  end
    elseif b == "on" then
	  if temp < maxTemp then
	    rs.setOutput("top", true)
	    rednet.send(console, "true")
	    rctrStatus = "on"
	    print("On received")
	  else
	    rednet.send(console, "false")
	  end
    elseif b == "off" then
	  rs.setOutput("top", false)
	  rednet.send(console, "true")
	  rctrStatus ="Off"
    end
  end
end
CometWolf #2
Posted 21 April 2014 - 06:24 PM
The code on the computer performs much much much faster than mc's tick-rate, which is what redstone runs on, meaning that just calling 2 rs.setOutputs in a row will result in 2 simoultaneous signals.
Bomb Bloke #3
Posted 22 April 2014 - 12:26 AM
Well… low as it is, there's still a chance they won't turn on within the same tick.

I assume it doesn't matter if it's not "instant" 100% of the time, but why not use one output and connect it to your multiple inputs?