Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args={...}
- local hopSlice = tonumber(args[1]) or 1
- local modems = {}
- for k,v in pairs(rs.getSides()) do
- if peripheral.getType(v)=="modem" then
- modems[#modems+1] = peripheral.wrap(v)
- end
- end
- print("Found " .. #modems .. " modem"..(#modems>1 and "s " or " ")..", estimated total hop time is " .. (65535 / (#modems * 128)) * hopSlice .. " seconds.")
- while true do
- for i=0,65535,128 * #modems do
- print("Hopping on channel range " .. i .. " to " .. i+127)
- for i=i,i+127 do
- for j=1,#modems do
- modems[j].open((i + math.floor(65535 / #modems)) % 65535)
- end
- end
- os.startTimer(hopSlice)
- while true do
- local e,side,recvChan,replyChan,msg,dist = os.pullEvent()
- if e == "timer" then
- break
- elseif e == "modem_message" then
- print("Message on " .. recvChan .. ":" .. replyChan .. ", '"..msg.."'")
- end
- end
- for j=1,#modems do
- modems[j].closeAll()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment