Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function lightChange(state, color, sSide)
- if state == "on" then do -- Turns on a specific light
- if color == "1" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide),colors.white))
- elseif color == "2" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.orange))
- elseif color == "3" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.magenta))
- elseif color == "4" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.lightBlue))
- elseif color == "5" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.yellow))
- elseif color == "6" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.lime))
- elseif color == "7" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.pink))
- elseif color == "8" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.gray))
- elseif color == "9" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.lightGray))
- elseif color == "10" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.cyan))
- elseif color == "11" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.purple))
- elseif color == "12" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.blue))
- elseif color == "13" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.brown))
- elseif color == "14" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.green))
- elseif color == "15" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.red))
- else print("Invalid light channel! Please call your doctor for medicine NOW!!!")
- end
- end
- elseif state == "off" then do --Turns off a specific light
- if color == "1" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide),colors.white))
- elseif color == "2" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.orange))
- elseif color == "3" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.magenta))
- elseif color == "4" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.lightBlue))
- elseif color == "5" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.yellow))
- elseif color == "6" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.lime))
- elseif color == "7" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.pink))
- elseif color == "8" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.gray))
- elseif color == "9" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.lightGray))
- elseif color == "10" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.cyan))
- elseif color == "11" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.purple))
- elseif color == "12" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.blue))
- elseif color == "13" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.brown))
- elseif color == "14" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.green))
- elseif color == "15" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.red))
- else print("Invalid light channel! Please call your doctor for medicine NOW!!!")
- end
- end
- elseif state == "allOn" then redstone.setBundledOutput(sSide, colors.combine(colors.white, colors.orange, colors.magenta, colors.lightBlue, colors.yellow, colors.lime, colors.pink, colors.gray, colors.lightGray, colors.cyan, colors.purple, colors.blue, colors.brown, colors.green, colors.red)) --Turns on all lights on the row
- elseif state == "allOff" then redstone.setBundledOutput(sSide, 0) -- Turns off all lights on the row
- else print("Invalid state detected. Please call your doctor if you have an erection lasting longer than four hours.")
- end
- end
- function main()
- rednet.open("bottom") --Open the bottom side to listen for light messages
- rednet.host("NIGGAJAMES", "1") --Register the slave as row# to the protocol NIGGAJAMES
- local senderID, action_and_color, protocol, action, color
- while true do
- senderID, action_and_color, protocol = rednet.receive("1") --Waits for a message from the master corresponding to row 1
- action = action_and_color[1]
- color = action_and_color[2]
- if action == "on" or action == "off" then
- print("Changing light "..color.." to "..action)
- elseif action == "allOn" then
- print("Turning all lights on in this row")
- elseif action == "allOff" then
- print("Turning all lights off in this row")
- else
- print("Go get yourself checked for herpes. Please.")
- end
- lightChange(action, color, "back") --Performs the light change for the row
- end
- end -- End of main()
- main()
Advertisement
Add Comment
Please, Sign In to add comment