Advertisement
thelockj

Scanner

Aug 9th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. local tArgs = { ... }
  2.   --Computer Craft Frequency Scanner
  3.   --Scans all frequencies (most frequencies are found in the first % complete update)
  4.   --Takes 1h 15min to complete a full scan (Only 128 frequencies can be scanned at once)
  5. local max = 511
  6. if type(tArgs[1]) == "string" and tArgs[1] == "quick" then
  7.   max = 64
  8. end
  9. modem = peripheral.wrap( "back" )
  10. for j = 0,max,1 do
  11.   for i = j*128,j*128+127,1 do
  12.     modem.open(i)
  13.   end
  14.   local timeout = os.startTimer(10)
  15.   while true do
  16.     event = {os.pullEvent()}
  17.       if event[1] == "modem_message" then
  18.         print(event[3]..": "..senderDistance.."m")
  19.       elseif event[1] == "timer" and event[2] == timeout then
  20.         break
  21.       end
  22.   end
  23.   for i = j*128,j*128+127,1 do
  24.     modem.close(i)
  25.   end
  26.   if math.mod(j, 32) == 0 then
  27.     print((j/511).."% Complete (0 ->"..(j*128+127)..")")
  28.   end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement