guitarplayer616

scan

Dec 13th, 2021 (edited)
1,052
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. local tArgs = {...}
  2. if #tArgs ~= 1 and #tArgs ~= 4 then
  3.     print("Usage: ")
  4.     print("Scan <filter>")
  5.     print("Scan <filter> [x] [y] [z]")
  6.     error()
  7. end
  8.  
  9. local gps_enabled = false
  10. if gps and gps.locate and gps.locate() then
  11.     gps_enabled = true
  12. end
  13.  
  14. print("Scanning...")
  15. p = peripheral.wrap("top")
  16. tbl = p.scan(8)
  17.  
  18.  
  19. for i,v in pairs(tbl) do
  20.   if v.name:find(tArgs[1]) then
  21.     if #tArgs == 4 then
  22.         print(tArgs[2]+v.x, tArgs[3]+v.y, tArgs[4]+v.z)
  23.     else
  24.         if gps_enabled then
  25.             local x,y,z = gps.locate()
  26.             print(x+v.x, y+v.y, z+v.z)
  27.         else
  28.             print("Found")
  29.         end
  30.     end
  31.   end
  32.  
  33. end
Add Comment
Please, Sign In to add comment