Posted 30 January 2015 - 08:42 PM
The idea behind this is when a train comes by and starts a signal from a receiver box (railcraft) it sends a signal on the brown wire to the the computer. When the computer detects the signals. It starts light flashing on the red and white wires. The problem is that the code below looks ok to me. This coding in lua has to have some thing different. It doesn't work. I have code on other languages before and if statements were never a problem. This should work and doesn't. I was wonder what I'm doing wrong. Any one have some idea about this.
-- Simple Rail road crossing signals
local mon = peripheral.wrap("monitor_7")
rs.setBundledOutput("right", 0)
while true do
local isOn = rs.getBundledInput("right", colors.brown)
if isOn == true then
mon.clear()
mon.setCursorPos(1,1)
mon.setTextColor(colors.red)
mon.write("train is coming thew")
rs.setBundledOutput("right", 0)
rs.setBundledOutput("right", colors.red)
sleep(1)
rs.setBundledOutput("right", 0)
rs.setBundledOutput("right", colors.white)
sleep(1)
else
rs.setBundledOutput("right", 0)
mon.clear()
mon.setCurorPos(1,1)
mon.setTextColor(colors.green)
mon.write("No Train yet")
end
--rs.setBundledOutput("right", 0)
end