Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local uri = ""
- 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))
- elseif peripheral.getType(side) == "modem" then
- rednet.open(side)
- end
- end
- while true do
- for _, shipcore in pairs(shipcores) do
- local name = shipcore.name()
- file = name:gsub(" ","")
- local shipdim = shipcore.isInHyperspace() and "Hyperspace"or"Space/Planet"
- timeout = 10
- local pos = shipcore.getLocalPosition()
- local x, y, z = shipcore.getLocalPosition()
- repeat
- sleep(0.05)
- timeout = timeout - 1
- until pos ~= nil or timeout < 0
- if timeout < 0 then
- print(name.." Position Error")
- else
- text = x.." "..y.." "..z
- oldText = ""
- local mass = shipcore.getShipSize()
- local energyStored, energyMax, energyUnits = shipcore.getEnergyStatus()
- if fs.exists("disk/ships/"..file) then
- local f = fs.open("disk/ships/"..file,"r")
- oldText = f.readAll()
- f.close()
- end
- if string.match(oldText, x) and string.match(oldText, z) then
- print(name.." No Movement.")
- else
- stt = "disk/ships/"..file
- 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(name.." Movment Detected")
- http.post(uri,"{\"content\":\"```yaml\\nShipname: "..name.." \\nType: "..core.." \\nDimension: "..shipdim.." \\nLocation: "..text.."\\nEnergy: "..energyStored.." "..energyUnits.."\\nTons: "..mass.."```\"}",{['content-type']="application/json"})
- output ="\1672".."CoreNET: ".."\1674".."Movement Detected.\nShipname: "..name.." \nType: "..core.." \nDimension: "..shipdim.." \nLocation: "..text.."\nEnergy: "..energyStored.." "..energyUnits.."\nTons: "..mass
- rednet.broadcast(output)
- f2.close()
- end
- end
- sleep(5)
- end
- end
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement