Stary2001

Untitled

Feb 12th, 2013
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. local modems = {}
  2. for k,v in pairs(rs.getSides()) do
  3. if peripheral.getType(v)=="modem" then
  4. modems[#modems+1] = peripheral.wrap(v)
  5. end
  6. end
  7.  
  8. print("Found " .. #modems .. " modem"..(#modems>1 and "s " or " ")..", estimated total hop time is " .. (65535 / (#modems * 128)) * 0.05 .. " seconds.")
  9.  
  10. while true do
  11. for i=0,65535,128 * #modems do
  12. print("Hopping on channel range " .. i .. " to " .. i+127)
  13. for i=i,i+127 do
  14. for j=1,#modems do
  15. modems[j].open((i + math.floor(65535 / #modems)) % 65535)
  16. end
  17. end
  18.  
  19. os.startTimer(0.05)
  20. while true do
  21. local e,side,recvChan,replyChan,msg,dist = os.pullEvent()
  22. if e == "timer" then
  23. break
  24. elseif e == "modem_message" then
  25. print("Message on " .. recvChan .. ":" .. replyChan .. ", '"..msg.."'")
  26. end
  27. end
  28. for j=1,#modems do
  29. modems[j].closeAll()
  30. end
  31. end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment