Advertisement
XDemonic

ComputerCraft - Main

Mar 25th, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1.         -- Wrap the modem and monitor
  2.         local mon = peripheral.wrap("top")
  3.         local wmod = peripheral.wrap("bottom")
  4.          
  5.         --Open different channels for different liquids
  6.         wmod.open(1) --FirstWaterTank
  7.         wmod.open(2) --FirstWaterTank -> Warning
  8.         wmod.open(3) --2ndWaterTank
  9.         wmod.open(4) --2ndWaterTank -> Warning
  10.         wmod.open(5) --2ndWaterTank
  11.         wmod.open(6) --2ndWaterTank -> Warning
  12.          
  13.         mon.clear()
  14.         mon.setCursorPos(1,1)
  15.         mon.setTextScale(1.4)
  16.         mon.setTextColour(colors.orange)
  17.         mon.write("Liquid Status:")
  18.          
  19.         -- Main loop, never stop
  20.         while true do
  21.           -- Check for incoming data on any open channel
  22.           local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  23.          
  24.           -- Add one case for every liquid
  25.           -- Change channel and text for each
  26.          
  27.           if senderChannel == 1  or senderChannel == 2 then
  28.             mon.setCursorPos(1,2)
  29.             print(message .." - WaterTank1,")
  30.             if senderChannel == 1 then
  31.             mon.setTextColour(colors.cyan)
  32.             else
  33.             mon.setTextColour(colors.red)
  34.             end
  35.             mon.write(message .."                             ")
  36.           elseif senderChannel == 3  or senderChannel == 4 then
  37.             mon.setCursorPos(1,3)
  38.             print(message .." - WaterTank2,")
  39.             if senderChannel == 3 then
  40.             mon.setTextColour(colors.cyan)
  41.             else
  42.             mon.setTextColour(colors.red)
  43.             end
  44.             mon.write(message .."                             ")
  45.           elseif senderChannel == 5  or senderChannel == 6 then
  46.             mon.setCursorPos(1,4)
  47.             print(message .." - Oil,")
  48.             if senderChannel == 3 then
  49.             mon.setTextColour(colors.lightGray)
  50.             else
  51.             mon.setTextColour(colors.red)
  52.             end
  53.             mon.write(message .."                             ")
  54.           end
  55.          
  56.         end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement