Advertisement
CaptainResu

scan

Jun 16th, 2023 (edited)
960
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. args = {...}
  2. local ore = "diamonds"
  3. local radius = 16
  4. -- print("Starting with args: ")
  5. for i, ar in ipairs(args) do
  6.     -- print(ar)
  7.     if i == 1 then ore = ar end
  8.     if i == 2 then radius = tonumber(ar) end
  9. end
  10. if radius > 16 then radius = 16 end
  11. if radius < 1 then radius = 1 end
  12. print("Scanning: " .. ore .. " with " .. radius .. " radius")
  13. sleep(3)
  14.  
  15. function sortbydistance(a, b)
  16.     -- print("( " .. a.x .. ", " .. a.y .. ", " .. a.z .. " ) / (" .. b.x .. ", " .. b.y .. ", " .. b.z .. " )")
  17.     return ((math.abs(a.x) + math.abs(a.y) + math.abs(a.z)) < (math.abs(b.x) + math.abs(b.y) + math.abs(b.z)))
  18. end
  19.  
  20. local geoscanner = peripheral.find("geoScanner")
  21.  
  22. while true do
  23.     local scan = geoscanner.scan(radius)
  24.     -- print("test")
  25.    
  26.     if scan ~= nil then
  27.         table.sort(scan, sortbydistance)
  28.  
  29.         term.setBackgroundColor(colors.black)
  30.         term.clear()
  31.         term.setCursorPos(1,1)
  32.                
  33.         for i, bData in ipairs(scan) do
  34.             if bData.name == "minecraft:" .. ore .. "_ore" or bData.name == "minecraft:deepslate_" .. ore .. "_ore" then
  35.                 print(ore .. ": X" .. bData.x .. " Y" .. bData.y .. " Z" .. bData.z)
  36.             end
  37.         end
  38.     end
  39.     -- sleep(1)
  40. end
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement