-- 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
Simple flashing lights using bundled cables and CC
Started by iceman11a, Jan 30 2015 08:42 PM
2 replies to this topic
#1
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.
#2
Posted 30 January 2015 - 09:30 PM
The rs.getBundledInput call only takes one argument, and returns the numeric value of the currently active wires. If you want to check against a specific value, you'll likely want to use colors.test:
local isOn = colors.test(rs.getBundledInput("right"), colors.brown)
#3
Posted 30 January 2015 - 10:30 PM
Thank you, That works
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











