Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Wrap the modem and monitor
- local mon = peripheral.wrap("top")
- local wmod = peripheral.wrap("bottom")
- --Open different channels for different liquids
- wmod.open(1) --FirstWaterTank
- wmod.open(2) --FirstWaterTank -> Warning
- wmod.open(3) --2ndWaterTank
- wmod.open(4) --2ndWaterTank -> Warning
- wmod.open(5) --2ndWaterTank
- wmod.open(6) --2ndWaterTank -> Warning
- mon.clear()
- mon.setCursorPos(1,1)
- mon.setTextScale(1.4)
- mon.setTextColour(colors.orange)
- mon.write("Liquid Status:")
- -- Main loop, never stop
- while true do
- -- Check for incoming data on any open channel
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- -- Add one case for every liquid
- -- Change channel and text for each
- if senderChannel == 1 or senderChannel == 2 then
- mon.setCursorPos(1,2)
- print(message .." - WaterTank1,")
- if senderChannel == 1 then
- mon.setTextColour(colors.cyan)
- else
- mon.setTextColour(colors.red)
- end
- mon.write(message .." ")
- elseif senderChannel == 3 or senderChannel == 4 then
- mon.setCursorPos(1,3)
- print(message .." - WaterTank2,")
- if senderChannel == 3 then
- mon.setTextColour(colors.cyan)
- else
- mon.setTextColour(colors.red)
- end
- mon.write(message .." ")
- elseif senderChannel == 5 or senderChannel == 6 then
- mon.setCursorPos(1,4)
- print(message .." - Oil,")
- if senderChannel == 3 then
- mon.setTextColour(colors.lightGray)
- else
- mon.setTextColour(colors.red)
- end
- mon.write(message .." ")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement