Guest User

righty

a guest
Oct 5th, 2013
2,207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. -- Wrap the modem and monitor
  2. local mon = peripheral.wrap("top")
  3. local wmod = peripheral.wrap("back")
  4.  
  5. -- Open different channels for different liquids
  6. wmod.open(3) --For water tank
  7. wmod.open(4) --For lava tank
  8.  
  9. mon.clear()
  10. mon.setCursorPos(1,1)
  11. mon.write("Liquid status:")
  12.  
  13. -- Main loop, never stop
  14. while true do
  15.  
  16.   -- Check for incoming data on any open channel
  17.   local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  18.  
  19.   -- Add one case for every liquid
  20.   -- Change channel and text for each
  21.  
  22.   if senderChannel == 3 then
  23.     mon.setCursorPos(1,2)
  24.     mon.write(message .."        ")
  25.     print(message .." from Water tank,")
  26.   elseif senderChannel == 4 then
  27.     mon.setCursorPos(1,3)
  28.     mon.write(message .."        ")
  29.     print(message .." from Lava tank.")  
  30.   end
  31.  
  32. end
Advertisement
Add Comment
Please, Sign In to add comment