dcchill

radar

Apr 24th, 2023
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. local radar = peripheral.find("radar") -- assuming the radar peripheral is connected to the computer
  2.  
  3. -- set the range to scan (in blocks)
  4. local range = 100
  5.  
  6. -- get the coordinates of the computer
  7. local x, y, z = gps.locate()
  8.  
  9. -- scan for ships within the range
  10. local ships = radar.scanShips(x-range, y-range, z-range, x+range, y+range, z+range)
  11.  
  12. -- print the number of ships found
  13. print("Number of ships found: " .. #ships)
  14.  
  15. -- print the coordinates of each ship
  16. for i, ship in ipairs(ships) do
  17. print("Ship " .. i .. " found at (" .. ship.x .. ", " .. ship.y .. ", " .. ship.z .. ")")
  18. end
  19.  
Advertisement
Add Comment
Please, Sign In to add comment