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("back")
- -- Close all channels by default in case
- -- users have other transmissions in air
- wmod.closeAll()
- -- Open different channels for different liquids
- -- Only 2+3 are open by default, open the
- -- ones you're using to prevent errors.
- wmod.open(2) -- water?
- wmod.open(3) -- lava?
- --wmod.open(4) -- x
- --wmod.open(5) -- x
- --wmod.open(6) -- x
- --wmod.open(7) -- x
- --wmod.open(8) -- x
- --wmod.open(9) -- x
- --wmod.open(10) -- x
- --wmod.open(11) -- x
- --wmod.open(12) -- x
- mon.clear()
- mon.setTextColor(colors.white)
- mon.setCursorPos(1,1)
- mon.write("Tank:")
- -- 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
- -- First check color
- if string.match(message, ".red.") then
- mon.setTextColor(colors.red)
- message = string.gsub(message, ".red.", "")
- elseif string.match(message, ".green.") then
- mon.setTextColor(colors.green)
- message = string.gsub(message, ".green.", "")
- end
- -- I have prepared for 11 channels.
- -- They should match channels up at top!
- if senderChannel == 2 then
- mon.setCursorPos(1,2)
- elseif senderChannel == 3 then
- mon.setCursorPos(1,2)
- elseif senderChannel == 4 then
- mon.setCursorPos(1,4)
- elseif senderChannel == 5 then
- mon.setCursorPos(1,5)
- elseif senderChannel == 6 then
- mon.setCursorPos(1,6)
- elseif senderChannel == 7 then
- mon.setCursorPos(1,7)
- elseif senderChannel == 8 then
- mon.setCursorPos(1,8)
- elseif senderChannel == 9 then
- mon.setCursorPos(1,9)
- elseif senderChannel == 10 then
- mon.setCursorPos(1,10)
- elseif senderChannel == 11 then
- mon.setCursorPos(1,11)
- elseif senderChannel == 12 then
- mon.setCursorPos(1,12)
- end
- mon.write(message .." ")
- print("Received " ..message)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement