alesandreo

geoscan_analyze.lua

Mar 30th, 2022 (edited)
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. -- f4MZ8ATi
  2. -- Stores arguments passed from the command line into a table.
  3. args = {...}
  4. scanner = peripheral.wrap("back")
  5. -- the first argument is [1]
  6. target_block = args[1]
  7. if not scanner then
  8.     error("Requires Scanner")
  9. end
  10.  
  11. -- Function that just searches through a table's keys for a substring.
  12. function search(tbl, k2)
  13.     if tbl then
  14.         for k, v in pairs(tbl) do
  15.             if string.find(k, target_block) then
  16.                 print(v.." "..k)
  17.                 break
  18.             end
  19.         end
  20.     end
  21. end
  22.  
  23. -- This while loop just continues while you walk around.
  24. count = 0
  25. while true do
  26.     count = count + 1
  27.     term.setCursorPos(1,1)
  28.     term.clear()
  29.     print("Scan #"..count)
  30.     -- scanner.chunkAnalyze returns a list of all ORE in the chunk, and its quantity.
  31.     search(scanner.chunkAnalyze(), target_block)
  32.     while ( scanner.getOperationCooldown("scanBlocks") > 0 ) do
  33.         os.sleep(0.1)
  34.     end
  35. end
Add Comment
Please, Sign In to add comment