Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ogPrint = print
- function print(...)
- term.clearLine()
- ogPrint(...)
- end
- local args = {...}
- local modem = peripheral.find("modem")
- if (not modem) then return end
- modem.closeAll()
- term.clear()
- term.setCursorPos(1,1)
- local modemLimit = 128
- local bandLimit = 256
- local band = tonumber(args[1]) or 1
- local startRange = modemLimit * (band - 1)
- local endRange = modemLimit * band
- local i = startRange
- while i < endRange do
- modem.open(i)
- i = i + 1
- end
- while true do
- term.setCursorPos(1,1)
- print("Band: "..band)
- print("Range: "..startRange.." - "..endRange - 1)
- local event, modemSide, senderChannel,
- replyChannel, message, senderDistance = os.pullEvent()
- if (event == "modem_message") then
- term.clear()
- print("Received a message from channel: "..senderChannel)
- print("They expect a reply on channel: "..replyChannel)
- print("The message was: "..message)
- elseif (event == "key") then
- if (modemSide == keys.down or modemSide == keys.up) then
- if (modemSide == keys.up and band < bandLimit) then
- band = band + 1
- elseif (band > 1) then
- band = band - 1
- end
- local x = 0
- modem.closeAll()
- startRange = modemLimit * (band - 1)
- endRange = (modemLimit * band)
- x = startRange
- while x < endRange do
- modem.open(x)
- x = x + 1
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement