Advertisement
Guest User

startup

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