jaklsfjlsak

ap

Feb 15th, 2021 (edited)
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. local uri = ""
  2. local sides = peripheral.getNames()
  3. local shipcores = {}
  4. for _, side in pairs(sides) do
  5. if peripheral.getType(side) == "warpdriveShipController" then
  6. print("Wrapping " .. side)
  7. table.insert(shipcores, peripheral.wrap(side))
  8. elseif peripheral.getType(side) == "modem" then
  9. rednet.open(side)
  10. end
  11. end
  12. sleep(0.1)
  13. while true do
  14. for _, shipcore in pairs(shipcores) do
  15. local name = shipcore.name()
  16. file = name:gsub(" ","")
  17. local shipdim = shipcore.isInHyperspace() and "Hyperspace"or"Space/Planet"
  18. timeout = 10
  19. sleep(0.1)
  20. repeat
  21. local pos
  22. pos = shipcore.getLocalPosition()
  23. local x, y, z
  24. x, y, z = shipcore.getLocalPosition()
  25. sleep(0.05)
  26. timeout = timeout - 1
  27. until pos ~= nil or timeout < 0
  28. if timeout < 0 then
  29. print(name.." Position Error")
  30. sleep(0.1)
  31. else
  32. text = x.." "..y.." "..z
  33. oldText = ""
  34. local mass = shipcore.getShipSize()
  35. local energyStored, energyMax, energyUnits = shipcore.getEnergyStatus()
  36. if fs.exists("disk/ships/"..file) then
  37. local f = fs.open("disk/ships/"..file,"r")
  38. oldText = f.readAll()
  39. f.close()
  40. end
  41. sleep(0.1)
  42. if string.find(oldText, text) then
  43. print(name.." No Movement")
  44. else
  45. sleep(0.1)
  46. stt = "disk/ships/"..file
  47. local f2 = fs.open(stt,"w")
  48. f2.write("Shipname: "..name.."\n")
  49. if energyMax <= 2057142 then core = "Shuttle" elseif energyMax <= 41142857 then core = "Corvette" else core = "Frigate"
  50. end
  51. sleep(0.1)
  52. f2.write("Type: "..core.."\n")
  53. f2.write("Dimension: "..shipdim.."\n")
  54. f2.write("Location: "..pos.."\n")
  55. f2.write("Energy: "..energyStored.." "..energyUnits.."\n")
  56. f2.write("Tons: "..mass.."\n")
  57. print(name.." Movment Detected")
  58. sleep(0.1)
  59. http.post(uri,"{\"content\":\"```yaml\\nShipname: "..name.." \\nType: "..core.." \\nDimension: "..shipdim.." \\nLocation: "..text.."\\nEnergy: "..energyStored.." "..energyUnits.."\\nTons: "..mass.."```\"}",{['content-type']="application/json"})
  60. sleep(0.1)
  61. output ="\1672".."CoreNET: ".."\1674".."Movement Detected.\nShipname: "..name.." \nType: "..core.." \nDimension: "..shipdim.." \nLocation: "..text.."\nEnergy: "..energyStored.." "..energyUnits.."\nTons: "..mass
  62. f2.close()
  63. end
  64. sleep(0.05)
  65. end
  66. sleep(5)
  67. end
  68. end
  69. os.reboot()
Add Comment
Please, Sign In to add comment