Advertisement
OmegaRogue

OC Geo1

May 25th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. local c = require("component")
  2. local geo = c.geolyzer
  3. local tunnel = c.tunnel
  4. local event = require("event")
  5. local ser = require("serialization")
  6.  
  7. local coords = {}
  8. local rows = {}
  9. local radius
  10.  
  11.  
  12. local function isInt(n)
  13. n = pcall(function() return n==math.floor(n) end)
  14. return not n
  15. end
  16.  
  17. local function readCoordinates(cor)
  18. local w = {}
  19. for word in string.gmatch(cor,"%S+") do
  20. table.insert(w,word)
  21. end
  22. coords = {
  23. x = w[1],
  24. y = w[2],
  25. z = w[3]
  26. }
  27. end
  28.  
  29.  
  30.  
  31.  
  32. io.write("Your coordinates: ")
  33. readCoordinates(io.read())
  34. if coords.x == nil or coords.y == nil or coords.z == nil then
  35. print("You didn't type them in correctly.")
  36. coords = {
  37. x = -3042,
  38. y = 56,
  39. z = 3031,
  40. }
  41. end
  42.  
  43. io.write("Radius: ")
  44. radius = io.read()
  45. if radius == "" or isInt(radius) then
  46. print("You didn't type it in correctly.")
  47. radius = 5
  48. end
  49.  
  50. tunnel.send("UserData",ser.serialize(coords),radius)
  51. os.sleep(1)
  52.  
  53. for x=-radius,radius-1 do
  54. for z=-radius,radius-1 do
  55. print("Scanning: " .. x .. " " .. z)
  56. table.insert(rows,ser.serialize(geo.scan(x,z,false)))
  57. end
  58. end
  59. io.write("Scan Complete. Send data?[Y/n] ")
  60. if string.lower(io.read()) == "y" then
  61. tunnel.send("maxPack",#rows)
  62. os.sleep(0.2)
  63. for i=1,#rows,4 do
  64. tunnel.send("Data",rows[i],rows[i+1],rows[i+2],rows[i+3])
  65. print("Sending package " .. i .. "/" .. #rows .. ".")
  66. os.sleep(0.2)
  67. end
  68. print("Sending package " .. #rows .. "/" .. #rows .. ".")
  69. print("Data sent.")
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement