Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ArchiCode, GauCode, ShackCode = 3, 2, 4
- local ArchiColor, GauColor, ShackColor = colors.red, colors.lightBlue, colors.purple
- local ArchiButton, GauButton, ShackButton = colors.orange, colors.yellow, colors.white
- function getCode()
- rednet.broadcast("ping")
- repeat
- event, ID,message, distance = os.pullEvent("rednet_message")
- until string.sub(message,1,4) == "rail"
- return tonumber(string.sub(message,5))
- end
- function setLight(color)
- rs.setBundledOutput("left",color)
- end
- function setLights(code)
- if ( bit.band(code, 2) ~= 0 ) then
- if ( bit.band(code,1) == 0 ) then
- setLight(GauColor)
- else
- setLight(ArchiColor)
- end
- return
- end
- if ( bit.band(code, 4) ~= 0 ) then setLight(ShackColor) return end
- setLight(0)
- end
- function sendCode(code)
- rednet.broadcast("rail" .. tostring(code))
- setLights(code)
- end
- rednet.open("top")
- local code = getCode()
- setLights(code)
- while true do
- event, id, message, distance = os.pullEvent()
- if ( event == "rednet_message" ) then
- if ( string.sub(message,1,4) == "rail" ) then
- local code = tonumber(string.sub(message,5))
- setLights(code)
- end
- end
- if ( event == "redstone" ) then
- local myColors = rs.getBundledInput("left")
- if ( colors.test(myColors,ArchiButton) ) then sendCode(ArchiCode) end
- if ( colors.test(myColors,GauButton) ) then sendCode(GauCode) end
- if ( colors.test(myColors,ShackButton) ) then sendCode(ShackCode) end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement