jonassvensson4

Main computer - TANK READER

Apr 11th, 2014
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
  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 channel for each liquid
  20.  
  21.   if senderChannel == 3 then
  22.     mon.setCursorPos(1,2)
  23.     mon.write(message .."        ")
  24.   elseif senderChannel == 4 then
  25.     mon.setCursorPos(1,3)
  26.     mon.write(message .."        ")
  27.   end
  28. end
Advertisement
Add Comment
Please, Sign In to add comment