Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local uri = "https://discordapp.com/api/webhooks/885394220875807/FCm0iGEm6QO0YL1eG-TMdZpYhKFtFWPP4dTdeEP2HKLH3YahB2-R_nDpHqM-sQJjLg99"
- --local p = peripheral.find("warpdriveShipController")
- --if p == nil or p.isInterfaced() == nil then
- --print("No Controller Detected")
- --sleep(8)
- --os.reboot()
- --end
- local sides = peripheral.getNames()
- local shipcores = {}
- for _, side in pairs(sides) do
- if peripheral.getType(side) == "warpdriveShipController" then
- print("Wrapping " .. side)
- table.insert(shipcores, peripheral.wrap(side))
- end
- end
- while true do
- for _, shipcore in pairs(shipcores) do
- local name = shipcore.name()
- file = name:gsub(" ","")
- --os.setComputerLabel(name)
- local shipdim = shipcore.isInHyperspace() and "Hyperspace"or"Space/Planet"
- timeout = 10
- local pos
- repeat
- pos = shipcore.getLocalPosition()
- local x, y, z = shipcore.getLocalPosition()
- sleep(0.05)
- timeout = timeout - 1
- until pos ~= nil or timeout < 0
- if timeout < 0 then
- print(name.." Position Error")
- --sleep(10)
- --os.reboot()
- else
- local x,y,z = shipcore.getLocalPosition()
- local mass = shipcore.getShipSize()
- local energyStored, energyMax, energyUnits = shipcore.getEnergyStatus()
- local text = x .. " "..y.." "..z
- local oldText = ""
- if fs.exists("disk/ships/"..file) then
- local f = fs.open("disk/ships/"..file,"r");
- oldText = f.readAll();
- --print("No Movement")
- f.close();
- end
- if string.find(oldText, text) then
- print(name.." No Movement")
- else
- --if oldText ~= text then
- stt = "disk/ships/"..file
- print(stt)
- local f2 = fs.open(stt,"w")
- f2.write("Shipname: "..name.."\n")
- if energyMax <= 2057142 then core = "Shuttle" elseif energyMax <= 41142857 then core = "Corvette" else core = "Frigate"
- end
- f2.write("Type: "..core.."\n")
- f2.write("Dimension: "..shipdim.."\n")
- f2.write("Location: "..text.."\n")
- f2.write("Energy: "..energyStored.." "..energyUnits.."\n")
- f2.write("Tons: "..mass.."\n")
- print("Movment Detected");
- http.post(uri,"{\"content\":\"```yaml\\nShipname: "..name.." \\nType: "..core.." \\nDimension: "..shipdim.." \\nLocation: "..text.."\\nEnergy: "..energyStored.." "..energyUnits.."\\nTons: "..mass.."```\"}",{['content-type']="application/json"}); f2.close();
- end
- end
- sleep(5)
- end
- end
- --os.reboot();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement