MastaC729

Disco Floor Slave Computer Program

Aug 22nd, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.30 KB | None | 0 0
  1. function lightChange(state, color, sSide)
  2.     if state == "on"    then do         -- Turns on a specific light
  3.         if color == "1" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide),colors.white))
  4.         elseif color == "2" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.orange))
  5.         elseif color == "3" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.magenta))
  6.         elseif color == "4" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.lightBlue))
  7.         elseif color == "5" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.yellow))
  8.         elseif color == "6" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.lime))
  9.         elseif color == "7" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.pink))
  10.         elseif color == "8" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.gray))
  11.         elseif color == "9" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.lightGray))
  12.         elseif color == "10" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.cyan))
  13.         elseif color == "11" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.purple))
  14.         elseif color == "12" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.blue))
  15.         elseif color == "13" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.brown))
  16.         elseif color == "14" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.green))
  17.         elseif color == "15" then rs.setBundledOutput(sSide, colors.combine(redstone.getBundledOutput(sSide), colors.red))
  18.         else print("Invalid light channel! Please call your doctor for medicine NOW!!!")
  19.         end
  20.     end
  21.     elseif state == "off" then do       --Turns off a specific light
  22.         if color == "1" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide),colors.white))
  23.         elseif color == "2" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.orange))
  24.         elseif color == "3" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.magenta))
  25.         elseif color == "4" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.lightBlue))
  26.         elseif color == "5" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.yellow))
  27.         elseif color == "6" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.lime))
  28.         elseif color == "7" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.pink))
  29.         elseif color == "8" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.gray))
  30.         elseif color == "9" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.lightGray))
  31.         elseif color == "10" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.cyan))
  32.         elseif color == "11" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.purple))
  33.         elseif color == "12" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.blue))
  34.         elseif color == "13" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.brown))
  35.         elseif color == "14" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.green))
  36.         elseif color == "15" then rs.setBundledOutput(sSide, colors.subtract(redstone.getBundledOutput(sSide), colors.red))
  37.         else print("Invalid light channel! Please call your doctor for medicine NOW!!!")
  38.         end
  39.     end
  40.     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
  41.     elseif state == "allOff" then redstone.setBundledOutput(sSide, 0)  -- Turns off all lights on the row
  42.     else print("Invalid state detected. Please call your doctor if you have an erection lasting longer than four hours.")
  43.     end
  44. end
  45.  
  46. function main()
  47.     rednet.open("bottom")           --Open the bottom side to listen for light messages
  48.     rednet.host("NIGGAJAMES", "1")  --Register the slave as row# to the protocol NIGGAJAMES
  49.  
  50.     local senderID, action_and_color, protocol, action, color
  51.  
  52.     while true do
  53.         senderID, action_and_color, protocol = rednet.receive("1")      --Waits for a message from the master corresponding to row 1
  54.         action = action_and_color[1]
  55.         color = action_and_color[2]
  56.         if action == "on" or action == "off" then
  57.             print("Changing light "..color.." to "..action)
  58.         elseif action == "allOn" then
  59.             print("Turning all lights on in this row")
  60.         elseif action == "allOff" then
  61.             print("Turning all lights off in this row")
  62.         else
  63.             print("Go get yourself checked for herpes. Please.")
  64.         end
  65.  
  66.         lightChange(action, color, "back")      --Performs the light change for the row
  67.     end
  68. end     -- End of main()
  69.  
  70. main()
Advertisement
Add Comment
Please, Sign In to add comment