SHOW:
|
|
- or go back to the newest paste.
| 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 |
| 6 | + | wmod.open(3) -- For water tank |
| 7 | - | wmod.open(4) --For lava 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 |
| 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 case for every liquid |
| 19 | + | -- Add one channel for each liquid |
| 20 | - | -- Change channel and text for each |
| 20 | + | |
| 21 | if senderChannel == 3 then | |
| 22 | mon.setCursorPos(1,2) | |
| 23 | mon.write(message .." ") | |
| 24 | elseif senderChannel == 4 then | |
| 25 | - | print(message .." from Water tank,") |
| 25 | + | |
| 26 | mon.write(message .." ") | |
| 27 | end | |
| 28 | end |