Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- on = redstone.getAnalogInput(lever)
- if on > 6 then
- w.statusshowWarning("AutoPilot: Disabled")
- sleep(3)
- elseif on < 5 then
- if fs.exists(navdatafile) then
- local h = fs.open(navdatafile, "r")
- local text = h.readAll()
- navdata = textutils.unserialize(text)
- h.close()
- for , core in ipairs(cores) do
- local wrap = core.wrapper
- while true do
- local status, isEnabled, state, energy = wrap.state()
- if state ~= "COOLING" then break end
- w.status_showWarning("Waiting Ship is in " .. state .. " mode")
- sleep(5)
- end
- while true do
- local status, isEnabled, state, energy = wrap.state()
- if state ~= "-NotDetected-" then break end
- w.status_showWarning("Waiting to connect to core(s)...")
- sleep(5)
- end
- end
- --------------------------------------AUTO PILOT
- for i=1,#navdata do
- local move = navdata[i]
- w.status_showSuccess("Executing Jump. There are "..#navdata.." Jump(s) left.")
- http.post(uri,"{"content":"
- yaml\\nAutopilot: Executing next node There are "..#navdata.." node(s) left to execute.
- "}",{['content-type']="application/json"})
- table.remove(navdata,1)
- if fs.exists(navbackup) then
- fs.delete(navbackup)
- fs.copy(navdatafile, navbackup)
- end
- if #navdata > 0 then
- local text = textutils.serialize(navdata)
- local h = fs.open(navdatafile, "w")
- h.write(text)
- h.close()
- else
- fs.delete(navdatafile)
- end
- ship.command("MANUAL", false)
- ship.movement(move[1],move[2],move[3])
- ship.rotationSteps(0)
- ship.command("MANUAL", true)
- sleep(10)
- for i=50,0,-1 do
- w.status_showWarning("Waiting for the ship to jump..."..i.." ")
- sleep(1)
- end
- number = #navdata + 1
- http.post(uri,"{"content":"
- yaml\\nAutoPilot: Failed Executing node "..number..".
- "}",{['content-type']="application/json"})
- fs.delete(navdatafile)
- fs.copy(navbackup, navdatafile)
- w.status_showWarning("AutoPilot: Failed Executing node " .. number)
- if failping >= 0 then
- http.post(uri,"{"content":""..name..""}",{['content-type']="application/json"})
- end
- sleep(3)
- os.reboot()
- end
- --------------------------------------AUTO PILOT
- end
- end
- -- while true do
- -- local status, isEnabled, state, energy = ship.state()
- -- if state == "COOLING" then
- -- w.status_showWarning("Waiting Ship is in " .. state .. " mode")
- -- sleep(5)
- -- elseif state == "-NotDetected-" then
- -- w.statusshowWarning("Waiting to connect to core(s)...")
- -- sleep(5)
- -- else
- -- break
- -- end
- -- end
- for , core in ipairs(cores) do
- local wrap = core.wrapper
- while true do
- local status, isEnabled, state, energy = wrap.state()
- if state ~= "COOLING" then break end
- w.status_showWarning("Waiting Ship is in " .. state .. " mode")
- sleep(5)
- end
- while true do
- local status, isEnabled, state, energy = wrap.state()
- if state ~= "-NotDetected-" then break end
- w.status_showWarning("Waiting to connect to core(s)...")
- sleep(5)
- end
- end
- local success, message = pcall(w.run)
- if not success then
- print("failed with message")
- print(message)
- w.sleep(5)
- print("rebooting...")
- w.reboot()
- else
- if ship ~= nil then
- ship.command("OFFLINE", true)
- ship.enable(false)
- end
- w.close()
- end
- =================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement