Advertisement
giwdul

scan_area

Jan 15th, 2024 (edited)
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. -- Get a reference to the Geo Scanner attachment
  2. local geoScanner = peripheral.find("geoScanner")
  3. if not geoScanner then
  4.   error("Geo Scanner not found")
  5. end
  6.  
  7. -- Run a single scan with a specified radius
  8. local radius = 5 -- You can change this radius as needed
  9. local data, reason = geoScanner.scan(radius)
  10.  
  11. if not data then
  12.   print("Scan failed: " .. reason)
  13. else
  14.   print("Scan successful. Scanning for ores...")
  15.   local oreCount = 0
  16.   for i, block in ipairs(data) do
  17.     if string.find(block.name, "_ore$") then -- Check if the block name ends with "_ore"
  18.       oreCount = oreCount + 1
  19.       print(oreCount .. ": " .. block.name .. " at (x=" .. block.x .. ", y=" .. block.y .. ", z=" .. block.z .. ")")
  20.     end
  21.   end
  22.   if oreCount == 0 then
  23.     print("No ores found in the scan radius.")
  24.   end
  25. end
  26.  
Tags: scan_area
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement