Advertisement
MuChT007

Reactors control Switch V1.0

Mar 1st, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.24 KB | None | 0 0
  1. --Reactors control Switch V1.0--
  2.  
  3. local modem = peripheral.wrap("bottom") -- Modem position --
  4. modem.open(65001) --Open channel 65001 so that we can listen on it --
  5.  
  6. local c = 0
  7. while true do
  8.  
  9. print(""..c)
  10.  
  11. local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  12.  
  13.         if message=="on1" then
  14.         c = colors.combine(c, colours.blue)
  15.                 redstone.setBundledOutput("top", c)
  16.                 print("Start R1 requested")
  17.                 modem.transmit(65002, 65001, "1on")
  18.         end
  19.  
  20.         if message=="off1" then
  21.         c = colors.subtract(c, colours.blue)
  22.                 redstone.setBundledOutput("top", c)
  23.                 print("Stop R1 requested")
  24.         sleep(1)
  25.                 modem.transmit(65002, 65001, "1off")
  26.         end
  27.  
  28.         if message=="on2" then
  29.         c = colors.combine(c, colours.green)
  30.                 redstone.setBundledOutput("top", c)
  31.                 print("Start R2 requested")
  32.                 modem.transmit(65002, 65001, "2on")
  33.         end
  34.  
  35.         if message=="off2" then
  36.         c = colors.subtract(c, colours.green)
  37.                 redstone.setBundledOutput("top", c)
  38.                 print("Stop R2 requested")
  39.         sleep(2)
  40.                 modem.transmit(65002, 65001, "2off")
  41.         end
  42.  
  43.         if message=="on3" then
  44.         c = colors.combine(c, colours.yellow)
  45.                 redstone.setBundledOutput("top", c)
  46.                 print("Start R3 requested")
  47.                 modem.transmit(65002, 65001, "3on")
  48.         end
  49.  
  50.         if message=="off3" then
  51.         c = colors.subtract(c, colours.yellow)
  52.                 redstone.setBundledOutput("top", c)
  53.                 print("Stop R3 requested")
  54.         sleep(3)
  55.                 modem.transmit(65002, 65001, "3off")
  56.         end
  57.  
  58.         if message=="on4" then
  59.         c = colors.combine(c, colours.purple)
  60.                 redstone.setBundledOutput("top", c)
  61.                 print("Start R4 requested")
  62.                 modem.transmit(65002, 65001, "4on")
  63.         end
  64.  
  65.         if message=="off4" then
  66.         c = colors.subtract(c, colours.purple)
  67.                 redstone.setBundledOutput("top", c)
  68.                 print("Stop R4 requested")
  69.         sleep(4)
  70.                 modem.transmit(65002, 65001, "4off")
  71.         end
  72.  
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement