Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- local Archi,BW,Gau = colors.purple, colors.orange, colors.yellow
- local ResetColor = colors.white
- local ID
- local ignoreReset = 0
- function sendNewCode(myColors)
- local value = 0
- if colors.test(myColors,Archi) then value = value + 1 end
- if colors.test(myColors,BW) then value = value + 2 end
- if colors.test(myColors,Gau) then value = value + 4 end
- if ( ID ~= nil ) then
- rednet.send(ID,"rail" .. value)
- else
- rednet.broadcast("rail" .. value)
- end
- end
- function resetNetwork()
- ignoreReset = 1
- rs.setBundledOutput("back",ResetColor)
- os.sleep(0.5)
- rs.setBundledOutput("back",0)
- end
- while true do
- event, ID,message, distance = os.pullEvent()
- if ( event == "rednet_message" ) then
- if ( string.sub(message,1,4) == "rail" ) then
- local value = tonumber(string.sub(message,5))
- local newColor = 0
- if ( bit.band(value, 1) ~= 0 ) then newColor = colors.combine(newColor,Archi) end
- if ( bit.band(value, 2) ~= 0 ) then newColor = colors.combine(newColor,BW) end
- if ( bit.band(value, 4) ~= 0 ) then newColor = colors.combine(newColor,Gau) end
- resetNetwork()
- rs.setBundledOutput("back",newColor)
- end
- if ( message == "ping" ) then
- os.sleep(1)
- local myColors = rs.getBundledInput("front")
- sendNewCode(myColors)
- end
- end
- if ( event == "redstone" and colors.test(rs.getBundledInput("front"),colors.white) ) then
- if ( ignoreReset == 0 ) then
- rs.setBundledOutput("back",0)
- os.sleep(5)
- local myColors = rs.getBundledInput("front")
- sendNewCode(myColors)
- else
- ignoreReset = 0
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement