From 8a1560bdec6033f97f338b72355334a1f4dd8e88 Mon Sep 17 00:00:00 2001 From: Jean Delgado Date: Tue, 16 Mar 2021 22:52:15 -0700 Subject: [PATCH 1/3] Orbiting improvements --- ButtonHUD.conf | 4 +-- ChangeLog.md | 4 +++ src/ButtonHUD.lua | 79 ++++++++++++++++++++++++++++++++--------------- 3 files changed, 60 insertions(+), 27 deletions(-) diff --git a/ButtonHUD.conf b/ButtonHUD.conf index cbef003..c942f3a 100644 --- a/ButtonHUD.conf +++ b/ButtonHUD.conf @@ -1,4 +1,4 @@ -name: ButtonsHud - Dimencia and Archaegeo v5.44 (Minified) +name: ButtonsHud - Dimencia and Archaegeo v5.441 (Minified) slots: core: class: CoreUnit @@ -385,7 +385,7 @@ handlers: Keyboard Scheme must be selected]],ConvertResolutionX(960),ConvertResolutionY(600))ct[#ct+1]=e([[ Set your preferred scheme in Lua Parameters instead]],ConvertResolutionX(960),ConvertResolutionY(650))end;local f7=ConvertResolutionX(960)local f8=ConvertResolutionY(860)local f9=ConvertResolutionY(880)local fa=ConvertResolutionY(900)local fb=ConvertResolutionY(960)local fc=ConvertResolutionY(200)local fd=ConvertResolutionY(150)local fe=ConvertResolutionY(960)if o()==1 and not RemoteHud then f8=ConvertResolutionY(135)f9=ConvertResolutionY(155)fa=ConvertResolutionY(175)fc=ConvertResolutionY(115)fd=ConvertResolutionY(95)end;if BrakeIsOn then ct[#ct+1]=e([[Brake Engaged]],f7,f8)elseif A>0 then ct[#ct+1]=e([[Auto-Brake Engaged]],f7,f8,A)end;if am and bi and hoverDetectGround()==-1 then ct[#ct+1]=e([[** STALL WARNING **]],f7,fc+50)end;if aq then ct[#ct+1]=e([[Gyro Enabled]],f7,fe)end;if GearExtended then if M then ct[#ct+1]=e([[Gear Extended]],f7,f9)else ct[#ct+1]=e([[Landed (G: Takeoff)]],f7,f9)end;local dy,dz=getDistanceDisplayString(Nav:getTargetGroundAltitude())ct[#ct+1]=e([[Hover Height: %s]],f7,fa,dy..dz)end;if Z then ct[#ct+1]=e([[ROCKET BOOST ENABLED]],f7,fb+20)end;if antigrav and not ExternalAGG and antigrav.getState()==1 and AntigravTargetAltitude~=nil then if math.abs(an-antigrav.getBaseAltitude())<501 then ct[#ct+1]=e([[AGG On - Target Altitude: %d Singluarity Altitude: %d]],f7,fc+20,d(AntigravTargetAltitude),d(antigrav.getBaseAltitude()))else ct[#ct+1]=e([[AGG On - Target Altitude: %d Singluarity Altitude: %d]],f7,fc+20,d(AntigravTargetAltitude),d(antigrav.getBaseAltitude()))end elseif Autopilot and AutopilotTargetName~="None"then ct[#ct+1]=e([[Autopilot %s]],f7,fc+20,AutopilotStatus)elseif LockPitch~=nil then ct[#ct+1]=e([[LockedPitch: %d]],f7,fc+20,d(LockPitch))elseif U then ct[#ct+1]=e([[Follow Mode Engaged]],f7,fc+20)elseif Reentry then ct[#ct+1]=e([[Re-entry in Progress]],f7,fc+20)end;local ff,fg,fh=b6:getPlanetarySystem(0):castIntersections(vec3(core.getConstructWorldPos()),bd:normalize(),function(fi)if fi.noAtmosphericDensityAltitude>0 then return fi.radius+fi.noAtmosphericDensityAltitude else return fi.radius+fi.surfaceMaxAltitude*1.5 end end)local fj=fg;if fh~=nil and fg~=nil then fj=math.min(fh,fg)end;if AltitudeHold then if AutoTakeoff and not IntoOrbit then local dy,dz=getDistanceDisplayString(HoldAltitude)ct[#ct+1]=e([[Ascent to %s]],f7,fc,dy..dz)if BrakeIsOn then ct[#ct+1]=e([[Throttle Up and Disengage Brake For Takeoff]],f7,fc+50)end else local dy,dz=getDistanceDisplayString2(HoldAltitude)ct[#ct+1]=e([[Altitude Hold: %s]],f7,fc,dy..dz)end end;if VertTakeOff and(antigrav~=nil and antigrav)then if j()>0.1 then ct[#ct+1]=e([[Beginning ascent]],f7,fc)elseif j()<0.09 and j()>0.05 then ct[#ct+1]=e([[Aligning trajectory]],f7,fc)elseif j()<0.05 then ct[#ct+1]=e([[Leaving atmosphere]],f7,fc)end end;if IntoOrbit then if bo~=nil then ct[#ct+1]=e([[%s]],f7,fc,bo)end end;if BrakeLanding then if StrongBrakes then ct[#ct+1]=e([[Brake-Landing]],f7,fc)else ct[#ct+1]=e([[Coast-Landing]],f7,fc)end end;if ProgradeIsOn then ct[#ct+1]=e([[Prograde Alignment]],f7,fc)end;if RetrogradeIsOn then ct[#ct+1]=e([[Retrograde Alignment]],f7,fc)end;if TurnBurn then ct[#ct+1]=e([[Turn & Burn Braking]],f7,fd)elseif fj~=nil and j()==0 then local dy,dz=getDistanceDisplayString(fj)local travelTime=b7.computeTravelTime(be,0,fj)local fk="Collision"if ff.noAtmosphericDensityAltitude>0 then fk="Atmosphere"end;ct[#ct+1]=e([[%s %s In %s (%s)]],f7,fd,ff.name,fk,FormatTimeString(travelTime),dy..dz)end;if VectorToTarget and not IntoOrbit then ct[#ct+1]=e([[%s]],f7,fc+30,VectorStatus)end;ct[#ct+1]=""end;function DisplayOrbitScreen(ct)if orbit~=nil and j()<0.2 and planet~=nil and orbit.apoapsis~=nil and orbit.periapsis~=nil and orbit.period~=nil and orbit.apoapsis.speed>5 and DisplayOrbit then local fl=OrbitMapX;local fm=OrbitMapY;local fn=OrbitMapSize;local fo=4;fm=fm+fo;local fp=15;local bY=fl+fn+fl/2+fo;local bZ=fm+fn/2+5+fo;local fq,fr,fs,ft;fq=fn/4;ft=0;ct[#ct+1]=[[]]ct[#ct+1]=e('',fn+fl*2,fn+fm,fo,fo)if orbit.periapsis~=nil and orbit.apoapsis~=nil then fs=(orbit.apoapsis.altitude+orbit.periapsis.altitude+planet.radius*2)/(fq*2)fr=(planet.radius+orbit.periapsis.altitude+(orbit.apoapsis.altitude-orbit.periapsis.altitude)/2)/fs*(1-orbit.eccentricity)ft=fq-orbit.periapsis.altitude/fs-planet.radius/fs;local fu=""if orbit.periapsis.altitude<=0 then fu='redout'end;ct[#ct+1]=e([[]],fu,fl+fn/2+ft+fo,fm+fn/2+fo,fq,fr)ct[#ct+1]=e('',fl+fn/2+fo,fm+fn/2+fo,planet.radius/fs)end;if orbit.apoapsis~=nil and orbit.apoapsis.speed1 then ct[#ct+1]=e([[]],bY-35,bZ-5,fl+fn/2+fq+ft,bZ-5)ct[#ct+1]=e([[Apoapsis]],bY,bZ)bZ=bZ+fp;local dy,dz=getDistanceDisplayString(orbit.apoapsis.altitude)ct[#ct+1]=e([[%s]],bY,bZ,dy..dz)bZ=bZ+fp;ct[#ct+1]=e([[%s]],bY,bZ,FormatTimeString(orbit.timeToApoapsis))bZ=bZ+fp;ct[#ct+1]=e([[%s]],bY,bZ,getSpeedDisplayString(orbit.apoapsis.speed))end;bZ=fm+fn/2+5+fo;bY=fl-fl/2+10+fo;if orbit.periapsis~=nil and orbit.periapsis.speed1 then ct[#ct+1]=e([[]],bY+35,bZ-5,fl+fn/2-fq+ft,bZ-5)ct[#ct+1]=e([[Periapsis]],bY,bZ)bZ=bZ+fp;local dy,dz=getDistanceDisplayString(orbit.periapsis.altitude)ct[#ct+1]=e([[%s]],bY,bZ,dy..dz)bZ=bZ+fp;ct[#ct+1]=e([[%s]],bY,bZ,FormatTimeString(orbit.timeToPeriapsis))bZ=bZ+fp;ct[#ct+1]=e([[%s]],bY,bZ,getSpeedDisplayString(orbit.periapsis.speed))end;ct[#ct+1]=e([[%s]],fl+fn/2+fo,20+fo,planet.name)if orbit.period~=nil and orbit.periapsis~=nil and orbit.apoapsis~=nil and orbit.apoapsis.speed>1 then local fv=orbit.timeToApoapsis/orbit.period*2*math.pi;local fw=fq*math.cos(fv)local fx=fr*math.sin(fv)ct[#ct+1]=e('',fl+fn/2+fw+ft+fo,fm+fn/2+fx+fo)end;ct[#ct+1]=[[]]end end;function getDistanceDisplayString(ac)local fy=ac>100000;local bD,dz=""if fy then bD,dz=round(ac/1000/200,1),"SU"elseif ac<1000 then bD,dz=round(ac,1),"m"else bD,dz=round(ac/1000,1),"Km"end;return bD,dz end;function getDistanceDisplayString2(ac)local fy=ac>100000;local bD,dz=""if fy then bD,dz=round(ac/1000/200,2)," SU"elseif ac<1000 then bD,dz=round(ac,2)," M"else bD,dz=round(ac/1000,2)," KM"end;return bD,dz end;function getSpeedDisplayString(bS)return d(round(bS*3.6,0)+0.5).." km/h"end;function FormatTimeString(fz)local fA=0;local fB=0;local fC=0;if fz<60 then fz=d(fz)elseif fz<3600 then fA=d(fz/60)fz=d(fz%60)elseif fz<86400 then fB=d(fz/3600)fA=d(fz%3600/60)else fC=d(fz/86400)fB=d(fz%86400/3600)end;if fC>0 then return fC.."d "..fB.."h "elseif fB>0 then return fB.."h "..fA.."m "elseif fA>0 then return fA.."m "..fz.."s"elseif fz>0 then return fz.."s"else return"0s"end end;function getMagnitudeInDirection(dr,fD)dr=vec3(dr)fD=vec3(fD):normalize()local bD=dr*fD;return bD.x+bD.y+bD.z end;function UpdateAutopilotTarget()if AutopilotTargetIndex==0 then AutopilotTargetName="None"a4=nil;CustomTarget=nil;return true end;local fE=AtlasOrdered[AutopilotTargetIndex].index;local fF=b0[0][fE]if fF.center then AutopilotTargetName=fF.name;a4=b6[0][fE]if CustomTarget~=nil then if j()==0 then if system.updateData(widgetMaxBrakeTimeText,widgetMaxBrakeTime)~=1 then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;if system.updateData(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)~=1 then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;if system.updateData(widgetCurBrakeTimeText,widgetCurBrakeTime)~=1 then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;if system.updateData(widgetCurBrakeDistanceText,widgetCurBrakeDistance)~=1 then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;if system.updateData(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)~=1 then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end end;if system.updateData(widgetMaxMassText,widgetMaxMass)~=1 then system.addDataToWidget(widgetMaxMassText,widgetMaxMass)end;if system.updateData(widgetTravelTimeText,widgetTravelTime)~=1 then system.addDataToWidget(widgetTravelTimeText,widgetTravelTime)end;if system.updateData(widgetTargetOrbitText,widgetTargetOrbit)~=1 then system.addDataToWidget(widgetTargetOrbitText,widgetTargetOrbit)end end;CustomTarget=nil else CustomTarget=fF;for _,bC in pairs(b6[0])do if bC.name==CustomTarget.planetname then a4=bC;AutopilotTargetName=CustomTarget.name;break end end;if system.updateData(widgetMaxMassText,widgetMaxMass)~=1 then system.addDataToWidget(widgetMaxMassText,widgetMaxMass)end;if system.updateData(widgetTravelTimeText,widgetTravelTime)~=1 then system.addDataToWidget(widgetTravelTimeText,widgetTravelTime)end end;if CustomTarget==nil then AutopilotTargetCoords=vec3(a4.center)else AutopilotTargetCoords=CustomTarget.position end;if a4.planetname~="Space"then if a4.hasAtmosphere then AutopilotTargetOrbit=math.floor(a4.radius*(TargetOrbitRadius-1)+a4.noAtmosphericDensityAltitude)else AutopilotTargetOrbit=math.floor(a4.radius*(TargetOrbitRadius-1)+a4.surfaceMaxAltitude)end else AutopilotTargetOrbit=1000 end;if CustomTarget~=nil and CustomTarget.planetname=="Space"then AutopilotEndSpeed=0 else _,AutopilotEndSpeed=b9(a4):escapeAndOrbitalSpeed(AutopilotTargetOrbit)end;AutopilotPlanetGravity=0;AutopilotAccelerating=false;AutopilotBraking=false;AutopilotCruising=false;Autopilot=false;AutopilotRealigned=false;AutopilotStatus="Aligning"return true end;function IncrementAutopilotTargetIndex()AutopilotTargetIndex=AutopilotTargetIndex+1;if AutopilotTargetIndex>#AtlasOrdered then AutopilotTargetIndex=0 end;if AutopilotTargetIndex==0 then UpdateAutopilotTarget()else local fE=AtlasOrdered[AutopilotTargetIndex].index;local fF=b0[0][fE]if fF.name=="Space"then IncrementAutopilotTargetIndex()else UpdateAutopilotTarget()end end end;function DecrementAutopilotTargetIndex()AutopilotTargetIndex=AutopilotTargetIndex-1;if AutopilotTargetIndex<0 then AutopilotTargetIndex=#AtlasOrdered end;if AutopilotTargetIndex==0 then UpdateAutopilotTarget()else local fE=AtlasOrdered[AutopilotTargetIndex].index;local fF=b0[0][fE]if fF.name=="Space"then DecrementAutopilotTargetIndex()else UpdateAutopilotTarget()end end end;function GetAutopilotMaxMass()local fG=LastMaxBrakeInAtmo/a4:getGravity(a4.center+vec3(0,0,1)*a4.radius):len()return fG end;function GetAutopilotTravelTime()if not Autopilot then if CustomTarget==nil or CustomTarget.planetname~=planet.name then AutopilotDistance=(a4.center-vec3(core.getConstructWorldPos())):len()else AutopilotDistance=(CustomTarget.position-vec3(core.getConstructWorldPos())):len()end end;local bd=core.getWorldVelocity()local bS=vec3(bd):len()local fH=unit.getThrottle()/100;if AtmoSpeedAssist then fH=z end;local fI,fJ=b7.computeDistanceAndTime(vec3(bd):len(),MaxGameVelocity,n(),Nav:maxForceForward()*fH,warmup,0)local a0,a1;if not TurnBurn then a0,a1=GetAutopilotBrakeDistanceAndTime(MaxGameVelocity)else a0,a1=GetAutopilotTBBrakeDistanceAndTime(MaxGameVelocity)end;local _,fK;if not TurnBurn and bS>0 then _,fK=GetAutopilotBrakeDistanceAndTime(bS)else _,fK=GetAutopilotTBBrakeDistanceAndTime(bS)end;local fL=0;local fM=0;if AutopilotCruising or not Autopilot and bS>5 then fM=b7.computeTravelTime(bS,0,AutopilotDistance)elseif a0+fI0 then return b7.computeDistanceAndTime(bS,AutopilotEndSpeed,n(),0,0,LastMaxBrakeInAtmo-AutopilotPlanetGravity*n())else return 0,0 end end end;function GetAutopilotTBBrakeDistanceAndTime(bS)RefreshLastMaxBrake()return b7.computeDistanceAndTime(bS,AutopilotEndSpeed,n(),Nav:maxForceForward(),warmup,LastMaxBrake-AutopilotPlanetGravity*n())end;function hoverDetectGround()local fO=-1;local fP=-1;if vBooster then fO=vBooster.distance()end;if hover then fP=hover.distance()end;if fO~=-1 and fP~=-1 then if fOProfileTimeMax then ProfileTimeMax=fV end;if fV0 then local g4=g1:find('identifiedConstructs":%[%]')if g4==nil and perisPanelID==nil then af=1;ToggleRadarPanel()end;if g4~=nil and perisPanelID~=nil then ToggleRadarPanel()end;if radarPanelID==nil then ToggleRadarPanel()end;ad=e([[Radar: %i contacts]],g2,g3,#g0)local g5={}for bB,bC in pairs(g0)do if radar_1.hasMatchingTransponder(bC)==1 then table.insert(g5,bC)end end;if#g5>0 then local bZ=ConvertResolutionY(15)local bY=ConvertResolutionX(1370)ad=e([[%sFriendlies In Range]],ad,bY,bZ)for bB,bC in pairs(g5)do bZ=bZ+20;ad=e([[%s%s]],ad,bY,bZ,radar_1.getConstructName(bC))end end else local g6;g6=g1:find('worksInEnvironment":false')if g6 then ad=e([[ Radar: Jammed]],g2,g3)else ad=e([[ - Radar: No Contacts]],g2,g3)end;if radarPanelID~=nil then af=0;ToggleRadarPanel()end end end end;function DisplayMessage(ct,dy)if dy~="empty"then ct[#ct+1]=[[]]for g7 in string.gmatch(dy,"([^\n]+)")do ct[#ct+1]=e([[%s]],g7)end;ct[#ct+1]=[[]]end;if ab~=0 then unit.setTimer("msgTick",ab)ab=0 end end;function updateDistance()local bL=system.getTime()local bd=vec3(core.getWorldVelocity())local dU=vec3(bd):len()local g8=bL-ap;if dU>1.38889 then dU=dU/1000;local g9=dU*(bL-ap)TotalDistanceTravelled=TotalDistanceTravelled+g9;a5=a5+g9 end;a6=a6+g8;TotalFlightTime=TotalFlightTime+g8;ap=bL end;function composeAxisAccelerationFromTargetSpeedV(ga,gb)local gc=vec3()local gd=vec3()if ga==axisCommandId.longitudinal then gc=vec3(core.getConstructOrientationForward())gd=vec3(core.getConstructWorldOrientationForward())elseif ga==axisCommandId.vertical then gc=vec3(core.getConstructOrientationUp())gd=vec3(core.getConstructWorldOrientationUp())elseif ga==axisCommandId.lateral then gc=vec3(core.getConstructOrientationRight())gd=vec3(core.getConstructWorldOrientationRight())else return vec3()end;local ge=vec3(core.getWorldGravity())local gf=ge:dot(gd)local gg=vec3(core.getWorldAirFrictionAcceleration())local gh=gg:dot(gd)local gi=vec3(core.getVelocity())local gj=gi:dot(gc)local gk=gb*constants.kph2m;if targetSpeedPID2==nil then targetSpeedPID2=pid.new(10,0,10.0)end;targetSpeedPID2:inject(gk-gj)local gl=targetSpeedPID2:get()local gm=(gl-gh-gf)*gd;return gm end;function composeAxisAccelerationFromTargetSpeed(ga,gb)local gc=vec3()local gd=vec3()if ga==axisCommandId.longitudinal then gc=vec3(core.getConstructOrientationForward())gd=vec3(core.getConstructWorldOrientationForward())elseif ga==axisCommandId.vertical then gc=vec3(core.getConstructOrientationUp())gd=vec3(core.getConstructWorldOrientationUp())elseif ga==axisCommandId.lateral then gc=vec3(core.getConstructOrientationRight())gd=vec3(core.getConstructWorldOrientationRight())else return vec3()end;local ge=vec3(core.getWorldGravity())local gf=ge:dot(gd)local gg=vec3(core.getWorldAirFrictionAcceleration())local gh=gg:dot(gd)local gi=vec3(core.getVelocity())local gj=gi:dot(gc)local gk=gb*constants.kph2m;if targetSpeedPID==nil then targetSpeedPID=pid.new(10,0,10.0)end;targetSpeedPID:inject(gk-gj)local gl=targetSpeedPID:get()local gm=(gl-gh-gf)*gd;return gm end;function Atlas()return{[0]={[0]={GM=0,bodyId=0,center={x=0,y=0,z=0},name='Space',planetarySystemId=0,radius=0,hasAtmosphere=false,gravity=0,noAtmosphericDensityAltitude=0,surfaceMaxAltitude=0},[2]={name="Alioth",description="Alioth is the planet selected by the arkship for landfall; it is a typical goldilocks planet where humanity may rebuild in the coming decades. The arkship geological survey reports mountainous regions alongside deep seas and lush forests. This is where it all starts.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9401,atmosphericEngineMaxAltitude=5580,biosphere="Forest",classification="Mesoplanet",bodyId=2,GM=157470826617,gravity=1.0082568597356114,fullAtmosphericDensityMaxAltitude=-10,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=6272,numSatellites=2,positionFromSun=2,center={x=-8,y=-8,z=-126303},radius=126067.8984375,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=3410,surfaceArea=199718780928,surfaceAverageAltitude=200,surfaceMaxAltitude=1100,surfaceMinAltitude=-330,systemZone="High",territories=259472,type="Planet",waterLevel=0,planetarySystemId=0},[21]={name="Alioth Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=21,GM=2118960000,gravity=0.24006116402380084,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=457933,y=-1509011,z=115524},radius=30000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=11309733888,surfaceAverageAltitude=140,surfaceMaxAltitude=200,surfaceMinAltitude=10,systemZone=nil,territories=14522,type="",waterLevel=nil,planetarySystemId=0},[22]={name="Alioth Moon 4",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=22,GM=2165833514,gravity=0.2427018259886451,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-1692694,y=729681,z=-411464},radius=30330,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=0,surfaceArea=11559916544,surfaceAverageAltitude=-15,surfaceMaxAltitude=-5,surfaceMinAltitude=-50,systemZone=nil,territories=14522,type="",waterLevel=nil,planetarySystemId=0},[5]={name="Feli",description="Feli is easily identified by its massive and deep crater. Outside of the crater, the arkship geological survey reports a fairly bland and uniform planet, it also cannot explain the existence of the crater. Feli is particular for having an extremely small atmosphere, allowing life to develop in the deeper areas of its crater but limiting it drastically on the actual surface.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.5488,atmosphericEngineMaxAltitude=66725,biosphere="Barren",classification="Mesoplanet",bodyId=5,GM=16951680000,gravity=0.4801223280476017,fullAtmosphericDensityMaxAltitude=30,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=78500,numSatellites=1,positionFromSun=5,center={x=-43534464,y=22565536,z=-48934464},radius=41800,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=42800,surfaceArea=21956466688,surfaceAverageAltitude=18300,surfaceMaxAltitude=18500,surfaceMinAltitude=46,systemZone="Low",territories=27002,type="Planet",waterLevel=nil,planetarySystemId=0},[50]={name="Feli Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=50,GM=499917600,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-43902841.78,y=22261034.7,z=-48862386},radius=14000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=800,surfaceMaxAltitude=900,surfaceMinAltitude=0,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[120]={name="Ion",description="Ion is nothing more than an oversized ice cube frozen through and through. It is a largely inhospitable planet due to its extremely low temperatures. The arkship geological survey reports extremely rough mountainous terrain with little habitable land.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9522,atmosphericEngineMaxAltitude=10480,biosphere="Ice",classification="Hypopsychroplanet",bodyId=120,GM=7135606629,gravity=0.36009174603570127,fullAtmosphericDensityMaxAltitude=-30,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=17700,numSatellites=2,positionFromSun=12,center={x=2865536.7,y=-99034464,z=-934462.02},radius=44950,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=6410,surfaceArea=25390383104,surfaceAverageAltitude=500,surfaceMaxAltitude=1300,surfaceMinAltitude=250,systemZone="Average",territories=32672,type="Planet",waterLevel=nil,planetarySystemId=0},[121]={name="Ion Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=121,GM=106830900,gravity=0.08802242599860607,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=2472916.8,y=-99133747,z=-1133582.8},radius=11000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=1520530944,surfaceAverageAltitude=100,surfaceMaxAltitude=200,surfaceMinAltitude=3,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[122]={name="Ion Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=122,GM=176580000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=2995424.5,y=-99275010,z=-1378480.7},radius=15000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=-1900,surfaceMaxAltitude=-1400,surfaceMinAltitude=-2100,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[9]={name="Jago",description="Jago is a water planet. The large majority of the planet's surface is covered by large oceans dotted by small areas of landmass across the planet. The arkship geological survey reports deep seas across the majority of the planet with sub 15 percent coverage of solid ground.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9835,atmosphericEngineMaxAltitude=9695,biosphere="Water",classification="Mesoplanet",bodyId=9,GM=18606274330,gravity=0.5041284298678057,fullAtmosphericDensityMaxAltitude=-90,habitability="Very High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=10900,numSatellites=0,positionFromSun=9,center={x=-94134462,y=12765534,z=-3634464},radius=61590,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=5900,surfaceArea=47668367360,surfaceAverageAltitude=0,surfaceMaxAltitude=1200,surfaceMinAltitude=-500,systemZone="Very High",territories=60752,type="Planet",waterLevel=0,planetarySystemId=0},[100]={name="Lacobus",description="Lacobus is an ice planet that also features large bodies of water. The arkship geological survey reports deep oceans alongside a frozen and rough mountainous environment. Lacobus seems to feature regional geothermal activity allowing for the presence of water on the surface.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.7571,atmosphericEngineMaxAltitude=11120,biosphere="Ice",classification="Psychroplanet",bodyId=100,GM=13975172474,gravity=0.45611622622739767,fullAtmosphericDensityMaxAltitude=-20,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=12510,numSatellites=3,positionFromSun=10,center={x=98865536,y=-13534464,z=-934461.99},radius=55650,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=6790,surfaceArea=38917074944,surfaceAverageAltitude=800,surfaceMaxAltitude=1660,surfaceMinAltitude=250,systemZone="Average",territories=50432,type="Planet",waterLevel=0,planetarySystemId=0},[102]={name="Lacobus Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=102,GM=444981600,gravity=0.14403669598391783,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=99180968,y=-13783862,z=-926156.4},radius=18000,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=0,surfaceArea=4071504128,surfaceAverageAltitude=150,surfaceMaxAltitude=300,surfaceMinAltitude=10,systemZone=nil,territories=5072,type="",waterLevel=nil,planetarySystemId=0},[103]={name="Lacobus Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=103,GM=211503600,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=99250052,y=-13629215,z=-1059341.4},radius=14000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=-1380,surfaceMaxAltitude=-1280,surfaceMinAltitude=-1880,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[101]={name="Lacobus Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=101,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=98905288.17,y=-13950921.1,z=-647589.53},radius=15000,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=500,surfaceMaxAltitude=820,surfaceMinAltitude=3,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[1]={name="Madis",description="Madis is a barren wasteland of a rock; it sits closest to the sun and temperatures reach extreme highs during the day. The arkship geological survey reports long rocky valleys intermittently separated by small ravines.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.8629,atmosphericEngineMaxAltitude=7165,biosphere="Barren",classification="hyperthermoplanet",bodyId=1,GM=6930729684,gravity=0.36009174603570127,fullAtmosphericDensityMaxAltitude=220,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=8050,numSatellites=3,positionFromSun=1,center={x=17465536,y=22665536,z=-34464},radius=44300,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=4480,surfaceArea=24661377024,surfaceAverageAltitude=750,surfaceMaxAltitude=850,surfaceMinAltitude=670,systemZone="Low",territories=30722,type="Planet",waterLevel=nil,planetarySystemId=0},[10]={name="Madis Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=10,GM=78480000,gravity=0.08002039003323584,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17448118.224,y=22966846.286,z=143078.82},radius=10000,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=0,surfaceArea=1256637056,surfaceAverageAltitude=210,surfaceMaxAltitude=420,surfaceMinAltitude=0,systemZone=nil,territories=1472,type="",waterLevel=nil,planetarySystemId=0},[11]={name="Madis Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=11,GM=237402000,gravity=0.09602446196397631,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17194626,y=22243633.88,z=-214962.81},radius=12000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=1809557376,surfaceAverageAltitude=-700,surfaceMaxAltitude=300,surfaceMinAltitude=-2900,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[12]={name="Madis Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=12,GM=265046609,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17520614,y=22184730,z=-309989.99},radius=15000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=700,surfaceMaxAltitude=1100,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[26]={name="Sanctuary",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9666,atmosphericEngineMaxAltitude=6935,biosphere="",classification="",bodyId=26,GM=68234043600,gravity=1.0000000427743831,fullAtmosphericDensityMaxAltitude=-30,habitability="",hasAtmosphere=true,isSanctuary=true,noAtmosphericDensityAltitude=7800,numSatellites=0,positionFromSun=0,center={x=-1404835,y=562655,z=-285074},radius=83400,safeAreaEdgeAltitude=0,size="L",spaceEngineMinAltitude=4230,surfaceArea=87406149632,surfaceAverageAltitude=80,surfaceMaxAltitude=500,surfaceMinAltitude=-60,systemZone=nil,territories=111632,type="",waterLevel=0,planetarySystemId=0},[6]={name="Sicari",description="Sicari is a typical desert planet; it has survived for millenniums and will continue to endure. While not the most habitable of environments it remains a relatively untouched and livable planet of the Alioth sector. The arkship geological survey reports large flatlands alongside steep plateaus.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.897,atmosphericEngineMaxAltitude=7725,biosphere="Desert",classification="Mesoplanet",bodyId=6,GM=10502547741,gravity=0.4081039739797361,fullAtmosphericDensityMaxAltitude=-625,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=8770,numSatellites=0,positionFromSun=6,center={x=52765536,y=27165538,z=52065535},radius=51100,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=4480,surfaceArea=32813432832,surfaceAverageAltitude=130,surfaceMaxAltitude=220,surfaceMinAltitude=50,systemZone="Average",territories=41072,type="Planet",waterLevel=nil,planetarySystemId=0},[7]={name="Sinnen",description="Sinnen is a an empty and rocky hell. With no atmosphere to speak of it is one of the least hospitable planets in the sector. The arkship geological survey reports mostly flatlands alongside deep ravines which look to have once been riverbeds. This planet simply looks to have dried up and died, likely from solar winds.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9226,atmosphericEngineMaxAltitude=10335,biosphere="Desert",classification="Mesoplanet",bodyId=7,GM=13033380591,gravity=0.4401121421448438,fullAtmosphericDensityMaxAltitude=-120,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=11620,numSatellites=1,positionFromSun=7,center={x=58665538,y=29665535,z=58165535},radius=54950,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=6270,surfaceArea=37944188928,surfaceAverageAltitude=317,surfaceMaxAltitude=360,surfaceMinAltitude=23,systemZone="Average",territories=48002,type="Planet",waterLevel=nil,planetarySystemId=0},[70]={name="Sinnen Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=70,GM=396912600,gravity=0.1360346539426409,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=58969616,y=29797945,z=57969449},radius=17000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=3631681280,surfaceAverageAltitude=-2050,surfaceMaxAltitude=-1950,surfaceMinAltitude=-2150,systemZone=nil,territories=4322,type="",waterLevel=nil,planetarySystemId=0},[110]={name="Symeon",description="Symeon is an ice planet mysteriously split at the equator by a band of solid desert. Exactly how this phenomenon is possible is unclear but some sort of weather anomaly may be responsible. The arkship geological survey reports a fairly diverse mix of flat-lands alongside mountainous formations.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9559,atmosphericEngineMaxAltitude=6920,biosphere="Ice, Desert",classification="Hybrid",bodyId=110,GM=9204742375,gravity=0.3920998898971822,fullAtmosphericDensityMaxAltitude=-30,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=7800,numSatellites=0,positionFromSun=11,center={x=14165536,y=-85634465,z=-934464.3},radius=49050,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=4230,surfaceArea=30233462784,surfaceAverageAltitude=39,surfaceMaxAltitude=450,surfaceMinAltitude=126,systemZone="High",territories=38882,type="Planet",waterLevel=nil,planetarySystemId=0},[4]={name="Talemai",description="Talemai is a planet in the final stages of an Ice Age. It seems likely that the planet was thrown into tumult by a cataclysmic volcanic event which resulted in its current state. The arkship geological survey reports large mountainous regions across the entire planet.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.8776,atmosphericEngineMaxAltitude=9685,biosphere="Barren",classification="Psychroplanet",bodyId=4,GM=14893847582,gravity=0.4641182439650478,fullAtmosphericDensityMaxAltitude=-78,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=10890,numSatellites=3,positionFromSun=4,center={x=-13234464,y=55765536,z=465536},radius=57500,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=5890,surfaceArea=41547563008,surfaceAverageAltitude=580,surfaceMaxAltitude=610,surfaceMinAltitude=520,systemZone="Average",territories=52922,type="Planet",waterLevel=nil,planetarySystemId=0},[42]={name="Talemai Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=42,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-13058408,y=55781856,z=740177.76},radius=15000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=720,surfaceMaxAltitude=850,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[40]={name="Talemai Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=40,GM=141264000,gravity=0.09602446196397631,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-13503090,y=55594325,z=769838.64},radius=12000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=1809557376,surfaceAverageAltitude=250,surfaceMaxAltitude=450,surfaceMinAltitude=0,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[41]={name="Talemai Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=41,GM=106830900,gravity=0.08802242599860607,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-12800515,y=55700259,z=325207.84},radius=11000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=1520530944,surfaceAverageAltitude=190,surfaceMaxAltitude=400,surfaceMinAltitude=0,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[8]={name="Teoma",description="[REDACTED] The arkship geological survey [REDACTED]. This planet should not be here.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.7834,atmosphericEngineMaxAltitude=5580,biosphere="Forest",classification="Mesoplanet",bodyId=8,GM=18477723600,gravity=0.48812434578525177,fullAtmosphericDensityMaxAltitude=15,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=6280,numSatellites=0,positionFromSun=8,center={x=80865538,y=54665536,z=-934463.94},radius=62000,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=3420,surfaceArea=48305131520,surfaceAverageAltitude=700,surfaceMaxAltitude=1100,surfaceMinAltitude=-200,systemZone="High",territories=60752,type="Planet",waterLevel=0,planetarySystemId=0},[3]={name="Thades",description="Thades is a scorched desert planet. Perhaps it was once teaming with life but now all that remains is ash and dust. The arkship geological survey reports a rocky mountainous planet bisected by a massive unnatural ravine; something happened to this planet.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.03552,atmosphericEngineMaxAltitude=32180,biosphere="Desert",classification="Thermoplanet",bodyId=3,GM=11776905000,gravity=0.49612641213015557,fullAtmosphericDensityMaxAltitude=150,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=32800,numSatellites=2,positionFromSun=3,center={x=29165536,y=10865536,z=65536},radius=49000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=21400,surfaceArea=30171856896,surfaceAverageAltitude=13640,surfaceMaxAltitude=13690,surfaceMinAltitude=370,systemZone="Low",territories=38882,type="Planet",waterLevel=nil,planetarySystemId=0},[30]={name="Thades Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=30,GM=211564034,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=29214402,y=10907080.695,z=433858.2},radius=14000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=60,surfaceMaxAltitude=300,surfaceMinAltitude=0,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[31]={name="Thades Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=31,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=29404193,y=10432768,z=19554.131},radius=15000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=70,surfaceMaxAltitude=350,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0}}}end;function SetupAtlas()b0=Atlas()for bB,bC in pairs(b0[0])do if aE==nil or bC.center.xaF then aF=bC.center.x end;if aG==nil or bC.center.yaH then aH=bC.center.y end end;b1=""local gn=1.1*(aF-aE)/1920;local go=1.4*(aH-aG)/1080;for bB,bC in pairs(b0[0])do local bY=960+bC.center.x/gn;local bZ=540+bC.center.y/go;b1=b1 ..''if not string.match(bC.name,"Moon")and not string.match(bC.name,"Sanctuary")and not string.match(bC.name,"Space")then b1=b1 ..""..bC.name..""end end;local cg=vec3(core.getConstructWorldPos())local bY=960+cg.x/gn;local bZ=540+cg.y/go;b1=b1 ..''b1=b1 .."You Are Here"b1=b1 ..[[]]b2=gn;b3=go;if screen_2 then screen_2.setHTML(''..b1)local cg=vec3(core.getConstructWorldPos())local bY=960+cg.x/gn;local bZ=540+cg.y/go;b1=''b1=b1 .."You Are Here"b4=screen_2.addContent((bY-80)/19.20,(bZ-80)/10.80,b1)end end;function PlanetRef()local function gp(gq)return type(gq)=='number'end;local function gr(gq)return type(tonumber(gq))=='number'end;local function gs(gt)return type(gt)=='table'end;local function gu(gv)return type(gv)=='string'end;local function gw(bC)return gs(bC)and gp(bC.x and bC.y and bC.z)end;local function gx(gy)return gs(gy)and gp(gy.latitude and gy.longitude and gy.altitude and gy.bodyId and gy.systemId)end;local gz=math.pi/180;local gA=180/math.pi;local epsilon=1e-10;local q=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local ch='::pos{'..q..','..q..','..q..','..q..','..q..'}'local utils=require('cpml.utils')local vec3=require('cpml.vec3')local gB=utils.clamp;local function float_eq(c6,c7)if c6==0 then return math.abs(c7)<1e-09 end;if c7==0 then return math.abs(c6)<1e-09 end;return math.abs(c6-c7)=0 then local hp=math.sqrt(ho)local fg=hn+hp;local fh=hn-hp;if fh>0 then return fi,fg,fh elseif fg>0 then return fi,fg,nil end end end;return nil,nil,nil end;function gS:closestBody(hq)assert(type(hq)=='table','Invalid coordinates.')local hr,fi;local hs=vec3(hq)for _,ht in pairs(self)do local hu=(ht.center-hs):len2()if(not fi or hu=0 and cf or 2*math.pi+cf;cd=math.pi/2-math.acos(cb.z/ac)end;return setmetatable({latitude=cd,longitude=ce,altitude=cc,bodyId=self.bodyId,systemId=self.planetarySystemId},MapPosition)end;function gH:convertToWorldCoordinates(gR)local hv=gu(gR)and gQ(gR)or gR;if hv.bodyId==0 then return vec3(hv.latitude,hv.longitude,hv.altitude)end;assert(gx(hv),'Argument 1 (mapPosition) is not an instance of "MapPosition".')assert(hv.systemId==self.planetarySystemId,'Argument 1 (mapPosition) has a different planetary system ID.')assert(hv.bodyId==self.bodyId,'Argument 1 (mapPosition) has a different planetary body ID.')local ck=math.cos(hv.latitude)return self.center+(self.radius+hv.altitude)*vec3(ck*math.cos(hv.longitude),ck*math.sin(hv.longitude),math.sin(hv.latitude))end;function gH:getAltitude(c9)return(vec3(c9)-self.center):len()-self.radius end;function gH:getDistance(c9)return(vec3(c9)-self.center):len()end;function gH:getGravity(c9)local hw=self.center-vec3(c9)local hx=hw:len2()return self.GM/hx*hw/math.sqrt(hx)end;return setmetatable(b5,{__call=function(_,...)return g_(...)end})end;function Keplers()local vec3=require('cpml.vec3')local PlanetRef=PlanetRef()local function gu(gv)return type(gv)=='string'end;local function gs(gt)return type(gt)=='table'end;local function float_eq(c6,c7)if c6==0 then return math.abs(c7)<1e-09 end;if c7==0 then return math.abs(c6)<1e-09 end;return math.abs(c6-c7)0 then hO=hN;hP=hO+hI/2 end;if hP>hI then hP=hP-hI end end;return{periapsis={position=hF,speed=hH/hD,circularOrbitSpeed=math.sqrt(hA/hD),altitude=hD-self.body.radius},apoapsis=hG and{position=hG,speed=hH/hE,circularOrbitSpeed=math.sqrt(hA/hE),altitude=hE-self.body.radius},currentVelocity=bC,currentPosition=cg,eccentricity=hC,period=hI,eccentricAnomaly=hK,meanAnomaly=hM,timeToPeriapsis=hO,timeToApoapsis=hP}end;local function hQ(hR)local ht=PlanetRef.BodyParameters(hR.planetarySystemId,hR.bodyId,hR.radius,hR.center,hR.GM)return setmetatable({body=ht},Kepler)end;return setmetatable(Kepler,{__call=function(_,...)return hQ(...)end})end;function Kinematics()local b7={}local hS=30000000/3600;local hT=hS*hS;local hU=100;local function hV(bC)return 1/math.sqrt(1-bC*bC/hT)end;function b7.computeAccelerationTime(hW,hX,hY)local hZ=hS*math.asin(hW/hS)return(hS*math.asin(hY/hS)-hZ)/hX end;function b7.computeDistanceAndTime(hW,hY,h_,i0,i1,i2)i1=i1 or 0;i2=i2 or 0;local i3=hW<=hY;local i4=i0*(i3 and 1 or-1)/h_;local i5=-i2/h_;local i6=i4+i5;if i3 and i6<=0 or not i3 and i6>=0 then return-1,-1 end;local i7,i8=0,0;if i4~=0 and i1>0 then local hZ=math.asin(hW/hS)local i9=math.pi*(i4/2+i5)local ia=i4*i1;local ib=hS*math.pi;local bC=function(gt)local cV=(i9*gt-ia*math.sin(math.pi*gt/2/i1)+ib*hZ)/ib;local ic=math.tan(cV)return hS*ic/math.sqrt(ic*ic+1)end;local id=i3 and function(gv)return gv>=hY end or function(gv)return gv<=hY end;i8=2*i1;if id(bC(i8))then local ie=0;while math.abs(i8-ie)>0.5 do local gt=(i8+ie)/2;if id(bC(gt))then i8=gt else ie=gt end end end;local ig=hW;local ih=i8/hU;for ii=1,hU do local bS=bC(ii*ih)i7=i7+(bS+ig)*ih/2;ig=bS end;if i8<2*i1 then return i7,i8 end;hW=ig end;local hZ=hS*math.asin(hW/hS)local bE=(hS*math.asin(hY/hS)-hZ)/i6;local ij=hT*math.cos(hZ/hS)/i6;local ac=ij-hT*math.cos((i6*bE+hZ)/hS)/i6;return ac+i7,bE+i8 end;function b7.computeTravelTime(hW,hX,ac)if ac==0 then return 0 end;if hX>0 then local hZ=hS*math.asin(hW/hS)local ij=hT*math.cos(hZ/hS)/hX;return(hS*math.acos(hX*(ij-ac)/hT)-hZ)/hX end;if hW==0 then return-1 end;assert(hW>0,'Acceleration and initial speed are both zero.')return ac/hW end;function b7.lorentz(bC)return hV(bC)end;return b7 end;function safeZone(ik)local gN=500000;local il,im,io=math.huge;local ip=false;local iq=vec3({13771471,7435803,-128971})local ir=18000000;il=vec3(ik):dist(iq)if il0 or bN==0 and an<10000)then for _,bC in pairs(door)do bC.toggle()end end;if switch then for _,bC in pairs(switch)do bC.toggle()end end;if forcefield and(bN>0 or bN==0 and an<10000)then for _,bC in pairs(forcefield)do bC.toggle()end end;SaveDataBank()if button then button.activate()end end;local function it(ee,iu)if iu==nil then iu=false end;if Nav.axisCommandManager:getAxisCommandType(0)~=axisCommandType.byThrottle and not iu then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,ee)end;local function iv(ee,iu)if iu==nil then iu=false end;if Nav.axisCommandManager:getAxisCommandType(0)~=axisCommandType.byTargetSpeed and not iu then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setTargetSpeedCommand(axisCommandId.longitudinal,ee)end;function script.onTick(iw)if iw=="tenthSecond"then if j()>0 and not WasInAtmo then if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and AtmoSpeedAssist and(AltitudeHold or Reentry)then z=1;Nav.control.cancelCurrentControlMasterMode()D=false end end;if AutopilotTargetName~="None"then if panelInterplanetary==nil then SetupInterplanetaryPanel()end;if AutopilotTargetName~=nil then local ix=CustomTarget~=nil;planetMaxMass=GetAutopilotMaxMass()system.updateData(interplanetaryHeaderText,'{"label": "Target", "value": "'..AutopilotTargetName..'", "unit":""}')travelTime=GetAutopilotTravelTime()if ix and not Autopilot then ac=(vec3(core.getConstructWorldPos())-CustomTarget.position):len()else ac=(AutopilotTargetCoords-vec3(core.getConstructWorldPos())):len()end;if not TurnBurn then a0,a1=GetAutopilotBrakeDistanceAndTime(be)a2,a3=GetAutopilotBrakeDistanceAndTime(MaxGameVelocity)else a0,a1=GetAutopilotTBBrakeDistanceAndTime(be)a2,a3=GetAutopilotTBBrakeDistanceAndTime(MaxGameVelocity)end;local dy,dz=getDistanceDisplayString(ac)system.updateData(widgetDistanceText,'{"label": "distance", "value": "'..dy..'", "unit":"'..dz..'"}')system.updateData(widgetTravelTimeText,'{"label": "Travel Time", "value": "'..FormatTimeString(travelTime)..'", "unit":""}')dy,dz=getDistanceDisplayString(a0)system.updateData(widgetCurBrakeDistanceText,'{"label": "Cur Brake distance", "value": "'..dy..'", "unit":"'..dz..'"}')system.updateData(widgetCurBrakeTimeText,'{"label": "Cur Brake Time", "value": "'..FormatTimeString(a1)..'", "unit":""}')dy,dz=getDistanceDisplayString(a2)system.updateData(widgetMaxBrakeDistanceText,'{"label": "Max Brake distance", "value": "'..dy..'", "unit":"'..dz..'"}')system.updateData(widgetMaxBrakeTimeText,'{"label": "Max Brake Time", "value": "'..FormatTimeString(a3)..'", "unit":""}')system.updateData(widgetMaxMassText,'{"label": "Maximum Mass", "value": "'..e("%.2f",planetMaxMass/1000)..'", "unit":" Tons"}')dy,dz=getDistanceDisplayString(AutopilotTargetOrbit)system.updateData(widgetTargetOrbitText,'{"label": "Target Orbit", "value": "'..e("%.2f",dy)..'", "unit":"'..dz..'"}')if j()>0 and not WasInAtmo then system.removeDataFromWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)system.removeDataFromWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)system.removeDataFromWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)system.removeDataFromWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)system.removeDataFromWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)WasInAtmo=true end;if j()==0 and WasInAtmo then if system.updateData(widgetMaxBrakeTimeText,widgetMaxBrakeTime)==1 then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;if system.updateData(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)==1 then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;if system.updateData(widgetCurBrakeTimeText,widgetCurBrakeTime)==1 then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;if system.updateData(widgetCurBrakeDistanceText,widgetCurBrakeDistance)==1 then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;if system.updateData(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)==1 then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end;WasInAtmo=false end end else HideInterplanetaryPanel()end;if warpdrive~=nil then if f(warpdrive.getData()).destination~="Unknown"and f(warpdrive.getData()).distance>400000 then warpdrive.show()showWarpWidget=true else warpdrive.hide()showWarpWidget=false end end elseif iw=="oneSecond"then ak=false;RefreshLastMaxBrake(nil,true)updateDistance()updateRadar()updateWeapons()local ct={}local dK=GetFlightStyle()DrawOdometer(ct,a5,TotalDistanceTravelled,dK,a6)if ShouldCheckDamage then CheckDamage(ct)end;ae=table.concat(ct,"")collectgarbage("collect")elseif iw=="fiveSecond"then al=dbHud_1.getStringValue("SPBAutopilotTargetName")if al~=nil and al~=""and al~="SatNavNotChanged"then local bD=json.decode(dbHud_1.getStringValue("SavedLocations"))if bD~=nil then _G["SavedLocations"]=bD;local cr=-1;local cn;for bB,bC in pairs(SavedLocations)do if bC.name and bC.name=="SatNav Location"then cr=bB;break end end;if cr~=-1 then cn=SavedLocations[cr]cr=-1;for bB,bC in pairs(b0[0])do if bC.name and bC.name=="SatNav Location"then cr=bB;break end end;if cr>-1 then b0[0][cr]=cn end;UpdateAtlasLocationsList()W=cn.name.." position updated"end end;for i=1,#AtlasOrdered do if AtlasOrdered[i].name==al then AutopilotTargetIndex=i;system.print("Index = "..AutopilotTargetIndex.." "..AtlasOrdered[i].name)UpdateAutopilotTarget()dbHud_1.setStringValue("SPBAutopilotTargetName","SatNavNotChanged")break end end end elseif iw=="msgTick"then local ct={}DisplayMessage(ct,"empty")W="empty"unit.stopTimer("msgTick")ab=3 elseif iw=="animateTick"then bb=true;ba=false;a9=0;aa=0;unit.stopTimer("animateTick")elseif iw=="hudTick"then local ct={}HUDPrologue(ct)if showHud then UpdateHud(ct)else DisplayOrbitScreen(ct)DrawWarnings(ct)end;HUDEpilogue(ct)ct[#ct+1]=e([[]],ResolutionX,ResolutionY)if W~="empty"then DisplayMessage(ct,W)end;if o()==0 and userControlScheme=="virtual joystick"then if DisplayDeadZone then DrawDeadZone(ct)end end;if o()==1 and screen_1 and screen_1.getMouseY()~=-1 then SetButtonContains()DrawButtons(ct)if screen_1.getMouseState()==1 then CheckButtons()end;ct[#ct+1]=e([[]],E,F,a9,aa)elseif system.isViewLocked()==0 then if o()==1 and V then SetButtonContains()DrawButtons(ct)if not ba and not bb then local iy=table.concat(ct,"")ct={}ct[#ct+1]=e("",ResolutionX,ResolutionY)ct[#ct+1]=b1;ct[#ct+1]=iy;ct[#ct+1]=""ba=true;ct[#ct+1]=[[]]unit.setTimer("animateTick",0.5)local content=table.concat(ct,"")system.setScreen(content)elseif bb then local iy=table.concat(ct,"")ct={}ct[#ct+1]=e("",ResolutionX,ResolutionY)ct[#ct+1]=b1;ct[#ct+1]=iy;ct[#ct+1]=""end;if not ba then ct[#ct+1]=e([[]],E,F,a9,aa)end else CheckButtons()end else if not V and o()==0 then CheckButtons()if ac>DeadZone then if DisplayDeadZone then DrawCursorLine(ct)end end else SetButtonContains()DrawButtons(ct)end;ct[#ct+1]=e([[]],E,F,a9,aa)end;ct[#ct+1]=[[]]content=table.concat(ct,"")if not DidLogOutput then system.logInfo(LastContent)DidLogOutput=true end elseif iw=="apTick"then am=j()>0;local bE=system.getTime()local iz=bE-bj;bj=bE;local cw=vec3(core.getConstructWorldOrientationForward())local cx=vec3(core.getConstructWorldOrientationRight())local iA=vec3(core.getConstructWorldOrientationUp())local cy=vec3(core.getWorldVertical())local iB=vec3(core.getConstructWorldPos())local dM=getRoll(cy,cw,cx)local dN=dM/180*math.pi;local dO=math.cos(dN)local dP=math.sin(dN)local cz=getPitch(cy,cw,cx)local iC=getPitch(cy,cw,cx*dO+iA*dP)local iD=-math.deg(cQ(iA,bd,cw))local iE=math.deg(cQ(cx,bd,cw))bi=am and iD<-YawStallAngle or iD>YawStallAngle or iE<-PitchStallAngle or iE>PitchStallAngle;bg=system.getMouseDeltaX()bh=system.getMouseDeltaY()if InvertMouse and not V then bh=-bh end;P=0;T=0;O=0;bd=vec3(core.getWorldVelocity())be=vec3(bd):len()sys=b6[0]planet=sys:closestBody(core.getConstructWorldPos())kepPlanet=b9(planet)orbit=kepPlanet:orbitalParameters(core.getConstructWorldPos(),bd)aj=hoverDetectGround()local bP=planet:getGravity(core.getConstructWorldPos()):len()*n()bk=0;b8=core.getMaxKinematicsParametersAlongAxis("ground",core.getConstructOrientationUp())[1]w,x,y,_=safeZone(iB)if o()==1 and screen_1 and screen_1.getMouseY()~=-1 then a9=screen_1.getMouseX()*ResolutionX;aa=screen_1.getMouseY()*ResolutionY elseif system.isViewLocked()==0 then if o()==1 and V then if not ba then a9=a9+bg;aa=aa+bh end else a9=0;aa=0 end else a9=a9+bg;aa=aa+bh;ac=math.sqrt(a9*a9+aa*aa)if not V and o()==0 then if userControlScheme=="virtual joystick"then if a9>0 and a9>DeadZone then P=P-(a9-DeadZone)*MouseXSensitivity elseif a9<0 and a90 and aa>DeadZone then O=O-(aa-DeadZone)*MouseYSensitivity elseif aa<0 and aa8334;if be>SpaceSpeedLimit/3.6 and not am and not Autopilot and not iF then W="Space Speed Engine Shutoff reached"if Nav.axisCommandManager:getAxisCommandType(0)==1 then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)z=0 end;if not iF and LastIsWarping then if not BrakeIsOn then BrakeToggle()end;if Autopilot then ToggleAutopilot()end end;LastIsWarping=iF;if am and j()>0.09 then if be>bm/3.6 and not AtmoSpeedAssist and not ar then BrakeIsOn=true;ar=true elseif not AtmoSpeedAssist and ar then if be85)and be>=bm/3.6-1 then BrakeIsOn=false;ProgradeIsOn=false;J=true;ag=false;ai=true;Autopilot=false;BeginReentry()else iv(math.floor(bm))z=0 end elseif be>I then AlignToWorldVector(vec3(bd),0.01)end end;if RetrogradeIsOn then if am then RetrogradeIsOn=false elseif be>I then AlignToWorldVector(-vec3(bd))end end;if not ProgradeIsOn and ag then if j()==0 then J=true;BeginReentry()ag=false;ai=true else ag=false;ToggleAutopilot()end end;local ei=vec3(core.getWorldVertical())*-1;local eg=bd.x*ei.x+bd.y*ei.y+bd.z*ei.z;if ai and CustomTarget~=nil and(anHoldAltitude-200)and be*3.6>bm-100 and math.abs(eg)<20 and j()>=0.1 and(CustomTarget.position-iB):len()>2000+an then ToggleAutopilot()ai=false end;if VertTakeOff then bc=true;if eg<-30 then W="Unable to achieve lift. Safety Landing."a8=0;bc=autoRollPreference;VertTakeOff=false;BrakeLanding=true elseif antigrav and not ExternalAGG and antigrav.getState()==1 then if an0 then BrakeIsOn=true;a8=0 elseif eg<-30 then BrakeIsOn=true;a8=15 elseif an>=antigrav.getBaseAltitude()then BrakeIsOn=true;a8=0;VertTakeOff=false;W="Takeoff complete. Singularity engaged"end else if j()>0.08 then bn=0;BrakeIsOn=false;a8=20 elseif j()<0.08 and j()>0 then BrakeIsOn=false;if bz then bn=0;a8=20 else a8=0;bn=36;iv(3500)end else bc=autoRollPreference;IntoOrbit=true;bx=false;CancelIntoOrbit=false;br=false;bp=nil;bq=nil;if bw==nil then bw=planet end;VertTakeOff=false end end;if bn~=nil then if vTpitchPID==nil then vTpitchPID=pid.new(2*0.01,0,2*0.1)end;local iH=utils.clamp(bn-iC,-PitchStallAngle*0.85,PitchStallAngle*0.85)vTpitchPID:inject(iH)local iI=utils.clamp(vTpitchPID:get(),-1,1)O=iI end end;if IntoOrbit then if bw==nil then if VectorToTarget then bw=a4 else bw=planet end end;if not bu then if bw.hasAtmosphere then bv=math.floor(bw.radius*(TargetOrbitRadius-1)+bw.noAtmosphericDensityAltitude)else bv=math.floor(bw.radius*(TargetOrbitRadius-1)+bw.surfaceMaxAltitude)end;bu=true end;if AltitudeHold or VectorToTarget then if not ah then bv=HoldAltitude;br=true;AltitudeHold=false end;if VectorToTarget then bt.VectorToTarget=VectorToTarget;VectorToTarget=false end end;local iJ,iK=b9(bw):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-bw.center):len()-bw.radius)local iL=dM;if orbit.periapsis~=nil and orbit.eccentricity<1 and an>bv and an0 then local function iM(ee,iN)bp=iN;if iC<=iN+3 and iC>=iN-3 then z=ee;it(ee)else z=0.05;it(0.05)end end;if orbit.apoapsis~=nil then if orbit.periapsis.altitude>bv*0.9 and orbit.periapsis.altitudeorbit.periapsis.altitude and orbit.apoapsis.altitude<=orbit.periapsis.altitude*1.35 then BrakeIsOn=false;z=0;it(0)bx=true;if iC>2 or iC<-2 then bp=0 else bo=nil;bs=false;bu=false;bw=nil;bc=autoRollPreference;W="Orbit established"if bt.VectorToTarget then VectorToTarget=bt.VectorToTarget end;bt.VectorToTarget=false;CancelIntoOrbit=false;IntoOrbit=false;br=false;bp=nil;bq=nil;bw=nil end else bo="Adjusting Orbit"bs=true;if orbit.periapsis.altitudeorbit.periapsis.altitude*1.25 then if be+10>iK then if eg>5 then iM(0.5,-80)BrakeIsOn=false elseif eg<-5 then iM(0.5,80)BrakeIsOn=false else it(0)BrakeIsOn=true end elseif be-10orbit.periapsis.altitude*1.25 then it(0)BrakeIsOn=true elseif orbit.periapsis.altitude0 then iP=iP-iQ+50 end;BrakeIsOn=false;if not br then local iR=false;local iS=false;if an=bp-1 then iR=true else iR=false end;if iL<=bq+1 and iL>=bq-1 then iS=true else iS=false end;if iR and iS then bp=nil;bq=nil;br=true end else if an=bv*0.8 and an100 then iP=iP*0.75;bp=-50 else bp=utils.map(an,bv*0.6,bv,35,0)end elseif an>=bv*1.01 and anbv*1.5 then bo="Reentering orbital corridor"if eg<-100 then bp=45;iP=iP*1.25 else bp=-80;iP=iP*0.75 end end end;iv(math.floor(iP))end;if bp~=nil then if OrbitPitchPID==nil then OrbitPitchPID=pid.new(2*0.01,0,2*0.1)end;local iT=bp-iC;OrbitPitchPID:inject(iT)local iU=utils.clamp(OrbitPitchPID:get(),-0.5,0.5)O=iU end;if bq~=nil then if iC<85 then local iV=math.max(autoRollFactor,0.01)/4;if OrbitRollPID==nil then OrbitRollPID=pid.new(iV*0.01,0,iV*0.1)end;local iW=bq-iL;OrbitRollPID:inject(iW)local iX=utils.clamp(OrbitRollPID:get(),-0.5,0.5)T=iX end end elseif CancelIntoOrbit then bu=false;bw=nil;it(0)CancelIntoOrbit=false end;if Autopilot and j()==0 and not ag then local iY,iZ=AutopilotTargetCoords,false;if CustomTarget~=nil and CustomTarget.planetname~="Space"then AutopilotRealigned=true;if not TargetSet then local i_=(CustomTarget.position-a4.center):normalize()local j0=i_:project_on_plane((a4.center-iB):normalize()):normalize()local j1=a4.center+j0*(a4.radius+AutopilotTargetOrbit)local j2=CustomTarget.position+(CustomTarget.position-a4.center):normalize()*(AutopilotTargetOrbit-a4:getAltitude(CustomTarget.position))if(iB-j1):len()<(iB-j2):len()then iY=j1;AutopilotTargetCoords=iY else iY=CustomTarget.position+(CustomTarget.position-a4.center):normalize()*(AutopilotTargetOrbit-a4:getAltitude(CustomTarget.position))AutopilotTargetCoords=iY end;local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)iZ=true;TargetSet=true end;AutopilotPlanetGravity=0 elseif CustomTarget~=nil and CustomTarget.planetname=="Space"then AutopilotPlanetGravity=0;iZ=true;TargetSet=true;AutopilotRealigned=true;iY=CustomTarget.position+(iB-CustomTarget.position)*AutopilotTargetOrbit elseif CustomTarget==nil then AutopilotPlanetGravity=0;if not TargetSet then local i_=(iB+bd*100000-a4.center):normalize()local j0=i_:project_on_plane((a4.center-iB):normalize()):normalize()if j0:len()<1 then i_=(iB+vec3(core.getConstructWorldOrientationForward())*100000-a4.center):normalize()j0=i_:project_on_plane((a4.center-iB):normalize()):normalize()end;iY=a4.center+j0*(a4.radius+AutopilotTargetOrbit)AutopilotTargetCoords=iY;TargetSet=true;iZ=true;AutopilotRealigned=true;local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)end end;AutopilotDistance=(vec3(iY)-vec3(core.getConstructWorldPos())):len()local ff,fg,fh=b6:getPlanetarySystem(0):castIntersections(iB,bd:normalize(),function(fi)if fi.noAtmosphericDensityAltitude>0 then return fi.radius+fi.noAtmosphericDensityAltitude else return fi.radius+fi.surfaceMaxAltitude*1.5 end end)local fj=fg;if fh~=nil and fg~=nil then fj=math.min(fh,fg)end;if fj~=nil and fj300 and AutopilotAccelerating then local dv=vec3(iY)-vec3(core.getConstructWorldPos())local j4=utils.clamp(math.deg(cQ(iA,bd:normalize(),dv:normalize()))*be/500,-90,90)local j5=utils.clamp(math.deg(cQ(cx,bd:normalize(),dv:normalize()))*be/500,-90,90)if math.abs(j4)<20 and math.abs(j5)<20 then j4=j4*2;j5=j5*2 end;if math.abs(j4)<2 and math.abs(j5)<2 then j4=j4*2;j5=j5*2 end;local iD=-math.deg(cQ(iA,cw,bd:normalize()))local iE=-math.deg(cQ(cx,cw,bd:normalize()))if apPitchPID==nil then apPitchPID=pid.new(2*0.01,0,2*0.1)end;apPitchPID:inject(j5-iE)local j6=utils.clamp(apPitchPID:get(),-1,1)O=O+j6;if apYawPID==nil then apYawPID=pid.new(2*0.01,0,2*0.1)end;apYawPID:inject(j4-iD)local j7=utils.clamp(apYawPID:get(),-1,1)P=P+j7;iZ=true;if math.abs(j4)>2 or math.abs(j5)>2 then AutopilotStatus="Adjusting Trajectory"else AutopilotStatus="Accelerating"end end;if j3=MaxGameVelocity or fH==0 and G then AutopilotAccelerating=false;AutopilotStatus="Cruising"AutopilotCruising=true;it(0)z=0 end;if AutopilotDistance<=a0 then AutopilotAccelerating=false;AutopilotStatus="Braking"AutopilotBraking=true;it(0)z=0;G=false end elseif AutopilotBraking then if AutopilotStatus~="Orbiting to Target"then BrakeIsOn=true;S=1 end;if TurnBurn then it(100,true)z=1 end;local _,iK=b9(a4):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-planet.center):len()-planet.radius)local dv;if CustomTarget~=nil then dv=CustomTarget.position-iB end;if CustomTarget~=nil and CustomTarget.planetname=="Space"and be<50 then W="Autopilot complete, arrived at space location"AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"elseif CustomTarget~=nil and CustomTarget.planetname~="Space"and be<=iK and(orbit.apoapsis==nil or orbit.periapsis==nil or orbit.apoapsis.altitude<=0 or orbit.periapsis.altitude<=0)then W="Autopilot complete, proceeding with reentry"AutopilotTargetCoords=CustomTarget.position;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"it(0)z=0;G=false;ProgradeIsOn=true;ag=true;local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)elseif orbit.periapsis~=nil and orbit.periapsis.altitude>0 and orbit.eccentricity<1 then AutopilotStatus="Circularizing"local _,iK=b9(a4):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-planet.center):len()-planet.radius)if be<=iK then if CustomTarget~=nil then if bd:normalize():dot(dv:normalize())>0.4 then AutopilotStatus="Orbiting to Target"if not WaypointSet then BrakeIsOn=false;local cA=zeroConvertToMapPosition(a4,CustomTarget.position)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)WaypointSet=true end else W="Autopilot complete, proceeding with reentry"AutopilotTargetCoords=CustomTarget.position;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"it(0)z=0;G=false;ProgradeIsOn=true;ag=true;BrakeIsOn=false;local cA=zeroConvertToMapPosition(a4,CustomTarget.position)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)WaypointSet=false end else BrakeIsOn=false;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"W="Autopilot completed, orbit established"S=0;z=0;G=false;if CustomTarget~=nil and CustomTarget.planetname~="Space"then ProgradeIsOn=true;ag=true end end end end elseif AutopilotCruising then if AutopilotDistance<=a0 then AutopilotAccelerating=false;AutopilotStatus="Braking"AutopilotBraking=true end;local fH=unit.getThrottle()if AtmoSpeedAssist then fH=z end;if fH>0 then AutopilotAccelerating=true;AutopilotStatus="Accelerating"AutopilotCruising=false end else if iG then if not AutopilotRealigned and CustomTarget==nil or not AutopilotRealigned and CustomTarget~=nil and CustomTarget.planetname~="Space"then if not ag then AutopilotTargetCoords=vec3(a4.center)+(AutopilotTargetOrbit+a4.radius)*vec3(core.getConstructWorldOrientationRight())AutopilotShipUp=core.getConstructWorldOrientationUp()AutopilotShipRight=core.getConstructWorldOrientationRight()end;AutopilotRealigned=true elseif iG then AutopilotAccelerating=true;AutopilotStatus="Accelerating"if not G then it(AutopilotInterplanetaryThrottle,true)z=round(AutopilotInterplanetaryThrottle,2)G=true;BrakeIsOn=false end end end end elseif Autopilot and(CustomTarget~=nil and CustomTarget.planetname~="Space"and j()>0)then W="Autopilot complete, proceeding with reentry"AutopilotTargetCoords=CustomTarget.position;BrakeIsOn=false;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"S=0;it(0)z=0;G=false;ProgradeIsOn=true;ag=true;local cA=zeroConvertToMapPosition(a4,CustomTarget.position)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)end;if U then bc=true;local j5=0;local cg=vec3(core.getConstructWorldPos())+vec3(unit.getMasterPlayerRelativePosition())local j8=cg-vec3(core.getConstructWorldPos())local j9=vec3(j8):project_on(vec3(core.getConstructWorldOrientationForward())):len()local ja=vec3(j8):project_on(vec3(core.getConstructWorldOrientationRight())):len()local ac=math.sqrt(j9*j9+ja*ja)AlignToWorldVector(j8:normalize())local jb=40;local jc=acje then if pitchPID==nil then pitchPID=pid.new(2*0.01,0,2*0.1)end;pitchPID:inject(j5-cz)local j6=pitchPID:get()O=j6 end end;if AltitudeHold or BrakeLanding or Reentry or VectorToTarget or LockPitch~=nil then local cB=unit.getClosestPlanetInfluence()>0;local jf=HoldAltitude-an;local jg=500+be;local jh=1;if AutoTakeoff then jh=utils.clamp(be/100,0.1,1)end;local j5=(utils.smoothstep(jf,-jg,jg)-0.5)*2*MaxPitch*jh;if not Reentry and not ag and not VectorToTarget and cw:dot(bd:normalize())<0.99 then j5=(utils.smoothstep(jf,-jg*utils.clamp(20-19*j()*10,1,20),jg*utils.clamp(20-19*j()*10,1,20))-0.5)*2*MaxPitch*utils.clamp(2-j()*10,1,2)*jh end;if not AltitudeHold then j5=0 end;if LockPitch~=nil then if cB and not IntoOrbit then j5=LockPitch else LockPitch=nil end end;bc=true;local ji=O;if Reentry then local ReentrySpeed=math.floor(bm)local jj,jk=b7.computeDistanceAndTime(be,ReentrySpeed/3.6,n(),0,0,LastMaxBrake-planet.gravity*9.8*n())local jl=an-(planet.noAtmosphericDensityAltitude+5000)if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and an>planet.noAtmosphericDensityAltitude+5000 and be<=ReentrySpeed/3.6 and be>ReentrySpeed/3.6-10 and math.abs(bd:normalize():dot(cw))>0.9 then Nav.control.cancelCurrentControlMasterMode()z=0 elseif Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byThrottle and(jj>-1 and jl<=jj or an<=planet.noAtmosphericDensityAltitude+5000)then BrakeIsOn=true else BrakeIsOn=false end;iv(ReentrySpeed,true)if not J then j5=-80;if j()>0.02 then W="PARACHUTE DEPLOYED"Reentry=false;BrakeLanding=true;j5=0;bc=autoRollPreference end elseif planet.noAtmosphericDensityAltitude>0 and an>planet.noAtmosphericDensityAltitude+5000 then bc=true elseif an<=planet.noAtmosphericDensityAltitude+5000 then iv(ReentrySpeed)if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)==bm then J=false;Reentry=false;bc=true end end end;if be>I and not ah and not VectorToTarget and not BrakeLanding and ForceAlignment then AlignToWorldVector(vec3(bd))end;if(VectorToTarget or ah)and AutopilotTargetIndex>0 and j()>0.01 then local dv;if CustomTarget~=nil then dv=CustomTarget.position-vec3(core.getConstructWorldPos())else dv=a4.center-iB end;local j4=math.deg(cQ(cy:normalize(),bd,dv))*2;local jm=math.rad(math.abs(dM))if be>minRollVelocity and j()>0.01 then local jn=utils.clamp(90-j5*2,-90,90)bk=utils.clamp(j4*2,-jn,jn)local jo=j4;j4=utils.clamp(utils.clamp(j4,-YawStallAngle*0.85,YawStallAngle*0.85)*math.cos(jm)+4*(iC-j5)*math.sin(math.rad(dM)),-YawStallAngle*0.85,YawStallAngle*0.85)j5=utils.clamp(utils.clamp(j5*math.cos(jm),-PitchStallAngle*0.85,PitchStallAngle*0.85)+math.abs(utils.clamp(math.abs(jo)*math.sin(jm),-PitchStallAngle*0.85,PitchStallAngle*0.85)),-PitchStallAngle*0.85,PitchStallAngle*0.85)else bk=0;j4=utils.clamp(j4,-YawStallAngle*0.85,YawStallAngle*0.85)end;local jp=iD-j4;if not bi and be>minRollVelocity and j()>0.01 then if yawPID==nil then yawPID=pid.new(2*0.01,0,2*0.1)end;yawPID:inject(jp)local j7=utils.clamp(yawPID:get(),-1,1)P=P+j7 elseif am and aj>-1 or be0.01 then if(iD<-YawStallAngle or iD>YawStallAngle)and j()>0.01 then AlignToWorldVector(bd)end;if(iE<-PitchStallAngle or iE>PitchStallAngle)and j()>0.01 then j5=utils.clamp(iC-iE,iC-PitchStallAngle*0.85,iC+PitchStallAngle*0.85)end end;if CustomTarget~=nil and not ah then local jq=planet:getAltitude(CustomTarget.position)local jl=math.sqrt(dv:len()^2-(an-jq)^2)local jr=LastMaxBrakeInAtmo;if jr then jr=jr*utils.clamp(be/100,0.1,1)*j()else jr=LastMaxBrake end;if j()<0.01 then jr=LastMaxBrake end;local js=bd:len()-math.abs(eg)local jt=vec3(core.getWorldAirFrictionAcceleration())local ju=math.sqrt(jt:len()-jt:project_on(ei):len())*n()if be>100 then a0,a1=b7.computeDistanceAndTime(be,100,n(),0,0,jr+ju)local jv,jw=b7.computeDistanceAndTime(100,0,n(),0,0,jr/2)a0=a0+jv else a0,a1=b7.computeDistanceAndTime(be,0,n(),0,0,jr/2)end;StrongBrakes=true;if not ah and not Reentry and jl<=a0+be*iz/2 and(bd:project_on_plane(cy):normalize():dot(dv:project_on_plane(cy):normalize())>0.99 or VectorStatus=="Finalizing Approach")then VectorStatus="Finalizing Approach"it(0)z=0;if AltitudeHold then ToggleAltitudeHold()VectorToTarget=true end;BrakeIsOn=true elseif not AutoTakeoff then BrakeIsOn=false end;if VectorStatus=="Finalizing Approach"and(js<0.1 or jl<0.1 or LastDistanceToTarget~=nil and LastDistanceToTargetplanet.noAtmosphericDensityAltitude and not(ah or Reentry)then if CustomTarget~=nil and a4.name==planet.name then local dv=CustomTarget.position-vec3(core.getConstructWorldPos())local jq=planet:getAltitude(CustomTarget.position)local jl=math.sqrt(dv:len()^2-(an-jq)^2)local jr=LastMaxBrakeInAtmo;if not bx and jl>100000 then bu=false;IntoOrbit=true else jr=LastMaxBrake;a0,a1=b7.computeDistanceAndTime(be,0,n(),0,0,jr/2)StrongBrakes=true;if jl<=a0+be*iz/2 and bd:project_on_plane(cy):normalize():dot(dv:project_on_plane(cy):normalize())>0.99 then if planet.hasAtmosphere then BrakeIsOn=false;ProgradeIsOn=false;J=true;ag=false;ai=true;Autopilot=false;BeginReentry()end end;LastDistanceToTarget=jl end end end;if j()==0 and(AltitudeHold and HoldAltitude>planet.noAtmosphericDensityAltitude)and not(ah or VectorToTarget or IntoOrbit or Reentry)then if not bx then IntoOrbit=true end end;if bi and j()>0.01 and aj==-1 and be>minRollVelocity and VectorStatus~="Finalizing Approach"then AlignToWorldVector(bd)j5=utils.clamp(iC-iE,iC-PitchStallAngle*0.85,iC+PitchStallAngle*0.85)end;O=ji;local fQ=-1;if BrakeLanding then j5=0;local jx=false;local jy=30;if b8~=nil and b8>0 then local ju=0;local dS=utils.clamp(j(),0.4,2)local jr=LastMaxBrakeInAtmo*utils.clamp(be/100,0.1,1)*dS;local jz=b8*dS+jr+ju-bP;local jA=jr/2+ju-bP;local jB=be-math.sqrt(math.abs(jA/2)*20/(0.5*n()))*utils.sign(jA)if jB<0 then jB=0 end;local jC;if be>100 then local jD,_=b7.computeDistanceAndTime(be,100,n(),0,0,jr)local jE,_=b7.computeDistanceAndTime(100,0,n(),0,0,math.sqrt(jr))jC=jD+jE else jC=b7.computeDistanceAndTime(be,0,n(),0,0,math.sqrt(jr))end;if jC<20 then BrakeIsOn=false else local jF=0;if jB>100 then local jG,_=b7.computeDistanceAndTime(jB,100,n(),0,0,jz)local jH,_=b7.computeDistanceAndTime(100,0,n(),0,0,b8*dS+math.sqrt(jr)+ju-bP)jF=jG+jH else jF,_=b7.computeDistanceAndTime(jB,0,n(),0,0,b8*dS+math.sqrt(jr)+ju-bP)end;jF=(jF+15+be*iz)*1.1;local jI=CustomTarget~=nil and planet:getAltitude(CustomTarget.position)>0 and CustomTarget.safe;if jI then local jq=planet:getAltitude(CustomTarget.position)local jJ=an-jq-100;local dv=CustomTarget.position-vec3(core.getConstructWorldPos())local jK=math.sqrt(dv:len()^2-(an-jq)^2)if jK>100 then jI=false elseif jJ<=jF or jF==-1 then BrakeIsOn=true;jx=true else BrakeIsOn=false;jx=true end end;if not jI and CalculateBrakeLandingSpeed then if jF>=jy then BrakeIsOn=true else BrakeIsOn=false end;jx=true end end end;if Nav.axisCommandManager:getAxisCommandType(0)==1 then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setTargetGroundAltitude(500)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(500)fQ=aj;if fQ>-1 then bc=autoRollPreference;if be<1 or bd:normalize():dot(cy)<0 then BrakeLanding=false;AltitudeHold=false;GearExtended=true;Nav.control.extendLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)a8=0;BrakeIsOn=true else BrakeIsOn=true end elseif StrongBrakes and bd:normalize():dot(-ei)<0.999 then BrakeIsOn=true elseif eg<-brakeLandingRate and not jx then BrakeIsOn=true elseif not jx then BrakeIsOn=false end end;if AutoTakeoff or ah then local ff,fh,fg;if AutopilotTargetCoords~=nil then ff,fh,fg=b6:getPlanetarySystem(0):castIntersections(iB,(AutopilotTargetCoords-iB):normalize(),function(fi)return fi.radius+fi.noAtmosphericDensityAltitude end)end;if antigrav and antigrav.getState()==1 then if an>=HoldAltitude-50 then AutoTakeoff=false;BrakeIsOn=true;it(0)z=0 else HoldAltitude=antigrav.getBaseAltitude()end elseif math.abs(j5)<15 and an/HoldAltitude>0.75 then AutoTakeoff=false;if not ah then if Nav.axisCommandManager:getAxisCommandType(0)==0 and not AtmoSpeedAssist then Nav.control.cancelCurrentControlMasterMode()end elseif ah and be-1;local jM=cz;if(VectorToTarget or ah)and not jL and be>minRollVelocity and j()>0.01 then local jm=math.rad(math.abs(dM))jM=cz*math.abs(math.cos(jm))+iE*math.sin(jm)end;local jN=utils.clamp(j5-jM,-PitchStallAngle*0.85,PitchStallAngle*0.85)if j()<0.01 and VectorToTarget then jN=utils.clamp(j5-jM,-85,MaxPitch)elseif j()<0.01 then jN=utils.clamp(j5-jM,-MaxPitch,MaxPitch)end;if math.abs(dM)<5 or VectorToTarget or BrakeLanding or jL or AltitudeHold then if pitchPID==nil then pitchPID=pid.new(5*0.01,0,5*0.1)end;pitchPID:inject(jN)local j6=pitchPID:get()O=O+j6 end end;if antigrav~=nil and(antigrav and not ExternalAGG and an<200000)then if AntigravTargetAltitude==nil or AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;if desiredBaseAltitude~=AntigravTargetAltitude then desiredBaseAltitude=AntigravTargetAltitude;antigrav.setBaseAltitude(desiredBaseAltitude)end end end end;function script.onFlush()if antigrav~=nil and(antigrav and not ExternalAGG)then if antigrav.getState()==0 and antigrav.getBaseAltitude()~=AntigravTargetAltitude then antigrav.setBaseAltitude(AntigravTargetAltitude)end end;if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byThrottle and D then z=0;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,z)D=false elseif Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and not D then z=0;D=true end;pitchSpeedFactor=math.max(pitchSpeedFactor,0.01)yawSpeedFactor=math.max(yawSpeedFactor,0.01)rollSpeedFactor=math.max(rollSpeedFactor,0.01)torqueFactor=math.max(torqueFactor,0.01)brakeSpeedFactor=math.max(brakeSpeedFactor,0.01)brakeFlatFactor=math.max(brakeFlatFactor,0.01)autoRollFactor=math.max(autoRollFactor,0.01)turnAssistFactor=math.max(turnAssistFactor,0.01)local jO=utils.clamp(N+O+system.getControlDeviceForwardInput(),-1,1)local jP=utils.clamp(Q+T+system.getControlDeviceYawInput(),-1,1)local jQ=utils.clamp(R+P-system.getControlDeviceLeftRightInput(),-1,1)local jR=S;local jS=vec3(core.getWorldVertical())if jS==nil or jS:len()==0 then jS=(planet.center-vec3(core.getConstructWorldPos())):normalize()end;local jT=vec3(core.getConstructWorldOrientationUp())local jU=vec3(core.getConstructWorldOrientationForward())local jV=vec3(core.getConstructWorldOrientationRight())local jW=vec3(core.getWorldVelocity())local jX=vec3(core.getWorldVelocity()):normalize()local jY=getRoll(jS,jU,jV)local jZ=math.abs(jY)local j_=utils.sign(jY)local j=j()local k0=vec3(core.getWorldAngularVelocity())local k1=jO*pitchSpeedFactor*jV+jP*rollSpeedFactor*jU+jQ*yawSpeedFactor*jT;if jS:len()>0.01 and(j>0.0 or ProgradeIsOn or Reentry or ag or AltitudeHold)then local dM=getRoll(jS,jU,jV)local dN=dM/180*math.pi;local dO=math.cos(dN)local dP=math.sin(dN)local iC=getPitch(jS,jU,jV*dO+jT*dP)if bc==true and math.abs(bk-jY)>autoRollRollThreshold and jP==0 and math.abs(iC)<85 then local k2=bk;local iV=autoRollFactor;if j==0 then iV=iV/4;bk=0;k2=0 end;if rollPID==nil then rollPID=pid.new(iV*0.01,0,iV*0.1)end;rollPID:inject(k2-jY)local k3=rollPID:get()k1=k1+k3*jU end end;if jS:len()>0.01 and j>0.0 then local k4=20.0;if turnAssist==true and jZ>k4 and jO==0 and jQ==0 then local k5=turnAssistFactor*0.1;local k6=turnAssistFactor*0.025;local k7=(jZ-k4)/(180-k4)*180;local k8=0;if k7<90 then k8=k7/90 elseif k7<180 then k8=(180-k7)/90 end;k8=k8*k8;local k9=-j_*k6*(1.0-k8)local ka=k5*k8;k1=k1+ka*jV+k9*jT end end;local kb=1;local kc=0;local kd=1;if system.getMouseWheel()>0 then if AltIsOn then if j>0 or Reentry then bm=utils.clamp(bm+speedChangeLarge,0,AtmoSpeedLimit)elseif Autopilot then MaxGameVelocity=utils.clamp(MaxGameVelocity+speedChangeLarge/3.6*100,0,8333.00)end;H=false else z=round(utils.clamp(z+speedChangeLarge/100,-1,1),2)end elseif system.getMouseWheel()<0 then if AltIsOn then if j>0 or Reentry then bm=utils.clamp(bm-speedChangeLarge,0,AtmoSpeedLimit)elseif Autopilot then MaxGameVelocity=utils.clamp(MaxGameVelocity-speedChangeLarge/3.6*100,0,8333.00)end;H=false else z=round(utils.clamp(z-speedChangeLarge/100,-1,1),2)end end;A=0;local eg=-jS:dot(jW)if am and AtmoSpeedAssist and Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byThrottle then if throttlePID==nil then throttlePID=pid.new(0.5,0,1)end;throttlePID:inject(bm/3.6-jW:dot(jU))local ke=throttlePID:get()C=utils.clamp(ke,-1,1)if C0.005 then B=true;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,utils.clamp(C,0.01,1))else B=false;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,z)end;if brakePID==nil then brakePID=pid.new(1*0.01,0,1*0.1)end;brakePID:inject(jW:len()-bm/3.6)local kf=utils.clamp(brakePID:get(),0,1)if j>0 and eg<-80 or j>0.005 then A=kf end;if A>0 then if B and C==0.01 then Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)end else C=utils.clamp(C,0.01,1)end;local kg=''local kh=vec3()local ki=composeAxisAccelerationFromTargetSpeedV(axisCommandId.vertical,a8*1000)Nav:setEngineForceCommand("vertical airfoil , vertical ground ",ki,kc)local kj='thrust analog longitudinal 'if ExtraLongitudeTags~="none"then kj=kj..ExtraLongitudeTags end;local kk=Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)local kl=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(kj,axisCommandId.longitudinal)local km=composeAxisAccelerationFromTargetSpeed(axisCommandId.lateral,LeftAmount*1000)kg=kg..' , '.."lateral airfoil , lateral ground "kh=kh+km;if kh:len()>constants.epsilon then Nav:setEngineForceCommand(kg,kh,kc,'','','',kd)end;Nav:setEngineForceCommand(kj,kl,kb)local kn='thrust analog vertical fueled 'local ko='thrust analog lateral fueled 'if ExtraLateralTags~="none"then ko=ko..ExtraLateralTags end;if ExtraVerticalTags~="none"then kn=kn..ExtraVerticalTags end;if a8~=0 or BrakeLanding and BrakeIsOn then Nav:setEngineForceCommand(kn,ki,kb)else Nav:setEngineForceCommand(kn,vec3(),kb)end;if LeftAmount~=0 then Nav:setEngineForceCommand(ko,km,kb)else Nav:setEngineForceCommand(ko,vec3(),kb)end;if jR==0 then jR=A end;local kp=-jR*(brakeSpeedFactor*jW+brakeFlatFactor*jX)Nav:setEngineForceCommand('brake',kp)else if AtmoSpeedAssist then Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,z)end;local kp=-jR*(brakeSpeedFactor*jW+brakeFlatFactor*jX)Nav:setEngineForceCommand('brake',kp)local kg=''local kh=vec3()local kq=false;local kj='thrust analog longitudinal 'if ExtraLongitudeTags~="none"then kj=kj..ExtraLongitudeTags end;local kk=Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)if kk==axisCommandType.byThrottle then local kl=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(kj,axisCommandId.longitudinal)Nav:setEngineForceCommand(kj,kl,kb)elseif kk==axisCommandType.byTargetSpeed then local kl=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.longitudinal)kg=kg..' , '..kj;kh=kh+kl;if Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)==0 or Nav.axisCommandManager:getCurrentToTargetDeltaSpeed(axisCommandId.longitudinal)<-Nav.axisCommandManager:getTargetSpeedCurrentStep(axisCommandId.longitudinal)*0.5 then kq=true end end;local ko='thrust analog lateral 'if ExtraLateralTags~="none"then ko=ko..ExtraLateralTags end;local kr=Nav.axisCommandManager:getAxisCommandType(axisCommandId.lateral)if kr==axisCommandType.byThrottle then local ks=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(ko,axisCommandId.lateral)Nav:setEngineForceCommand(ko,ks,kb)elseif kr==axisCommandType.byTargetSpeed then local km=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.lateral)kg=kg..' , '..ko;kh=kh+km end;local kn='thrust analog vertical 'if ExtraVerticalTags~="none"then kn=kn..ExtraVerticalTags end;local kt=Nav.axisCommandManager:getAxisCommandType(axisCommandId.vertical)if kt==axisCommandType.byThrottle then local ki=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(kn,axisCommandId.vertical)if a8~=0 or BrakeLanding and BrakeIsOn then Nav:setEngineForceCommand(kn,ki,kb,'airfoil','ground','',kd)else Nav:setEngineForceCommand(kn,vec3(),kb)Nav:setEngineForceCommand('airfoil vertical',ki,kb,'airfoil','','',kd)Nav:setEngineForceCommand('ground vertical',ki,kb,'ground','','',kd)end elseif kt==axisCommandType.byTargetSpeed then if a8<0 then Nav:setEngineForceCommand('hover',vec3(),kb)end;local ku=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.vertical)kg=kg..' , '..kn;kh=kh+ku end;local gb=unit.getAxisCommandValue(0)if kh:len()>constants.epsilon then if S~=0 or kq or math.abs(jX:dot(jU))<0.8 or bd:len()>gb/3.6 then kg=kg..', brake'end;Nav:setEngineForceCommand(kg,kh,kc,'','','',kd)end end;local kv=torqueFactor*(k1-k0)local kw=vec3(core.getWorldAirFrictionAngularAcceleration())kv=kv-kw;Nav:setEngineTorqueCommand('torque',kv,kb,'airfoil','','',kd)Nav:setBoosterCommand('rocket_engine')if Z and not VanillaRockets then local bS=vec3(core.getVelocity()):len()local kx=0.15;if Nav.axisCommandManager:getAxisCommandType(0)==1 then local ky=Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)if bS*3.6>ky*(1-kx)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bS*3.6=gb*(1-kx)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bS=gb*(1-kx)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bS0 or anHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude+Y;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude+Y end else AntigravTargetAltitude=desiredBaseAltitude+100 end elseif AltitudeHold then HoldAltitude=HoldAltitude+X else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(1.0)end elseif kz=="groundaltitudedown"then OldButtonMod=X;OldAntiMod=Y;if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitudeHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end end else AntigravTargetAltitude=desiredBaseAltitude end elseif AltitudeHold then HoldAltitude=HoldAltitude-X else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(-1.0)end elseif kz=="option1"then if not Autopilot then IncrementAutopilotTargetIndex()H=false end elseif kz=="option2"then if not Autopilot then DecrementAutopilotTargetIndex()H=false end elseif kz=="option3"then if hideHudOnToggleWidgets then if showHud then showHud=false else showHud=true end end;H=false;ToggleWidgets()elseif kz=="option4"then ToggleAutopilot()H=false elseif kz=="option5"then ToggleLockPitch()H=false elseif kz=="option6"then ToggleAltitudeHold()H=false elseif kz=="option7"then wipeSaveVariables()H=false elseif kz=="option8"then ToggleFollowMode()H=false elseif kz=="option9"then if gyro~=nil then gyro.toggle()aq=gyro.getState()==1 end;H=false elseif kz=="lshift"then if system.isViewLocked()==1 then V=true;PrevViewLock=system.isViewLocked()system.lockView(1)elseif o()==1 and ShiftShowsRemoteButtons then V=true;bb=false;ba=false end elseif kz=="brake"then if BrakeToggleStatus then BrakeToggle()elseif not BrakeIsOn then BrakeToggle()else BrakeIsOn=true end elseif kz=="lalt"then AltIsOn=true;if o()==0 and not freeLookToggle and userControlScheme=="keyboard"then system.lockView(1)end elseif kz=="booster"then if VanillaRockets then Nav:toggleBoosters()elseif not Z then if not IsRocketOn then Nav:toggleBoosters()IsRocketOn=true end;Z=true else if IsRocketOn then Nav:toggleBoosters()IsRocketOn=false end;Z=false end elseif kz=="stopengines"then Nav.axisCommandManager:resetCommand(axisCommandId.longitudinal)clearAll()z=0 elseif kz=="speedup"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z+speedChangeLarge/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal,speedChangeLarge)end else IncrementAutopilotTargetIndex()end elseif kz=="speeddown"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z-speedChangeLarge/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal,-speedChangeLarge)end else DecrementAutopilotTargetIndex()end elseif kz=="antigravity"and not ExternalAGG then if antigrav~=nil then ToggleAntigrav()end end end;function script.onActionStop(kz)if kz=="forward"then N=0 elseif kz=="backward"then N=0 elseif kz=="left"then Q=0 elseif kz=="right"then Q=0 elseif kz=="yawright"then R=0 elseif kz=="yawleft"then R=0 elseif kz=="straferight"then Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral,-1.0)LeftAmount=0 elseif kz=="strafeleft"then Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral,1.0)LeftAmount=0 elseif kz=="up"then a8=0;Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical,-1.0)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(currentGroundAltitudeStabilization)Nav:setEngineForceCommand('hover',vec3(),1)elseif kz=="down"then a8=0;Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical,1.0)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(currentGroundAltitudeStabilization)Nav:setEngineForceCommand('hover',vec3(),1)elseif kz=="groundaltitudeup"then if antigrav and not ExternalAGG and antigrav.getState()==1 then Y=OldAntiMod end;if AltitudeHold then X=OldButtonMod end;H=false elseif kz=="groundaltitudedown"then if antigrav and not ExternalAGG and antigrav.getState()==1 then Y=OldAntiMod end;if AltitudeHold then X=OldButtonMod end;H=false elseif kz=="lshift"then if system.isViewLocked()==1 then V=false;a9=0;aa=0;system.lockView(PrevViewLock)elseif o()==1 and ShiftShowsRemoteButtons then V=false;bb=false;ba=false end elseif kz=="brake"then if not BrakeToggleStatus then if BrakeIsOn then BrakeToggle()else BrakeIsOn=false end end elseif kz=="lalt"then if o()==0 and freeLookToggle then if H then if system.isViewLocked()==1 then system.lockView(0)else system.lockView(1)end else H=true end elseif o()==0 and not freeLookToggle and userControlScheme=="keyboard"then system.lockView(0)end;AltIsOn=false end end;function script.onActionLoop(kz)if kz=="groundaltitudeup"then if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitudeHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude+Y;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude+Y end;Y=Y*1.05;BrakeIsOn=false else AntigravTargetAltitude=desiredBaseAltitude+100;BrakeIsOn=false end elseif AltitudeHold then HoldAltitude=HoldAltitude+X;X=X*1.05 else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(1.0)end elseif kz=="groundaltitudedown"then if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitudeHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end end;Y=Y*1.05;BrakeIsOn=false else AntigravTargetAltitude=desiredBaseAltitude-100;BrakeIsOn=false end elseif AltitudeHold then HoldAltitude=HoldAltitude-X;X=X*1.05 else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(-1.0)end elseif kz=="speedup"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z+speedChangeSmall/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal,speedChangeSmall)end end elseif kz=="speeddown"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z-speedChangeSmall/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal,-speedChangeSmall)end end end end;function script.onInputText(dA)local i;local kA="/commands /setname /G /agg /addlocation /copydatabank"local kB,kC=nil,nil;local kD="Command List:\n/commands \n/setname - Updates current selected saved position name\n/G VariableName newValue - Updates global variable to new value\n".."/G dump - shows all updatable variables with /G\n/agg - Manually set agg target height\n".."/addlocation savename ::pos{0,2,46.4596,-155.1799,22.6572} - adds a saved location by waypoint, not as accurate as making one at location\n".."/copydatabank - copies dbHud databank to a blank databank"i=string.find(dA," ")kB=dA;if i~=nil then kB=string.sub(dA,0,i-1)kC=string.sub(dA,i+1)elseif not string.find(kA,kB)then for g7 in string.gmatch(kD,"([^\n]+)")do c(g7)end;return end;if kB=="/setname"then if kC==nil or kC==""then W="Usage: /setname Newname"return end;if AutopilotTargetIndex>0 and CustomTarget~=nil then UpdatePosition(kC)else W="Select a saved target to rename first"end elseif kB=="/addlocation"then if kC==nil or kC==""or string.find(kC,"::")==nil then W="Usage: /addlocation savename ::pos{0,2,46.4596,-155.1799,22.6572}"return end;i=string.find(kC,"::")local cm=string.sub(kC,1,i-2)local cg=string.sub(kC,i)local q=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local ch='::pos{'..q..','..q..','..q..','..q..','..q..'}'local ci,cj,cd,ce,cc=string.match(cg,ch)local planet=b0[tonumber(ci)][tonumber(cj)]AddNewLocationByWaypoint(cm,planet,cg)W="Added "..cm.." to saved locations,\nplanet "..planet.name.." at "..cg;ab=5 elseif kB=="/agg"then if kC==nil or kC==""then W="Usage: /agg targetheight"return end;kC=tonumber(kC)if kC<1000 then kC=1000 end;AntigravTargetAltitude=kC;W="AGG Target Height set to "..kC elseif kB=="/G"then if kC==nil or kC==""then W="Usage: /G VariableName variablevalue\n/G dump - shows all variables"return end;if kC=="dump"then for bB,bC in pairs(a)do if type(_G[bC])=="boolean"then if _G[bC]==true then c(bC.." true")else c(bC.." false")end elseif _G[bC]==nil then c(bC.." nil")else c(bC.." ".._G[bC])end end;return end;i=string.find(kC," ")local kE=string.sub(kC,0,i-1)local kF=string.sub(kC,i+1)for bB,bC in pairs(a)do if bC==kE then W="Variable "..kE.." changed to "..kF;local kG=type(_G[bC])if kG=="number"then kF=tonumber(kF)elseif kG=="boolean"then if string.lower(kF)=="true"then kF=true else kF=false end end;_G[bC]=kF;return end end;W="No such global variable: "..kE elseif kB=="/copydatabank"then if dbHud_2 then SaveDataBank(true)else W="Databank required to copy databank"end end end;script.onStart() + Radar: No Contacts]],g2,g3)end;if radarPanelID~=nil then af=0;ToggleRadarPanel()end end end end;function DisplayMessage(ct,dy)if dy~="empty"then ct[#ct+1]=[[]]for g7 in string.gmatch(dy,"([^\n]+)")do ct[#ct+1]=e([[%s]],g7)end;ct[#ct+1]=[[]]end;if ab~=0 then unit.setTimer("msgTick",ab)ab=0 end end;function updateDistance()local bL=system.getTime()local bd=vec3(core.getWorldVelocity())local dU=vec3(bd):len()local g8=bL-ap;if dU>1.38889 then dU=dU/1000;local g9=dU*(bL-ap)TotalDistanceTravelled=TotalDistanceTravelled+g9;a5=a5+g9 end;a6=a6+g8;TotalFlightTime=TotalFlightTime+g8;ap=bL end;function composeAxisAccelerationFromTargetSpeedV(ga,gb)local gc=vec3()local gd=vec3()if ga==axisCommandId.longitudinal then gc=vec3(core.getConstructOrientationForward())gd=vec3(core.getConstructWorldOrientationForward())elseif ga==axisCommandId.vertical then gc=vec3(core.getConstructOrientationUp())gd=vec3(core.getConstructWorldOrientationUp())elseif ga==axisCommandId.lateral then gc=vec3(core.getConstructOrientationRight())gd=vec3(core.getConstructWorldOrientationRight())else return vec3()end;local ge=vec3(core.getWorldGravity())local gf=ge:dot(gd)local gg=vec3(core.getWorldAirFrictionAcceleration())local gh=gg:dot(gd)local gi=vec3(core.getVelocity())local gj=gi:dot(gc)local gk=gb*constants.kph2m;if targetSpeedPID2==nil then targetSpeedPID2=pid.new(10,0,10.0)end;targetSpeedPID2:inject(gk-gj)local gl=targetSpeedPID2:get()local gm=(gl-gh-gf)*gd;return gm end;function composeAxisAccelerationFromTargetSpeed(ga,gb)local gc=vec3()local gd=vec3()if ga==axisCommandId.longitudinal then gc=vec3(core.getConstructOrientationForward())gd=vec3(core.getConstructWorldOrientationForward())elseif ga==axisCommandId.vertical then gc=vec3(core.getConstructOrientationUp())gd=vec3(core.getConstructWorldOrientationUp())elseif ga==axisCommandId.lateral then gc=vec3(core.getConstructOrientationRight())gd=vec3(core.getConstructWorldOrientationRight())else return vec3()end;local ge=vec3(core.getWorldGravity())local gf=ge:dot(gd)local gg=vec3(core.getWorldAirFrictionAcceleration())local gh=gg:dot(gd)local gi=vec3(core.getVelocity())local gj=gi:dot(gc)local gk=gb*constants.kph2m;if targetSpeedPID==nil then targetSpeedPID=pid.new(10,0,10.0)end;targetSpeedPID:inject(gk-gj)local gl=targetSpeedPID:get()local gm=(gl-gh-gf)*gd;return gm end;function Atlas()return{[0]={[0]={GM=0,bodyId=0,center={x=0,y=0,z=0},name='Space',planetarySystemId=0,radius=0,hasAtmosphere=false,gravity=0,noAtmosphericDensityAltitude=0,surfaceMaxAltitude=0},[2]={name="Alioth",description="Alioth is the planet selected by the arkship for landfall; it is a typical goldilocks planet where humanity may rebuild in the coming decades. The arkship geological survey reports mountainous regions alongside deep seas and lush forests. This is where it all starts.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9401,atmosphericEngineMaxAltitude=5580,biosphere="Forest",classification="Mesoplanet",bodyId=2,GM=157470826617,gravity=1.0082568597356114,fullAtmosphericDensityMaxAltitude=-10,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=6272,numSatellites=2,positionFromSun=2,center={x=-8,y=-8,z=-126303},radius=126067.8984375,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=3410,surfaceArea=199718780928,surfaceAverageAltitude=200,surfaceMaxAltitude=1100,surfaceMinAltitude=-330,systemZone="High",territories=259472,type="Planet",waterLevel=0,planetarySystemId=0},[21]={name="Alioth Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=21,GM=2118960000,gravity=0.24006116402380084,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=457933,y=-1509011,z=115524},radius=30000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=11309733888,surfaceAverageAltitude=140,surfaceMaxAltitude=200,surfaceMinAltitude=10,systemZone=nil,territories=14522,type="",waterLevel=nil,planetarySystemId=0},[22]={name="Alioth Moon 4",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=22,GM=2165833514,gravity=0.2427018259886451,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-1692694,y=729681,z=-411464},radius=30330,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=0,surfaceArea=11559916544,surfaceAverageAltitude=-15,surfaceMaxAltitude=-5,surfaceMinAltitude=-50,systemZone=nil,territories=14522,type="",waterLevel=nil,planetarySystemId=0},[5]={name="Feli",description="Feli is easily identified by its massive and deep crater. Outside of the crater, the arkship geological survey reports a fairly bland and uniform planet, it also cannot explain the existence of the crater. Feli is particular for having an extremely small atmosphere, allowing life to develop in the deeper areas of its crater but limiting it drastically on the actual surface.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.5488,atmosphericEngineMaxAltitude=66725,biosphere="Barren",classification="Mesoplanet",bodyId=5,GM=16951680000,gravity=0.4801223280476017,fullAtmosphericDensityMaxAltitude=30,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=78500,numSatellites=1,positionFromSun=5,center={x=-43534464,y=22565536,z=-48934464},radius=41800,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=42800,surfaceArea=21956466688,surfaceAverageAltitude=18300,surfaceMaxAltitude=18500,surfaceMinAltitude=46,systemZone="Low",territories=27002,type="Planet",waterLevel=nil,planetarySystemId=0},[50]={name="Feli Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=50,GM=499917600,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-43902841.78,y=22261034.7,z=-48862386},radius=14000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=800,surfaceMaxAltitude=900,surfaceMinAltitude=0,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[120]={name="Ion",description="Ion is nothing more than an oversized ice cube frozen through and through. It is a largely inhospitable planet due to its extremely low temperatures. The arkship geological survey reports extremely rough mountainous terrain with little habitable land.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9522,atmosphericEngineMaxAltitude=10480,biosphere="Ice",classification="Hypopsychroplanet",bodyId=120,GM=7135606629,gravity=0.36009174603570127,fullAtmosphericDensityMaxAltitude=-30,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=17700,numSatellites=2,positionFromSun=12,center={x=2865536.7,y=-99034464,z=-934462.02},radius=44950,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=6410,surfaceArea=25390383104,surfaceAverageAltitude=500,surfaceMaxAltitude=1300,surfaceMinAltitude=250,systemZone="Average",territories=32672,type="Planet",waterLevel=nil,planetarySystemId=0},[121]={name="Ion Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=121,GM=106830900,gravity=0.08802242599860607,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=2472916.8,y=-99133747,z=-1133582.8},radius=11000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=1520530944,surfaceAverageAltitude=100,surfaceMaxAltitude=200,surfaceMinAltitude=3,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[122]={name="Ion Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=122,GM=176580000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=2995424.5,y=-99275010,z=-1378480.7},radius=15000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=-1900,surfaceMaxAltitude=-1400,surfaceMinAltitude=-2100,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[9]={name="Jago",description="Jago is a water planet. The large majority of the planet's surface is covered by large oceans dotted by small areas of landmass across the planet. The arkship geological survey reports deep seas across the majority of the planet with sub 15 percent coverage of solid ground.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9835,atmosphericEngineMaxAltitude=9695,biosphere="Water",classification="Mesoplanet",bodyId=9,GM=18606274330,gravity=0.5041284298678057,fullAtmosphericDensityMaxAltitude=-90,habitability="Very High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=10900,numSatellites=0,positionFromSun=9,center={x=-94134462,y=12765534,z=-3634464},radius=61590,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=5900,surfaceArea=47668367360,surfaceAverageAltitude=0,surfaceMaxAltitude=1200,surfaceMinAltitude=-500,systemZone="Very High",territories=60752,type="Planet",waterLevel=0,planetarySystemId=0},[100]={name="Lacobus",description="Lacobus is an ice planet that also features large bodies of water. The arkship geological survey reports deep oceans alongside a frozen and rough mountainous environment. Lacobus seems to feature regional geothermal activity allowing for the presence of water on the surface.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.7571,atmosphericEngineMaxAltitude=11120,biosphere="Ice",classification="Psychroplanet",bodyId=100,GM=13975172474,gravity=0.45611622622739767,fullAtmosphericDensityMaxAltitude=-20,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=12510,numSatellites=3,positionFromSun=10,center={x=98865536,y=-13534464,z=-934461.99},radius=55650,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=6790,surfaceArea=38917074944,surfaceAverageAltitude=800,surfaceMaxAltitude=1660,surfaceMinAltitude=250,systemZone="Average",territories=50432,type="Planet",waterLevel=0,planetarySystemId=0},[102]={name="Lacobus Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=102,GM=444981600,gravity=0.14403669598391783,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=99180968,y=-13783862,z=-926156.4},radius=18000,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=0,surfaceArea=4071504128,surfaceAverageAltitude=150,surfaceMaxAltitude=300,surfaceMinAltitude=10,systemZone=nil,territories=5072,type="",waterLevel=nil,planetarySystemId=0},[103]={name="Lacobus Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=103,GM=211503600,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=99250052,y=-13629215,z=-1059341.4},radius=14000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=-1380,surfaceMaxAltitude=-1280,surfaceMinAltitude=-1880,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[101]={name="Lacobus Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=101,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=98905288.17,y=-13950921.1,z=-647589.53},radius=15000,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=500,surfaceMaxAltitude=820,surfaceMinAltitude=3,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[1]={name="Madis",description="Madis is a barren wasteland of a rock; it sits closest to the sun and temperatures reach extreme highs during the day. The arkship geological survey reports long rocky valleys intermittently separated by small ravines.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.8629,atmosphericEngineMaxAltitude=7165,biosphere="Barren",classification="hyperthermoplanet",bodyId=1,GM=6930729684,gravity=0.36009174603570127,fullAtmosphericDensityMaxAltitude=220,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=8050,numSatellites=3,positionFromSun=1,center={x=17465536,y=22665536,z=-34464},radius=44300,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=4480,surfaceArea=24661377024,surfaceAverageAltitude=750,surfaceMaxAltitude=850,surfaceMinAltitude=670,systemZone="Low",territories=30722,type="Planet",waterLevel=nil,planetarySystemId=0},[10]={name="Madis Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=10,GM=78480000,gravity=0.08002039003323584,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17448118.224,y=22966846.286,z=143078.82},radius=10000,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=0,surfaceArea=1256637056,surfaceAverageAltitude=210,surfaceMaxAltitude=420,surfaceMinAltitude=0,systemZone=nil,territories=1472,type="",waterLevel=nil,planetarySystemId=0},[11]={name="Madis Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=11,GM=237402000,gravity=0.09602446196397631,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17194626,y=22243633.88,z=-214962.81},radius=12000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=1809557376,surfaceAverageAltitude=-700,surfaceMaxAltitude=300,surfaceMinAltitude=-2900,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[12]={name="Madis Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=12,GM=265046609,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17520614,y=22184730,z=-309989.99},radius=15000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=700,surfaceMaxAltitude=1100,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[26]={name="Sanctuary",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9666,atmosphericEngineMaxAltitude=6935,biosphere="",classification="",bodyId=26,GM=68234043600,gravity=1.0000000427743831,fullAtmosphericDensityMaxAltitude=-30,habitability="",hasAtmosphere=true,isSanctuary=true,noAtmosphericDensityAltitude=7800,numSatellites=0,positionFromSun=0,center={x=-1404835,y=562655,z=-285074},radius=83400,safeAreaEdgeAltitude=0,size="L",spaceEngineMinAltitude=4230,surfaceArea=87406149632,surfaceAverageAltitude=80,surfaceMaxAltitude=500,surfaceMinAltitude=-60,systemZone=nil,territories=111632,type="",waterLevel=0,planetarySystemId=0},[6]={name="Sicari",description="Sicari is a typical desert planet; it has survived for millenniums and will continue to endure. While not the most habitable of environments it remains a relatively untouched and livable planet of the Alioth sector. The arkship geological survey reports large flatlands alongside steep plateaus.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.897,atmosphericEngineMaxAltitude=7725,biosphere="Desert",classification="Mesoplanet",bodyId=6,GM=10502547741,gravity=0.4081039739797361,fullAtmosphericDensityMaxAltitude=-625,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=8770,numSatellites=0,positionFromSun=6,center={x=52765536,y=27165538,z=52065535},radius=51100,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=4480,surfaceArea=32813432832,surfaceAverageAltitude=130,surfaceMaxAltitude=220,surfaceMinAltitude=50,systemZone="Average",territories=41072,type="Planet",waterLevel=nil,planetarySystemId=0},[7]={name="Sinnen",description="Sinnen is a an empty and rocky hell. With no atmosphere to speak of it is one of the least hospitable planets in the sector. The arkship geological survey reports mostly flatlands alongside deep ravines which look to have once been riverbeds. This planet simply looks to have dried up and died, likely from solar winds.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9226,atmosphericEngineMaxAltitude=10335,biosphere="Desert",classification="Mesoplanet",bodyId=7,GM=13033380591,gravity=0.4401121421448438,fullAtmosphericDensityMaxAltitude=-120,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=11620,numSatellites=1,positionFromSun=7,center={x=58665538,y=29665535,z=58165535},radius=54950,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=6270,surfaceArea=37944188928,surfaceAverageAltitude=317,surfaceMaxAltitude=360,surfaceMinAltitude=23,systemZone="Average",territories=48002,type="Planet",waterLevel=nil,planetarySystemId=0},[70]={name="Sinnen Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=70,GM=396912600,gravity=0.1360346539426409,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=58969616,y=29797945,z=57969449},radius=17000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=3631681280,surfaceAverageAltitude=-2050,surfaceMaxAltitude=-1950,surfaceMinAltitude=-2150,systemZone=nil,territories=4322,type="",waterLevel=nil,planetarySystemId=0},[110]={name="Symeon",description="Symeon is an ice planet mysteriously split at the equator by a band of solid desert. Exactly how this phenomenon is possible is unclear but some sort of weather anomaly may be responsible. The arkship geological survey reports a fairly diverse mix of flat-lands alongside mountainous formations.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9559,atmosphericEngineMaxAltitude=6920,biosphere="Ice, Desert",classification="Hybrid",bodyId=110,GM=9204742375,gravity=0.3920998898971822,fullAtmosphericDensityMaxAltitude=-30,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=7800,numSatellites=0,positionFromSun=11,center={x=14165536,y=-85634465,z=-934464.3},radius=49050,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=4230,surfaceArea=30233462784,surfaceAverageAltitude=39,surfaceMaxAltitude=450,surfaceMinAltitude=126,systemZone="High",territories=38882,type="Planet",waterLevel=nil,planetarySystemId=0},[4]={name="Talemai",description="Talemai is a planet in the final stages of an Ice Age. It seems likely that the planet was thrown into tumult by a cataclysmic volcanic event which resulted in its current state. The arkship geological survey reports large mountainous regions across the entire planet.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.8776,atmosphericEngineMaxAltitude=9685,biosphere="Barren",classification="Psychroplanet",bodyId=4,GM=14893847582,gravity=0.4641182439650478,fullAtmosphericDensityMaxAltitude=-78,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=10890,numSatellites=3,positionFromSun=4,center={x=-13234464,y=55765536,z=465536},radius=57500,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=5890,surfaceArea=41547563008,surfaceAverageAltitude=580,surfaceMaxAltitude=610,surfaceMinAltitude=520,systemZone="Average",territories=52922,type="Planet",waterLevel=nil,planetarySystemId=0},[42]={name="Talemai Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=42,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-13058408,y=55781856,z=740177.76},radius=15000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=720,surfaceMaxAltitude=850,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[40]={name="Talemai Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=40,GM=141264000,gravity=0.09602446196397631,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-13503090,y=55594325,z=769838.64},radius=12000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=1809557376,surfaceAverageAltitude=250,surfaceMaxAltitude=450,surfaceMinAltitude=0,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[41]={name="Talemai Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=41,GM=106830900,gravity=0.08802242599860607,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-12800515,y=55700259,z=325207.84},radius=11000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=1520530944,surfaceAverageAltitude=190,surfaceMaxAltitude=400,surfaceMinAltitude=0,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[8]={name="Teoma",description="[REDACTED] The arkship geological survey [REDACTED]. This planet should not be here.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.7834,atmosphericEngineMaxAltitude=5580,biosphere="Forest",classification="Mesoplanet",bodyId=8,GM=18477723600,gravity=0.48812434578525177,fullAtmosphericDensityMaxAltitude=15,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=6280,numSatellites=0,positionFromSun=8,center={x=80865538,y=54665536,z=-934463.94},radius=62000,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=3420,surfaceArea=48305131520,surfaceAverageAltitude=700,surfaceMaxAltitude=1100,surfaceMinAltitude=-200,systemZone="High",territories=60752,type="Planet",waterLevel=0,planetarySystemId=0},[3]={name="Thades",description="Thades is a scorched desert planet. Perhaps it was once teaming with life but now all that remains is ash and dust. The arkship geological survey reports a rocky mountainous planet bisected by a massive unnatural ravine; something happened to this planet.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.03552,atmosphericEngineMaxAltitude=32180,biosphere="Desert",classification="Thermoplanet",bodyId=3,GM=11776905000,gravity=0.49612641213015557,fullAtmosphericDensityMaxAltitude=150,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=32800,numSatellites=2,positionFromSun=3,center={x=29165536,y=10865536,z=65536},radius=49000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=21400,surfaceArea=30171856896,surfaceAverageAltitude=13640,surfaceMaxAltitude=13690,surfaceMinAltitude=370,systemZone="Low",territories=38882,type="Planet",waterLevel=nil,planetarySystemId=0},[30]={name="Thades Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=30,GM=211564034,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=29214402,y=10907080.695,z=433858.2},radius=14000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=60,surfaceMaxAltitude=300,surfaceMinAltitude=0,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[31]={name="Thades Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=31,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=29404193,y=10432768,z=19554.131},radius=15000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=70,surfaceMaxAltitude=350,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0}}}end;function SetupAtlas()b0=Atlas()for bB,bC in pairs(b0[0])do if aE==nil or bC.center.xaF then aF=bC.center.x end;if aG==nil or bC.center.yaH then aH=bC.center.y end end;b1=""local gn=1.1*(aF-aE)/1920;local go=1.4*(aH-aG)/1080;for bB,bC in pairs(b0[0])do local bY=960+bC.center.x/gn;local bZ=540+bC.center.y/go;b1=b1 ..''if not string.match(bC.name,"Moon")and not string.match(bC.name,"Sanctuary")and not string.match(bC.name,"Space")then b1=b1 ..""..bC.name..""end end;local cg=vec3(core.getConstructWorldPos())local bY=960+cg.x/gn;local bZ=540+cg.y/go;b1=b1 ..''b1=b1 .."You Are Here"b1=b1 ..[[]]b2=gn;b3=go;if screen_2 then screen_2.setHTML(''..b1)local cg=vec3(core.getConstructWorldPos())local bY=960+cg.x/gn;local bZ=540+cg.y/go;b1=''b1=b1 .."You Are Here"b4=screen_2.addContent((bY-80)/19.20,(bZ-80)/10.80,b1)end end;function PlanetRef()local function gp(gq)return type(gq)=='number'end;local function gr(gq)return type(tonumber(gq))=='number'end;local function gs(gt)return type(gt)=='table'end;local function gu(gv)return type(gv)=='string'end;local function gw(bC)return gs(bC)and gp(bC.x and bC.y and bC.z)end;local function gx(gy)return gs(gy)and gp(gy.latitude and gy.longitude and gy.altitude and gy.bodyId and gy.systemId)end;local gz=math.pi/180;local gA=180/math.pi;local epsilon=1e-10;local q=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local ch='::pos{'..q..','..q..','..q..','..q..','..q..'}'local utils=require('cpml.utils')local vec3=require('cpml.vec3')local gB=utils.clamp;local function float_eq(c6,c7)if c6==0 then return math.abs(c7)<1e-09 end;if c7==0 then return math.abs(c6)<1e-09 end;return math.abs(c6-c7)=0 then local hp=math.sqrt(ho)local fg=hn+hp;local fh=hn-hp;if fh>0 then return fi,fg,fh elseif fg>0 then return fi,fg,nil end end end;return nil,nil,nil end;function gS:closestBody(hq)assert(type(hq)=='table','Invalid coordinates.')local hr,fi;local hs=vec3(hq)for _,ht in pairs(self)do local hu=(ht.center-hs):len2()if(not fi or hu=0 and cf or 2*math.pi+cf;cd=math.pi/2-math.acos(cb.z/ac)end;return setmetatable({latitude=cd,longitude=ce,altitude=cc,bodyId=self.bodyId,systemId=self.planetarySystemId},MapPosition)end;function gH:convertToWorldCoordinates(gR)local hv=gu(gR)and gQ(gR)or gR;if hv.bodyId==0 then return vec3(hv.latitude,hv.longitude,hv.altitude)end;assert(gx(hv),'Argument 1 (mapPosition) is not an instance of "MapPosition".')assert(hv.systemId==self.planetarySystemId,'Argument 1 (mapPosition) has a different planetary system ID.')assert(hv.bodyId==self.bodyId,'Argument 1 (mapPosition) has a different planetary body ID.')local ck=math.cos(hv.latitude)return self.center+(self.radius+hv.altitude)*vec3(ck*math.cos(hv.longitude),ck*math.sin(hv.longitude),math.sin(hv.latitude))end;function gH:getAltitude(c9)return(vec3(c9)-self.center):len()-self.radius end;function gH:getDistance(c9)return(vec3(c9)-self.center):len()end;function gH:getGravity(c9)local hw=self.center-vec3(c9)local hx=hw:len2()return self.GM/hx*hw/math.sqrt(hx)end;return setmetatable(b5,{__call=function(_,...)return g_(...)end})end;function Keplers()local vec3=require('cpml.vec3')local PlanetRef=PlanetRef()local function gu(gv)return type(gv)=='string'end;local function gs(gt)return type(gt)=='table'end;local function float_eq(c6,c7)if c6==0 then return math.abs(c7)<1e-09 end;if c7==0 then return math.abs(c6)<1e-09 end;return math.abs(c6-c7)0 then hO=hN;hP=hO+hI/2 end;if hP>hI then hP=hP-hI end end;return{periapsis={position=hF,speed=hH/hD,circularOrbitSpeed=math.sqrt(hA/hD),altitude=hD-self.body.radius},apoapsis=hG and{position=hG,speed=hH/hE,circularOrbitSpeed=math.sqrt(hA/hE),altitude=hE-self.body.radius},currentVelocity=bC,currentPosition=cg,eccentricity=hC,period=hI,eccentricAnomaly=hK,meanAnomaly=hM,timeToPeriapsis=hO,timeToApoapsis=hP}end;local function hQ(hR)local ht=PlanetRef.BodyParameters(hR.planetarySystemId,hR.bodyId,hR.radius,hR.center,hR.GM)return setmetatable({body=ht},Kepler)end;return setmetatable(Kepler,{__call=function(_,...)return hQ(...)end})end;function Kinematics()local b7={}local hS=30000000/3600;local hT=hS*hS;local hU=100;local function hV(bC)return 1/math.sqrt(1-bC*bC/hT)end;function b7.computeAccelerationTime(hW,hX,hY)local hZ=hS*math.asin(hW/hS)return(hS*math.asin(hY/hS)-hZ)/hX end;function b7.computeDistanceAndTime(hW,hY,h_,i0,i1,i2)i1=i1 or 0;i2=i2 or 0;local i3=hW<=hY;local i4=i0*(i3 and 1 or-1)/h_;local i5=-i2/h_;local i6=i4+i5;if i3 and i6<=0 or not i3 and i6>=0 then return-1,-1 end;local i7,i8=0,0;if i4~=0 and i1>0 then local hZ=math.asin(hW/hS)local i9=math.pi*(i4/2+i5)local ia=i4*i1;local ib=hS*math.pi;local bC=function(gt)local cV=(i9*gt-ia*math.sin(math.pi*gt/2/i1)+ib*hZ)/ib;local ic=math.tan(cV)return hS*ic/math.sqrt(ic*ic+1)end;local id=i3 and function(gv)return gv>=hY end or function(gv)return gv<=hY end;i8=2*i1;if id(bC(i8))then local ie=0;while math.abs(i8-ie)>0.5 do local gt=(i8+ie)/2;if id(bC(gt))then i8=gt else ie=gt end end end;local ig=hW;local ih=i8/hU;for ii=1,hU do local bS=bC(ii*ih)i7=i7+(bS+ig)*ih/2;ig=bS end;if i8<2*i1 then return i7,i8 end;hW=ig end;local hZ=hS*math.asin(hW/hS)local bE=(hS*math.asin(hY/hS)-hZ)/i6;local ij=hT*math.cos(hZ/hS)/i6;local ac=ij-hT*math.cos((i6*bE+hZ)/hS)/i6;return ac+i7,bE+i8 end;function b7.computeTravelTime(hW,hX,ac)if ac==0 then return 0 end;if hX>0 then local hZ=hS*math.asin(hW/hS)local ij=hT*math.cos(hZ/hS)/hX;return(hS*math.acos(hX*(ij-ac)/hT)-hZ)/hX end;if hW==0 then return-1 end;assert(hW>0,'Acceleration and initial speed are both zero.')return ac/hW end;function b7.lorentz(bC)return hV(bC)end;return b7 end;function safeZone(ik)local gN=500000;local il,im,io=math.huge;local ip=false;local iq=vec3({13771471,7435803,-128971})local ir=18000000;il=vec3(ik):dist(iq)if il0 or bN==0 and an<10000)then for _,bC in pairs(door)do bC.toggle()end end;if switch then for _,bC in pairs(switch)do bC.toggle()end end;if forcefield and(bN>0 or bN==0 and an<10000)then for _,bC in pairs(forcefield)do bC.toggle()end end;SaveDataBank()if button then button.activate()end end;local function it(ee,iu)if iu==nil then iu=false end;if Nav.axisCommandManager:getAxisCommandType(0)~=axisCommandType.byThrottle and not iu then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,ee)end;local function iv(ee,iu)if iu==nil then iu=false end;if Nav.axisCommandManager:getAxisCommandType(0)~=axisCommandType.byTargetSpeed and not iu then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setTargetSpeedCommand(axisCommandId.longitudinal,ee)end;function script.onTick(iw)if iw=="tenthSecond"then if j()>0 and not WasInAtmo then if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and AtmoSpeedAssist and(AltitudeHold or Reentry)then z=1;Nav.control.cancelCurrentControlMasterMode()D=false end end;if AutopilotTargetName~="None"then if panelInterplanetary==nil then SetupInterplanetaryPanel()end;if AutopilotTargetName~=nil then local ix=CustomTarget~=nil;planetMaxMass=GetAutopilotMaxMass()system.updateData(interplanetaryHeaderText,'{"label": "Target", "value": "'..AutopilotTargetName..'", "unit":""}')travelTime=GetAutopilotTravelTime()if ix and not Autopilot then ac=(vec3(core.getConstructWorldPos())-CustomTarget.position):len()else ac=(AutopilotTargetCoords-vec3(core.getConstructWorldPos())):len()end;if not TurnBurn then a0,a1=GetAutopilotBrakeDistanceAndTime(be)a2,a3=GetAutopilotBrakeDistanceAndTime(MaxGameVelocity)else a0,a1=GetAutopilotTBBrakeDistanceAndTime(be)a2,a3=GetAutopilotTBBrakeDistanceAndTime(MaxGameVelocity)end;local dy,dz=getDistanceDisplayString(ac)system.updateData(widgetDistanceText,'{"label": "distance", "value": "'..dy..'", "unit":"'..dz..'"}')system.updateData(widgetTravelTimeText,'{"label": "Travel Time", "value": "'..FormatTimeString(travelTime)..'", "unit":""}')dy,dz=getDistanceDisplayString(a0)system.updateData(widgetCurBrakeDistanceText,'{"label": "Cur Brake distance", "value": "'..dy..'", "unit":"'..dz..'"}')system.updateData(widgetCurBrakeTimeText,'{"label": "Cur Brake Time", "value": "'..FormatTimeString(a1)..'", "unit":""}')dy,dz=getDistanceDisplayString(a2)system.updateData(widgetMaxBrakeDistanceText,'{"label": "Max Brake distance", "value": "'..dy..'", "unit":"'..dz..'"}')system.updateData(widgetMaxBrakeTimeText,'{"label": "Max Brake Time", "value": "'..FormatTimeString(a3)..'", "unit":""}')system.updateData(widgetMaxMassText,'{"label": "Maximum Mass", "value": "'..e("%.2f",planetMaxMass/1000)..'", "unit":" Tons"}')dy,dz=getDistanceDisplayString(AutopilotTargetOrbit)system.updateData(widgetTargetOrbitText,'{"label": "Target Orbit", "value": "'..e("%.2f",dy)..'", "unit":"'..dz..'"}')if j()>0 and not WasInAtmo then system.removeDataFromWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)system.removeDataFromWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)system.removeDataFromWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)system.removeDataFromWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)system.removeDataFromWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)WasInAtmo=true end;if j()==0 and WasInAtmo then if system.updateData(widgetMaxBrakeTimeText,widgetMaxBrakeTime)==1 then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;if system.updateData(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)==1 then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;if system.updateData(widgetCurBrakeTimeText,widgetCurBrakeTime)==1 then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;if system.updateData(widgetCurBrakeDistanceText,widgetCurBrakeDistance)==1 then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;if system.updateData(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)==1 then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end;WasInAtmo=false end end else HideInterplanetaryPanel()end;if warpdrive~=nil then if f(warpdrive.getData()).destination~="Unknown"and f(warpdrive.getData()).distance>400000 then warpdrive.show()showWarpWidget=true else warpdrive.hide()showWarpWidget=false end end elseif iw=="oneSecond"then ak=false;RefreshLastMaxBrake(nil,true)updateDistance()updateRadar()updateWeapons()local ct={}local dK=GetFlightStyle()DrawOdometer(ct,a5,TotalDistanceTravelled,dK,a6)if ShouldCheckDamage then CheckDamage(ct)end;ae=table.concat(ct,"")collectgarbage("collect")elseif iw=="fiveSecond"then al=dbHud_1.getStringValue("SPBAutopilotTargetName")if al~=nil and al~=""and al~="SatNavNotChanged"then local bD=json.decode(dbHud_1.getStringValue("SavedLocations"))if bD~=nil then _G["SavedLocations"]=bD;local cr=-1;local cn;for bB,bC in pairs(SavedLocations)do if bC.name and bC.name=="SatNav Location"then cr=bB;break end end;if cr~=-1 then cn=SavedLocations[cr]cr=-1;for bB,bC in pairs(b0[0])do if bC.name and bC.name=="SatNav Location"then cr=bB;break end end;if cr>-1 then b0[0][cr]=cn end;UpdateAtlasLocationsList()W=cn.name.." position updated"end end;for i=1,#AtlasOrdered do if AtlasOrdered[i].name==al then AutopilotTargetIndex=i;system.print("Index = "..AutopilotTargetIndex.." "..AtlasOrdered[i].name)UpdateAutopilotTarget()dbHud_1.setStringValue("SPBAutopilotTargetName","SatNavNotChanged")break end end end elseif iw=="msgTick"then local ct={}DisplayMessage(ct,"empty")W="empty"unit.stopTimer("msgTick")ab=3 elseif iw=="animateTick"then bb=true;ba=false;a9=0;aa=0;unit.stopTimer("animateTick")elseif iw=="hudTick"then local ct={}HUDPrologue(ct)if showHud then UpdateHud(ct)else DisplayOrbitScreen(ct)DrawWarnings(ct)end;HUDEpilogue(ct)ct[#ct+1]=e([[]],ResolutionX,ResolutionY)if W~="empty"then DisplayMessage(ct,W)end;if o()==0 and userControlScheme=="virtual joystick"then if DisplayDeadZone then DrawDeadZone(ct)end end;if o()==1 and screen_1 and screen_1.getMouseY()~=-1 then SetButtonContains()DrawButtons(ct)if screen_1.getMouseState()==1 then CheckButtons()end;ct[#ct+1]=e([[]],E,F,a9,aa)elseif system.isViewLocked()==0 then if o()==1 and V then SetButtonContains()DrawButtons(ct)if not ba and not bb then local iy=table.concat(ct,"")ct={}ct[#ct+1]=e("",ResolutionX,ResolutionY)ct[#ct+1]=b1;ct[#ct+1]=iy;ct[#ct+1]=""ba=true;ct[#ct+1]=[[]]unit.setTimer("animateTick",0.5)local content=table.concat(ct,"")system.setScreen(content)elseif bb then local iy=table.concat(ct,"")ct={}ct[#ct+1]=e("",ResolutionX,ResolutionY)ct[#ct+1]=b1;ct[#ct+1]=iy;ct[#ct+1]=""end;if not ba then ct[#ct+1]=e([[]],E,F,a9,aa)end else CheckButtons()end else if not V and o()==0 then CheckButtons()if ac>DeadZone then if DisplayDeadZone then DrawCursorLine(ct)end end else SetButtonContains()DrawButtons(ct)end;ct[#ct+1]=e([[]],E,F,a9,aa)end;ct[#ct+1]=[[]]content=table.concat(ct,"")if not DidLogOutput then system.logInfo(LastContent)DidLogOutput=true end elseif iw=="apTick"then am=j()>0;local bE=system.getTime()local iz=bE-bj;bj=bE;local cw=vec3(core.getConstructWorldOrientationForward())local cx=vec3(core.getConstructWorldOrientationRight())local iA=vec3(core.getConstructWorldOrientationUp())local cy=vec3(core.getWorldVertical())local iB=vec3(core.getConstructWorldPos())local dM=getRoll(cy,cw,cx)local dN=dM/180*math.pi;local dO=math.cos(dN)local dP=math.sin(dN)local cz=getPitch(cy,cw,cx)local iC=getPitch(cy,cw,cx*dO+iA*dP)local iD=-math.deg(cQ(iA,bd,cw))local iE=math.deg(cQ(cx,bd,cw))bi=am and iD<-YawStallAngle or iD>YawStallAngle or iE<-PitchStallAngle or iE>PitchStallAngle;bg=system.getMouseDeltaX()bh=system.getMouseDeltaY()if InvertMouse and not V then bh=-bh end;P=0;T=0;O=0;bd=vec3(core.getWorldVelocity())be=vec3(bd):len()sys=b6[0]planet=sys:closestBody(core.getConstructWorldPos())kepPlanet=b9(planet)orbit=kepPlanet:orbitalParameters(core.getConstructWorldPos(),bd)aj=hoverDetectGround()local bP=planet:getGravity(core.getConstructWorldPos()):len()*n()bk=0;b8=core.getMaxKinematicsParametersAlongAxis("ground",core.getConstructOrientationUp())[1]w,x,y,_=safeZone(iB)if o()==1 and screen_1 and screen_1.getMouseY()~=-1 then a9=screen_1.getMouseX()*ResolutionX;aa=screen_1.getMouseY()*ResolutionY elseif system.isViewLocked()==0 then if o()==1 and V then if not ba then a9=a9+bg;aa=aa+bh end else a9=0;aa=0 end else a9=a9+bg;aa=aa+bh;ac=math.sqrt(a9*a9+aa*aa)if not V and o()==0 then if userControlScheme=="virtual joystick"then if a9>0 and a9>DeadZone then P=P-(a9-DeadZone)*MouseXSensitivity elseif a9<0 and a90 and aa>DeadZone then O=O-(aa-DeadZone)*MouseYSensitivity elseif aa<0 and aa8334;if be>SpaceSpeedLimit/3.6 and not am and not Autopilot and not iF then W="Space Speed Engine Shutoff reached"if Nav.axisCommandManager:getAxisCommandType(0)==1 then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)z=0 end;if not iF and LastIsWarping then if not BrakeIsOn then BrakeToggle()end;if Autopilot then ToggleAutopilot()end end;LastIsWarping=iF;if am and j()>0.09 then if be>bm/3.6 and not AtmoSpeedAssist and not ar then BrakeIsOn=true;ar=true elseif not AtmoSpeedAssist and ar then if be85)and be>=bm/3.6-1 then BrakeIsOn=false;ProgradeIsOn=false;J=true;ag=false;ai=true;Autopilot=false;BeginReentry()else iv(math.floor(bm))z=0 end elseif be>I then AlignToWorldVector(vec3(bd),0.01)end end;if RetrogradeIsOn then if am then RetrogradeIsOn=false elseif be>I then AlignToWorldVector(-vec3(bd))end end;if not ProgradeIsOn and ag then if j()==0 then J=true;BeginReentry()ag=false;ai=true else ag=false;ToggleAutopilot()end end;local ei=vec3(core.getWorldVertical())*-1;local eg=bd.x*ei.x+bd.y*ei.y+bd.z*ei.z;if ai and CustomTarget~=nil and(anHoldAltitude-200)and be*3.6>bm-100 and math.abs(eg)<20 and j()>=0.1 and(CustomTarget.position-iB):len()>2000+an then ToggleAutopilot()ai=false end;if VertTakeOff then bc=true;if eg<-30 then W="Unable to achieve lift. Safety Landing."a8=0;bc=autoRollPreference;VertTakeOff=false;BrakeLanding=true elseif antigrav and not ExternalAGG and antigrav.getState()==1 then if an0 then BrakeIsOn=true;a8=0 elseif eg<-30 then BrakeIsOn=true;a8=15 elseif an>=antigrav.getBaseAltitude()then BrakeIsOn=true;a8=0;VertTakeOff=false;W="Takeoff complete. Singularity engaged"end else if j()>0.08 then bn=0;BrakeIsOn=false;a8=20 elseif j()<0.08 and j()>0 then BrakeIsOn=false;if bz then bn=0;a8=20 else a8=0;bn=36;iv(3500)end else bc=autoRollPreference;IntoOrbit=true;bx=false;CancelIntoOrbit=false;br=false;bp=nil;bq=nil;if bw==nil then bw=planet end;VertTakeOff=false end end;if bn~=nil then if vTpitchPID==nil then vTpitchPID=pid.new(2*0.01,0,2*0.1)end;local iH=utils.clamp(bn-iC,-PitchStallAngle*0.85,PitchStallAngle*0.85)vTpitchPID:inject(iH)local iI=utils.clamp(vTpitchPID:get(),-1,1)O=iI end end;if IntoOrbit then if bw==nil then if VectorToTarget then bw=a4 else bw=planet end end;if not bu then if bw.hasAtmosphere then bv=math.floor(bw.radius*(TargetOrbitRadius-1)+bw.noAtmosphericDensityAltitude)else bv=math.floor(bw.radius*(TargetOrbitRadius-1)+bw.surfaceMaxAltitude)end;bu=true end;if AltitudeHold or VectorToTarget then if not ah then bv=HoldAltitude;br=true;AltitudeHold=false end;if VectorToTarget then bt.VectorToTarget=VectorToTarget;VectorToTarget=false end end;local iJ,iK=b9(bw):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-bw.center):len()-bw.radius)local iL=dM;if orbit.periapsis~=nil and orbit.eccentricity<1 and an>bv and an=iN-3 then z=ee;it(ee)else z=0.05;it(0.05)end end;if orbit.apoapsis~=nil then if orbit.periapsis.altitude>bv*0.95 and orbit.periapsis.altitudeorbit.periapsis.altitude and orbit.apoapsis.altitude<=orbit.periapsis.altitude*1.35 then BrakeIsOn=false;z=0;it(0)bx=true;if iC>2 or iC<-2 then bp=0 else bo=nil;bs=false;bu=false;bw=nil;bc=autoRollPreference;W="Orbit established"if bt.VectorToTarget then VectorToTarget=bt.VectorToTarget end;bt.VectorToTarget=false;CancelIntoOrbit=false;IntoOrbit=false;br=false;bp=nil;bq=nil;bw=nil end else bo="Adjusting Orbit"bs=true;if eg>125 then iM(0.5,-65)BrakeIsOn=false elseif orbit.periapsis.altitude<0 then if be+10>iK then if eg>5 then iM(0.5,-65)BrakeIsOn=false elseif eg<-5 then iM(0.5,65)BrakeIsOn=false else it(0)BrakeIsOn=not BrakeIsOn end elseif be-100 and orbit.periapsis.altitudeiK then it(0)BrakeIsOn=not BrakeIsOn elseif be+20>iK then if eg>35 then iM(0.5,-80)BrakeIsOn=false elseif eg<-35 then iM(0.5,80)BrakeIsOn=false end elseif be-20orbit.periapsis.altitude*1.3 then it(0)BrakeIsOn=not BrakeIsOn end end end end else local iO=2.75;local iP=math.abs(utils.round(iJ*iO))local iQ=iP%50;if iQ>0 then iP=iP-iQ+50 end;BrakeIsOn=false;if not br then local iR=false;local iS=false;if an=bp-1 then iR=true else iR=false end;if iL<=bq+1 and iL>=bq-1 then iS=true else iS=false end;if iR and iS then bp=nil;bq=nil;br=true end else if an=bv*0.8 and an=bv*1.15 and anbv*1.5 then bo="Reentering orbital corridor"if eg<-100 then bp=45;iP=iP*1.25 else bp=-80;iP=iP*0.75 end end end;iv(math.floor(iP))end;if bp~=nil then if OrbitPitchPID==nil then OrbitPitchPID=pid.new(2*0.01,0,2*0.1)end;local iT=bp-iC;OrbitPitchPID:inject(iT)local iU=utils.clamp(OrbitPitchPID:get(),-0.5,0.5)O=iU end;if bq~=nil then if iC<85 then local iV=math.max(autoRollFactor,0.01)/4;if OrbitRollPID==nil then OrbitRollPID=pid.new(iV*0.01,0,iV*0.1)end;local iW=bq-iL;OrbitRollPID:inject(iW)local iX=utils.clamp(OrbitRollPID:get(),-0.5,0.5)T=iX end end elseif CancelIntoOrbit then bu=false;bw=nil;it(0)CancelIntoOrbit=false end;if Autopilot and j()==0 and not ag then local iY,iZ=AutopilotTargetCoords,false;if CustomTarget~=nil and CustomTarget.planetname~="Space"then AutopilotRealigned=true;if not TargetSet then local i_=(CustomTarget.position-a4.center):normalize()local j0=i_:project_on_plane((a4.center-iB):normalize()):normalize()local j1=a4.center+j0*(a4.radius+AutopilotTargetOrbit)local j2=CustomTarget.position+(CustomTarget.position-a4.center):normalize()*(AutopilotTargetOrbit-a4:getAltitude(CustomTarget.position))if(iB-j1):len()<(iB-j2):len()then iY=j1;AutopilotTargetCoords=iY else iY=CustomTarget.position+(CustomTarget.position-a4.center):normalize()*(AutopilotTargetOrbit-a4:getAltitude(CustomTarget.position))AutopilotTargetCoords=iY end;local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)iZ=true;TargetSet=true end;AutopilotPlanetGravity=0 elseif CustomTarget~=nil and CustomTarget.planetname=="Space"then AutopilotPlanetGravity=0;iZ=true;TargetSet=true;AutopilotRealigned=true;iY=CustomTarget.position+(iB-CustomTarget.position)*AutopilotTargetOrbit elseif CustomTarget==nil then AutopilotPlanetGravity=0;if not TargetSet then local i_=(iB+bd*100000-a4.center):normalize()local j0=i_:project_on_plane((a4.center-iB):normalize()):normalize()if j0:len()<1 then i_=(iB+vec3(core.getConstructWorldOrientationForward())*100000-a4.center):normalize()j0=i_:project_on_plane((a4.center-iB):normalize()):normalize()end;iY=a4.center+j0*(a4.radius+AutopilotTargetOrbit)AutopilotTargetCoords=iY;TargetSet=true;iZ=true;AutopilotRealigned=true;local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)end end;AutopilotDistance=(vec3(iY)-vec3(core.getConstructWorldPos())):len()local ff,fg,fh=b6:getPlanetarySystem(0):castIntersections(iB,bd:normalize(),function(fi)if fi.noAtmosphericDensityAltitude>0 then return fi.radius+fi.noAtmosphericDensityAltitude else return fi.radius+fi.surfaceMaxAltitude*1.5 end end)local fj=fg;if fh~=nil and fg~=nil then fj=math.min(fh,fg)end;if fj~=nil and fj300 and AutopilotAccelerating then local dv=vec3(iY)-vec3(core.getConstructWorldPos())local j4=utils.clamp(math.deg(cQ(iA,bd:normalize(),dv:normalize()))*be/500,-90,90)local j5=utils.clamp(math.deg(cQ(cx,bd:normalize(),dv:normalize()))*be/500,-90,90)if math.abs(j4)<20 and math.abs(j5)<20 then j4=j4*2;j5=j5*2 end;if math.abs(j4)<2 and math.abs(j5)<2 then j4=j4*2;j5=j5*2 end;local iD=-math.deg(cQ(iA,cw,bd:normalize()))local iE=-math.deg(cQ(cx,cw,bd:normalize()))if apPitchPID==nil then apPitchPID=pid.new(2*0.01,0,2*0.1)end;apPitchPID:inject(j5-iE)local j6=utils.clamp(apPitchPID:get(),-1,1)O=O+j6;if apYawPID==nil then apYawPID=pid.new(2*0.01,0,2*0.1)end;apYawPID:inject(j4-iD)local j7=utils.clamp(apYawPID:get(),-1,1)P=P+j7;iZ=true;if math.abs(j4)>2 or math.abs(j5)>2 then AutopilotStatus="Adjusting Trajectory"else AutopilotStatus="Accelerating"end end;if j3=MaxGameVelocity or fH==0 and G then AutopilotAccelerating=false;AutopilotStatus="Cruising"AutopilotCruising=true;it(0)z=0 end;if AutopilotDistance<=a0 then AutopilotAccelerating=false;AutopilotStatus="Braking"AutopilotBraking=true;it(0)z=0;G=false end elseif AutopilotBraking then if AutopilotStatus~="Orbiting to Target"then BrakeIsOn=true;S=1 end;if TurnBurn then it(100,true)z=1 end;local _,iK=b9(a4):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-planet.center):len()-planet.radius)local dv;if CustomTarget~=nil then dv=CustomTarget.position-iB end;if CustomTarget~=nil and CustomTarget.planetname=="Space"and be<50 then W="Autopilot complete, arrived at space location"AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"elseif CustomTarget~=nil and CustomTarget.planetname~="Space"and be<=iK and(orbit.apoapsis==nil or orbit.periapsis==nil or orbit.apoapsis.altitude<=0 or orbit.periapsis.altitude<=0)then W="Autopilot complete, proceeding with reentry"AutopilotTargetCoords=CustomTarget.position;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"it(0)z=0;G=false;ProgradeIsOn=true;ag=true;local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)elseif orbit.periapsis~=nil and orbit.periapsis.altitude>0 and orbit.eccentricity<1 then AutopilotStatus="Circularizing"local _,iK=b9(a4):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-planet.center):len()-planet.radius)if be<=iK then if CustomTarget~=nil then if bd:normalize():dot(dv:normalize())>0.4 then AutopilotStatus="Orbiting to Target"if not WaypointSet then BrakeIsOn=false;local cA=zeroConvertToMapPosition(a4,CustomTarget.position)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)WaypointSet=true end else W="Autopilot complete, proceeding with reentry"AutopilotTargetCoords=CustomTarget.position;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"it(0)z=0;G=false;ProgradeIsOn=true;ag=true;BrakeIsOn=false;local cA=zeroConvertToMapPosition(a4,CustomTarget.position)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)WaypointSet=false end else BrakeIsOn=false;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"W="Autopilot completed, orbit established"S=0;z=0;G=false;if CustomTarget~=nil and CustomTarget.planetname~="Space"then ProgradeIsOn=true;ag=true end end end end elseif AutopilotCruising then if AutopilotDistance<=a0 then AutopilotAccelerating=false;AutopilotStatus="Braking"AutopilotBraking=true end;local fH=unit.getThrottle()if AtmoSpeedAssist then fH=z end;if fH>0 then AutopilotAccelerating=true;AutopilotStatus="Accelerating"AutopilotCruising=false end else if iG then if not AutopilotRealigned and CustomTarget==nil or not AutopilotRealigned and CustomTarget~=nil and CustomTarget.planetname~="Space"then if not ag then AutopilotTargetCoords=vec3(a4.center)+(AutopilotTargetOrbit+a4.radius)*vec3(core.getConstructWorldOrientationRight())AutopilotShipUp=core.getConstructWorldOrientationUp()AutopilotShipRight=core.getConstructWorldOrientationRight()end;AutopilotRealigned=true elseif iG then AutopilotAccelerating=true;AutopilotStatus="Accelerating"if not G then it(AutopilotInterplanetaryThrottle,true)z=round(AutopilotInterplanetaryThrottle,2)G=true;BrakeIsOn=false end end end end elseif Autopilot and(CustomTarget~=nil and CustomTarget.planetname~="Space"and j()>0)then W="Autopilot complete, proceeding with reentry"AutopilotTargetCoords=CustomTarget.position;BrakeIsOn=false;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"S=0;it(0)z=0;G=false;ProgradeIsOn=true;ag=true;local cA=zeroConvertToMapPosition(a4,CustomTarget.position)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)end;if U then bc=true;local j5=0;local cg=vec3(core.getConstructWorldPos())+vec3(unit.getMasterPlayerRelativePosition())local j8=cg-vec3(core.getConstructWorldPos())local j9=vec3(j8):project_on(vec3(core.getConstructWorldOrientationForward())):len()local ja=vec3(j8):project_on(vec3(core.getConstructWorldOrientationRight())):len()local ac=math.sqrt(j9*j9+ja*ja)AlignToWorldVector(j8:normalize())local jb=40;local jc=acje then if pitchPID==nil then pitchPID=pid.new(2*0.01,0,2*0.1)end;pitchPID:inject(j5-cz)local j6=pitchPID:get()O=j6 end end;if AltitudeHold or BrakeLanding or Reentry or VectorToTarget or LockPitch~=nil then local cB=unit.getClosestPlanetInfluence()>0;local jf=HoldAltitude-an;local jg=500+be;local jh=1;if AutoTakeoff then jh=utils.clamp(be/100,0.1,1)end;local j5=(utils.smoothstep(jf,-jg,jg)-0.5)*2*MaxPitch*jh;if not Reentry and not ag and not VectorToTarget and cw:dot(bd:normalize())<0.99 then j5=(utils.smoothstep(jf,-jg*utils.clamp(20-19*j()*10,1,20),jg*utils.clamp(20-19*j()*10,1,20))-0.5)*2*MaxPitch*utils.clamp(2-j()*10,1,2)*jh end;if not AltitudeHold then j5=0 end;if LockPitch~=nil then if cB and not IntoOrbit then j5=LockPitch else LockPitch=nil end end;bc=true;local ji=O;if Reentry then local ReentrySpeed=math.floor(bm)local jj,jk=b7.computeDistanceAndTime(be,ReentrySpeed/3.6,n(),0,0,LastMaxBrake-planet.gravity*9.8*n())local jl=an-(planet.noAtmosphericDensityAltitude+5000)if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and an>planet.noAtmosphericDensityAltitude+5000 and be<=ReentrySpeed/3.6 and be>ReentrySpeed/3.6-10 and math.abs(bd:normalize():dot(cw))>0.9 then Nav.control.cancelCurrentControlMasterMode()z=0 elseif Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byThrottle and(jj>-1 and jl<=jj or an<=planet.noAtmosphericDensityAltitude+5000)then BrakeIsOn=true else BrakeIsOn=false end;iv(ReentrySpeed,true)if not J then j5=-80;if j()>0.02 then W="PARACHUTE DEPLOYED"Reentry=false;BrakeLanding=true;j5=0;bc=autoRollPreference end elseif planet.noAtmosphericDensityAltitude>0 and an>planet.noAtmosphericDensityAltitude+5000 then bc=true elseif an<=planet.noAtmosphericDensityAltitude+5000 then iv(ReentrySpeed)if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)==bm then J=false;Reentry=false;bc=true end end end;if be>I and not ah and not VectorToTarget and not BrakeLanding and ForceAlignment then AlignToWorldVector(vec3(bd))end;if(VectorToTarget or ah)and AutopilotTargetIndex>0 and j()>0.01 then local dv;if CustomTarget~=nil then dv=CustomTarget.position-vec3(core.getConstructWorldPos())else dv=a4.center-iB end;local j4=math.deg(cQ(cy:normalize(),bd,dv))*2;local jm=math.rad(math.abs(dM))if be>minRollVelocity and j()>0.01 then local jn=utils.clamp(90-j5*2,-90,90)bk=utils.clamp(j4*2,-jn,jn)local jo=j4;j4=utils.clamp(utils.clamp(j4,-YawStallAngle*0.85,YawStallAngle*0.85)*math.cos(jm)+4*(iC-j5)*math.sin(math.rad(dM)),-YawStallAngle*0.85,YawStallAngle*0.85)j5=utils.clamp(utils.clamp(j5*math.cos(jm),-PitchStallAngle*0.85,PitchStallAngle*0.85)+math.abs(utils.clamp(math.abs(jo)*math.sin(jm),-PitchStallAngle*0.85,PitchStallAngle*0.85)),-PitchStallAngle*0.85,PitchStallAngle*0.85)else bk=0;j4=utils.clamp(j4,-YawStallAngle*0.85,YawStallAngle*0.85)end;local jp=iD-j4;if not bi and be>minRollVelocity and j()>0.01 then if yawPID==nil then yawPID=pid.new(2*0.01,0,2*0.1)end;yawPID:inject(jp)local j7=utils.clamp(yawPID:get(),-1,1)P=P+j7 elseif am and aj>-1 or be0.01 then if(iD<-YawStallAngle or iD>YawStallAngle)and j()>0.01 then AlignToWorldVector(bd)end;if(iE<-PitchStallAngle or iE>PitchStallAngle)and j()>0.01 then j5=utils.clamp(iC-iE,iC-PitchStallAngle*0.85,iC+PitchStallAngle*0.85)end end;if CustomTarget~=nil and not ah then local jq=planet:getAltitude(CustomTarget.position)local jl=math.sqrt(dv:len()^2-(an-jq)^2)local jr=LastMaxBrakeInAtmo;if jr then jr=jr*utils.clamp(be/100,0.1,1)*j()else jr=LastMaxBrake end;if j()<0.01 then jr=LastMaxBrake end;local js=bd:len()-math.abs(eg)local jt=vec3(core.getWorldAirFrictionAcceleration())local ju=math.sqrt(jt:len()-jt:project_on(ei):len())*n()if be>100 then a0,a1=b7.computeDistanceAndTime(be,100,n(),0,0,jr+ju)local jv,jw=b7.computeDistanceAndTime(100,0,n(),0,0,jr/2)a0=a0+jv else a0,a1=b7.computeDistanceAndTime(be,0,n(),0,0,jr/2)end;StrongBrakes=true;if not ah and not Reentry and jl<=a0+be*iz/2 and(bd:project_on_plane(cy):normalize():dot(dv:project_on_plane(cy):normalize())>0.99 or VectorStatus=="Finalizing Approach")then VectorStatus="Finalizing Approach"it(0)z=0;if AltitudeHold then ToggleAltitudeHold()VectorToTarget=true end;BrakeIsOn=true elseif not AutoTakeoff then BrakeIsOn=false end;if VectorStatus=="Finalizing Approach"and(js<0.1 or jl<0.1 or LastDistanceToTarget~=nil and LastDistanceToTargetplanet.noAtmosphericDensityAltitude and not(ah or Reentry)then if CustomTarget~=nil and a4.name==planet.name then local dv=CustomTarget.position-vec3(core.getConstructWorldPos())local jq=planet:getAltitude(CustomTarget.position)local jl=math.sqrt(dv:len()^2-(an-jq)^2)local jr=LastMaxBrakeInAtmo;if not bx and jl>100000 then bu=false;IntoOrbit=true else jr=LastMaxBrake;a0,a1=b7.computeDistanceAndTime(be,0,n(),0,0,jr/2)StrongBrakes=true;if jl<=a0+be*iz/2 and bd:project_on_plane(cy):normalize():dot(dv:project_on_plane(cy):normalize())>0.99 then if planet.hasAtmosphere then BrakeIsOn=false;ProgradeIsOn=false;J=true;ag=false;ai=true;Autopilot=false;BeginReentry()end end;LastDistanceToTarget=jl end end end;if j()==0 and(AltitudeHold and HoldAltitude>planet.noAtmosphericDensityAltitude)and not(ah or VectorToTarget or IntoOrbit or Reentry)then if not bx then IntoOrbit=true end end;if bi and j()>0.01 and aj==-1 and be>minRollVelocity and VectorStatus~="Finalizing Approach"then AlignToWorldVector(bd)j5=utils.clamp(iC-iE,iC-PitchStallAngle*0.85,iC+PitchStallAngle*0.85)end;O=ji;local fQ=-1;if BrakeLanding then j5=0;local jx=false;local jy=30;if b8~=nil and b8>0 then local ju=0;local dS=utils.clamp(j(),0.4,2)local jr=LastMaxBrakeInAtmo*utils.clamp(be/100,0.1,1)*dS;local jz=b8*dS+jr+ju-bP;local jA=jr/2+ju-bP;local jB=be-math.sqrt(math.abs(jA/2)*20/(0.5*n()))*utils.sign(jA)if jB<0 then jB=0 end;local jC;if be>100 then local jD,_=b7.computeDistanceAndTime(be,100,n(),0,0,jr)local jE,_=b7.computeDistanceAndTime(100,0,n(),0,0,math.sqrt(jr))jC=jD+jE else jC=b7.computeDistanceAndTime(be,0,n(),0,0,math.sqrt(jr))end;if jC<20 then BrakeIsOn=false else local jF=0;if jB>100 then local jG,_=b7.computeDistanceAndTime(jB,100,n(),0,0,jz)local jH,_=b7.computeDistanceAndTime(100,0,n(),0,0,b8*dS+math.sqrt(jr)+ju-bP)jF=jG+jH else jF,_=b7.computeDistanceAndTime(jB,0,n(),0,0,b8*dS+math.sqrt(jr)+ju-bP)end;jF=(jF+15+be*iz)*1.1;local jI=CustomTarget~=nil and planet:getAltitude(CustomTarget.position)>0 and CustomTarget.safe;if jI then local jq=planet:getAltitude(CustomTarget.position)local jJ=an-jq-100;local dv=CustomTarget.position-vec3(core.getConstructWorldPos())local jK=math.sqrt(dv:len()^2-(an-jq)^2)if jK>100 then jI=false elseif jJ<=jF or jF==-1 then BrakeIsOn=true;jx=true else BrakeIsOn=false;jx=true end end;if not jI and CalculateBrakeLandingSpeed then if jF>=jy then BrakeIsOn=true else BrakeIsOn=false end;jx=true end end end;if Nav.axisCommandManager:getAxisCommandType(0)==1 then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setTargetGroundAltitude(500)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(500)fQ=aj;if fQ>-1 then bc=autoRollPreference;if be<1 or bd:normalize():dot(cy)<0 then BrakeLanding=false;AltitudeHold=false;GearExtended=true;Nav.control.extendLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)a8=0;BrakeIsOn=true else BrakeIsOn=true end elseif StrongBrakes and bd:normalize():dot(-ei)<0.999 then BrakeIsOn=true elseif eg<-brakeLandingRate and not jx then BrakeIsOn=true elseif not jx then BrakeIsOn=false end end;if AutoTakeoff or ah then local ff,fh,fg;if AutopilotTargetCoords~=nil then ff,fh,fg=b6:getPlanetarySystem(0):castIntersections(iB,(AutopilotTargetCoords-iB):normalize(),function(fi)return fi.radius+fi.noAtmosphericDensityAltitude end)end;if antigrav and antigrav.getState()==1 then if an>=HoldAltitude-50 then AutoTakeoff=false;BrakeIsOn=true;it(0)z=0 else HoldAltitude=antigrav.getBaseAltitude()end elseif math.abs(j5)<15 and an/HoldAltitude>0.75 then AutoTakeoff=false;if not ah then if Nav.axisCommandManager:getAxisCommandType(0)==0 and not AtmoSpeedAssist then Nav.control.cancelCurrentControlMasterMode()end elseif ah and be-1;local jM=cz;if(VectorToTarget or ah)and not jL and be>minRollVelocity and j()>0.01 then local jm=math.rad(math.abs(dM))jM=cz*math.abs(math.cos(jm))+iE*math.sin(jm)end;local jN=utils.clamp(j5-jM,-PitchStallAngle*0.85,PitchStallAngle*0.85)if j()<0.01 and VectorToTarget then jN=utils.clamp(j5-jM,-85,MaxPitch)elseif j()<0.01 then jN=utils.clamp(j5-jM,-MaxPitch,MaxPitch)end;if math.abs(dM)<5 or VectorToTarget or BrakeLanding or jL or AltitudeHold then if pitchPID==nil then pitchPID=pid.new(5*0.01,0,5*0.1)end;pitchPID:inject(jN)local j6=pitchPID:get()O=O+j6 end end;if antigrav~=nil and(antigrav and not ExternalAGG and an<200000)then if AntigravTargetAltitude==nil or AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;if desiredBaseAltitude~=AntigravTargetAltitude then desiredBaseAltitude=AntigravTargetAltitude;antigrav.setBaseAltitude(desiredBaseAltitude)end end end end;function script.onFlush()if antigrav~=nil and(antigrav and not ExternalAGG)then if antigrav.getState()==0 and antigrav.getBaseAltitude()~=AntigravTargetAltitude then antigrav.setBaseAltitude(AntigravTargetAltitude)end end;if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byThrottle and D then z=0;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,z)D=false elseif Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and not D then z=0;D=true end;pitchSpeedFactor=math.max(pitchSpeedFactor,0.01)yawSpeedFactor=math.max(yawSpeedFactor,0.01)rollSpeedFactor=math.max(rollSpeedFactor,0.01)torqueFactor=math.max(torqueFactor,0.01)brakeSpeedFactor=math.max(brakeSpeedFactor,0.01)brakeFlatFactor=math.max(brakeFlatFactor,0.01)autoRollFactor=math.max(autoRollFactor,0.01)turnAssistFactor=math.max(turnAssistFactor,0.01)local jO=utils.clamp(N+O+system.getControlDeviceForwardInput(),-1,1)local jP=utils.clamp(Q+T+system.getControlDeviceYawInput(),-1,1)local jQ=utils.clamp(R+P-system.getControlDeviceLeftRightInput(),-1,1)local jR=S;local jS=vec3(core.getWorldVertical())if jS==nil or jS:len()==0 then jS=(planet.center-vec3(core.getConstructWorldPos())):normalize()end;local jT=vec3(core.getConstructWorldOrientationUp())local jU=vec3(core.getConstructWorldOrientationForward())local jV=vec3(core.getConstructWorldOrientationRight())local jW=vec3(core.getWorldVelocity())local jX=vec3(core.getWorldVelocity()):normalize()local jY=getRoll(jS,jU,jV)local jZ=math.abs(jY)local j_=utils.sign(jY)local j=j()local k0=vec3(core.getWorldAngularVelocity())local k1=jO*pitchSpeedFactor*jV+jP*rollSpeedFactor*jU+jQ*yawSpeedFactor*jT;if jS:len()>0.01 and(j>0.0 or ProgradeIsOn or Reentry or ag or AltitudeHold)then local dM=getRoll(jS,jU,jV)local dN=dM/180*math.pi;local dO=math.cos(dN)local dP=math.sin(dN)local iC=getPitch(jS,jU,jV*dO+jT*dP)if bc==true and math.abs(bk-jY)>autoRollRollThreshold and jP==0 and math.abs(iC)<85 then local k2=bk;local iV=autoRollFactor;if j==0 then iV=iV/4;bk=0;k2=0 end;if rollPID==nil then rollPID=pid.new(iV*0.01,0,iV*0.1)end;rollPID:inject(k2-jY)local k3=rollPID:get()k1=k1+k3*jU end end;if jS:len()>0.01 and j>0.0 then local k4=20.0;if turnAssist==true and jZ>k4 and jO==0 and jQ==0 then local k5=turnAssistFactor*0.1;local k6=turnAssistFactor*0.025;local k7=(jZ-k4)/(180-k4)*180;local k8=0;if k7<90 then k8=k7/90 elseif k7<180 then k8=(180-k7)/90 end;k8=k8*k8;local k9=-j_*k6*(1.0-k8)local ka=k5*k8;k1=k1+ka*jV+k9*jT end end;local kb=1;local kc=0;local kd=1;if system.getMouseWheel()>0 then if AltIsOn then if j>0 or Reentry then bm=utils.clamp(bm+speedChangeLarge,0,AtmoSpeedLimit)elseif Autopilot then MaxGameVelocity=utils.clamp(MaxGameVelocity+speedChangeLarge/3.6*100,0,8333.00)end;H=false else z=round(utils.clamp(z+speedChangeLarge/100,-1,1),2)end elseif system.getMouseWheel()<0 then if AltIsOn then if j>0 or Reentry then bm=utils.clamp(bm-speedChangeLarge,0,AtmoSpeedLimit)elseif Autopilot then MaxGameVelocity=utils.clamp(MaxGameVelocity-speedChangeLarge/3.6*100,0,8333.00)end;H=false else z=round(utils.clamp(z-speedChangeLarge/100,-1,1),2)end end;A=0;local eg=-jS:dot(jW)if am and AtmoSpeedAssist and Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byThrottle then if throttlePID==nil then throttlePID=pid.new(0.5,0,1)end;throttlePID:inject(bm/3.6-jW:dot(jU))local ke=throttlePID:get()C=utils.clamp(ke,-1,1)if C0.005 then B=true;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,utils.clamp(C,0.01,1))else B=false;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,z)end;if brakePID==nil then brakePID=pid.new(1*0.01,0,1*0.1)end;brakePID:inject(jW:len()-bm/3.6)local kf=utils.clamp(brakePID:get(),0,1)if j>0 and eg<-80 or j>0.005 then A=kf end;if A>0 then if B and C==0.01 then Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)end else C=utils.clamp(C,0.01,1)end;local kg=''local kh=vec3()local ki=composeAxisAccelerationFromTargetSpeedV(axisCommandId.vertical,a8*1000)Nav:setEngineForceCommand("vertical airfoil , vertical ground ",ki,kc)local kj='thrust analog longitudinal 'if ExtraLongitudeTags~="none"then kj=kj..ExtraLongitudeTags end;local kk=Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)local kl=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(kj,axisCommandId.longitudinal)local km=composeAxisAccelerationFromTargetSpeed(axisCommandId.lateral,LeftAmount*1000)kg=kg..' , '.."lateral airfoil , lateral ground "kh=kh+km;if kh:len()>constants.epsilon then Nav:setEngineForceCommand(kg,kh,kc,'','','',kd)end;Nav:setEngineForceCommand(kj,kl,kb)local kn='thrust analog vertical fueled 'local ko='thrust analog lateral fueled 'if ExtraLateralTags~="none"then ko=ko..ExtraLateralTags end;if ExtraVerticalTags~="none"then kn=kn..ExtraVerticalTags end;if a8~=0 or BrakeLanding and BrakeIsOn then Nav:setEngineForceCommand(kn,ki,kb)else Nav:setEngineForceCommand(kn,vec3(),kb)end;if LeftAmount~=0 then Nav:setEngineForceCommand(ko,km,kb)else Nav:setEngineForceCommand(ko,vec3(),kb)end;if jR==0 then jR=A end;local kp=-jR*(brakeSpeedFactor*jW+brakeFlatFactor*jX)Nav:setEngineForceCommand('brake',kp)else if AtmoSpeedAssist then Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,z)end;local kp=-jR*(brakeSpeedFactor*jW+brakeFlatFactor*jX)Nav:setEngineForceCommand('brake',kp)local kg=''local kh=vec3()local kq=false;local kj='thrust analog longitudinal 'if ExtraLongitudeTags~="none"then kj=kj..ExtraLongitudeTags end;local kk=Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)if kk==axisCommandType.byThrottle then local kl=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(kj,axisCommandId.longitudinal)Nav:setEngineForceCommand(kj,kl,kb)elseif kk==axisCommandType.byTargetSpeed then local kl=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.longitudinal)kg=kg..' , '..kj;kh=kh+kl;if Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)==0 or Nav.axisCommandManager:getCurrentToTargetDeltaSpeed(axisCommandId.longitudinal)<-Nav.axisCommandManager:getTargetSpeedCurrentStep(axisCommandId.longitudinal)*0.5 then kq=true end end;local ko='thrust analog lateral 'if ExtraLateralTags~="none"then ko=ko..ExtraLateralTags end;local kr=Nav.axisCommandManager:getAxisCommandType(axisCommandId.lateral)if kr==axisCommandType.byThrottle then local ks=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(ko,axisCommandId.lateral)Nav:setEngineForceCommand(ko,ks,kb)elseif kr==axisCommandType.byTargetSpeed then local km=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.lateral)kg=kg..' , '..ko;kh=kh+km end;local kn='thrust analog vertical 'if ExtraVerticalTags~="none"then kn=kn..ExtraVerticalTags end;local kt=Nav.axisCommandManager:getAxisCommandType(axisCommandId.vertical)if kt==axisCommandType.byThrottle then local ki=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(kn,axisCommandId.vertical)if a8~=0 or BrakeLanding and BrakeIsOn then Nav:setEngineForceCommand(kn,ki,kb,'airfoil','ground','',kd)else Nav:setEngineForceCommand(kn,vec3(),kb)Nav:setEngineForceCommand('airfoil vertical',ki,kb,'airfoil','','',kd)Nav:setEngineForceCommand('ground vertical',ki,kb,'ground','','',kd)end elseif kt==axisCommandType.byTargetSpeed then if a8<0 then Nav:setEngineForceCommand('hover',vec3(),kb)end;local ku=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.vertical)kg=kg..' , '..kn;kh=kh+ku end;local gb=unit.getAxisCommandValue(0)if kh:len()>constants.epsilon then if S~=0 or kq or math.abs(jX:dot(jU))<0.8 or bd:len()>gb/3.6 then kg=kg..', brake'end;Nav:setEngineForceCommand(kg,kh,kc,'','','',kd)end end;local kv=torqueFactor*(k1-k0)local kw=vec3(core.getWorldAirFrictionAngularAcceleration())kv=kv-kw;Nav:setEngineTorqueCommand('torque',kv,kb,'airfoil','','',kd)Nav:setBoosterCommand('rocket_engine')if Z and not VanillaRockets then local bS=vec3(core.getVelocity()):len()local kx=0.15;if Nav.axisCommandManager:getAxisCommandType(0)==1 then local ky=Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)if bS*3.6>ky*(1-kx)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bS*3.6=gb*(1-kx)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bS=gb*(1-kx)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bS0 or anHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude+Y;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude+Y end else AntigravTargetAltitude=desiredBaseAltitude+100 end elseif AltitudeHold then HoldAltitude=HoldAltitude+X else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(1.0)end elseif kz=="groundaltitudedown"then OldButtonMod=X;OldAntiMod=Y;if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitudeHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end end else AntigravTargetAltitude=desiredBaseAltitude end elseif AltitudeHold then HoldAltitude=HoldAltitude-X else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(-1.0)end elseif kz=="option1"then if not Autopilot then IncrementAutopilotTargetIndex()H=false end elseif kz=="option2"then if not Autopilot then DecrementAutopilotTargetIndex()H=false end elseif kz=="option3"then if hideHudOnToggleWidgets then if showHud then showHud=false else showHud=true end end;H=false;ToggleWidgets()elseif kz=="option4"then ToggleAutopilot()H=false elseif kz=="option5"then ToggleLockPitch()H=false elseif kz=="option6"then ToggleAltitudeHold()H=false elseif kz=="option7"then wipeSaveVariables()H=false elseif kz=="option8"then ToggleFollowMode()H=false elseif kz=="option9"then if gyro~=nil then gyro.toggle()aq=gyro.getState()==1 end;H=false elseif kz=="lshift"then if system.isViewLocked()==1 then V=true;PrevViewLock=system.isViewLocked()system.lockView(1)elseif o()==1 and ShiftShowsRemoteButtons then V=true;bb=false;ba=false end elseif kz=="brake"then if BrakeToggleStatus then BrakeToggle()elseif not BrakeIsOn then BrakeToggle()else BrakeIsOn=true end elseif kz=="lalt"then AltIsOn=true;if o()==0 and not freeLookToggle and userControlScheme=="keyboard"then system.lockView(1)end elseif kz=="booster"then if VanillaRockets then Nav:toggleBoosters()elseif not Z then if not IsRocketOn then Nav:toggleBoosters()IsRocketOn=true end;Z=true else if IsRocketOn then Nav:toggleBoosters()IsRocketOn=false end;Z=false end elseif kz=="stopengines"then Nav.axisCommandManager:resetCommand(axisCommandId.longitudinal)clearAll()z=0 elseif kz=="speedup"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z+speedChangeLarge/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal,speedChangeLarge)end else IncrementAutopilotTargetIndex()end elseif kz=="speeddown"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z-speedChangeLarge/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal,-speedChangeLarge)end else DecrementAutopilotTargetIndex()end elseif kz=="antigravity"and not ExternalAGG then if antigrav~=nil then ToggleAntigrav()end end end;function script.onActionStop(kz)if kz=="forward"then N=0 elseif kz=="backward"then N=0 elseif kz=="left"then Q=0 elseif kz=="right"then Q=0 elseif kz=="yawright"then R=0 elseif kz=="yawleft"then R=0 elseif kz=="straferight"then Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral,-1.0)LeftAmount=0 elseif kz=="strafeleft"then Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral,1.0)LeftAmount=0 elseif kz=="up"then a8=0;Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical,-1.0)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(currentGroundAltitudeStabilization)Nav:setEngineForceCommand('hover',vec3(),1)elseif kz=="down"then a8=0;Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical,1.0)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(currentGroundAltitudeStabilization)Nav:setEngineForceCommand('hover',vec3(),1)elseif kz=="groundaltitudeup"then if antigrav and not ExternalAGG and antigrav.getState()==1 then Y=OldAntiMod end;if AltitudeHold then X=OldButtonMod end;H=false elseif kz=="groundaltitudedown"then if antigrav and not ExternalAGG and antigrav.getState()==1 then Y=OldAntiMod end;if AltitudeHold then X=OldButtonMod end;H=false elseif kz=="lshift"then if system.isViewLocked()==1 then V=false;a9=0;aa=0;system.lockView(PrevViewLock)elseif o()==1 and ShiftShowsRemoteButtons then V=false;bb=false;ba=false end elseif kz=="brake"then if not BrakeToggleStatus then if BrakeIsOn then BrakeToggle()else BrakeIsOn=false end end elseif kz=="lalt"then if o()==0 and freeLookToggle then if H then if system.isViewLocked()==1 then system.lockView(0)else system.lockView(1)end else H=true end elseif o()==0 and not freeLookToggle and userControlScheme=="keyboard"then system.lockView(0)end;AltIsOn=false end end;function script.onActionLoop(kz)if kz=="groundaltitudeup"then if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitudeHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude+Y;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude+Y end;Y=Y*1.05;BrakeIsOn=false else AntigravTargetAltitude=desiredBaseAltitude+100;BrakeIsOn=false end elseif AltitudeHold then HoldAltitude=HoldAltitude+X;X=X*1.05 else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(1.0)end elseif kz=="groundaltitudedown"then if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitudeHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end end;Y=Y*1.05;BrakeIsOn=false else AntigravTargetAltitude=desiredBaseAltitude-100;BrakeIsOn=false end elseif AltitudeHold then HoldAltitude=HoldAltitude-X;X=X*1.05 else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(-1.0)end elseif kz=="speedup"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z+speedChangeSmall/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal,speedChangeSmall)end end elseif kz=="speeddown"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z-speedChangeSmall/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal,-speedChangeSmall)end end end end;function script.onInputText(dA)local i;local kA="/commands /setname /G /agg /addlocation /copydatabank"local kB,kC=nil,nil;local kD="Command List:\n/commands \n/setname - Updates current selected saved position name\n/G VariableName newValue - Updates global variable to new value\n".."/G dump - shows all updatable variables with /G\n/agg - Manually set agg target height\n".."/addlocation savename ::pos{0,2,46.4596,-155.1799,22.6572} - adds a saved location by waypoint, not as accurate as making one at location\n".."/copydatabank - copies dbHud databank to a blank databank"i=string.find(dA," ")kB=dA;if i~=nil then kB=string.sub(dA,0,i-1)kC=string.sub(dA,i+1)elseif not string.find(kA,kB)then for g7 in string.gmatch(kD,"([^\n]+)")do c(g7)end;return end;if kB=="/setname"then if kC==nil or kC==""then W="Usage: /setname Newname"return end;if AutopilotTargetIndex>0 and CustomTarget~=nil then UpdatePosition(kC)else W="Select a saved target to rename first"end elseif kB=="/addlocation"then if kC==nil or kC==""or string.find(kC,"::")==nil then W="Usage: /addlocation savename ::pos{0,2,46.4596,-155.1799,22.6572}"return end;i=string.find(kC,"::")local cm=string.sub(kC,1,i-2)local cg=string.sub(kC,i)local q=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local ch='::pos{'..q..','..q..','..q..','..q..','..q..'}'local ci,cj,cd,ce,cc=string.match(cg,ch)local planet=b0[tonumber(ci)][tonumber(cj)]AddNewLocationByWaypoint(cm,planet,cg)W="Added "..cm.." to saved locations,\nplanet "..planet.name.." at "..cg;ab=5 elseif kB=="/agg"then if kC==nil or kC==""then W="Usage: /agg targetheight"return end;kC=tonumber(kC)if kC<1000 then kC=1000 end;AntigravTargetAltitude=kC;W="AGG Target Height set to "..kC elseif kB=="/G"then if kC==nil or kC==""then W="Usage: /G VariableName variablevalue\n/G dump - shows all variables"return end;if kC=="dump"then for bB,bC in pairs(a)do if type(_G[bC])=="boolean"then if _G[bC]==true then c(bC.." true")else c(bC.." false")end elseif _G[bC]==nil then c(bC.." nil")else c(bC.." ".._G[bC])end end;return end;i=string.find(kC," ")local kE=string.sub(kC,0,i-1)local kF=string.sub(kC,i+1)for bB,bC in pairs(a)do if bC==kE then W="Variable "..kE.." changed to "..kF;local kG=type(_G[bC])if kG=="number"then kF=tonumber(kF)elseif kG=="boolean"then if string.lower(kF)=="true"then kF=true else kF=false end end;_G[bC]=kF;return end end;W="No such global variable: "..kE elseif kB=="/copydatabank"then if dbHud_2 then SaveDataBank(true)else W="Databank required to copy databank"end end end;script.onStart() -- error handling code added by wrap.lua diff --git a/ChangeLog.md b/ChangeLog.md index b299cc1..8b9a2fd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,10 @@ Fixed script unloading when away from control unit. Note: We are now at our script limit even minimized. We are trying to clean up to give more room, but this might be the limit of everything in the hud meaning new features would remove old features or we might have to get creative on some things. +Version 5.441 +- Orbiting + - Adjusted tolerances. Should orbit better. + Version 5.44 - Orbiting (note: Trying to establish super low orbits (i.e. 7000m at Alioth) could result in achieving luminary status (burning up)) - `Alt-6` (Altitude Hold): If target altitude changed (`alt-spacebar`) to above the atmosphere will now establish orbit at that height. diff --git a/src/ButtonHUD.lua b/src/ButtonHUD.lua index 7655b09..3155cda 100644 --- a/src/ButtonHUD.lua +++ b/src/ButtonHUD.lua @@ -5514,7 +5514,7 @@ function safeZone(WorldPos) -- Thanks to @SeM for the base code, modified to wor -- Start of actual HUD Script. Written by Dimencia and Archaegeo. Optimization and Automation of scripting by ChronosWS Linked sources where appropriate, most have been modified. function script.onStart() - VERSION_NUMBER = 5.44 + VERSION_NUMBER = 5.441 SetupComplete = false beginSetup = coroutine.create(function() Nav.axisCommandManager:setupCustomTargetSpeedRanges(axisCommandId.longitudinal, @@ -6194,7 +6194,7 @@ function script.onTick(timerId) local escapeVel, endSpeed = Kep(OrbitTargetPlanet):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-OrbitTargetPlanet.center):len()-OrbitTargetPlanet.radius) local orbitalRoll = roll -- Getting as close to orbit distance as comfortably possible - if orbit.periapsis ~= nil and orbit.eccentricity < 1 and coreAltitude > OrbitTargetOrbit and coreAltitude < OrbitTargetOrbit*1.3 and orbit.periapsis.altitude > 0 then + if orbit.periapsis ~= nil and orbit.eccentricity < 1 and coreAltitude > OrbitTargetOrbit and coreAltitude < OrbitTargetOrbit*1.4 then local function orbitThrottle(value, orbitalpitch) orbitPitch = orbitalpitch if adjustedPitch <= orbitalpitch+3 and adjustedPitch >= orbitalpitch-3 then @@ -6206,7 +6206,7 @@ function script.onTick(timerId) end end if orbit.apoapsis ~= nil then - if orbit.periapsis.altitude > OrbitTargetOrbit*0.9 and orbit.periapsis.altitude < OrbitTargetOrbit*1.2 and orbit.apoapsis.altitude > orbit.periapsis.altitude and + if orbit.periapsis.altitude > OrbitTargetOrbit*0.95 and orbit.periapsis.altitude < OrbitTargetOrbit*1.25 and orbit.apoapsis.altitude > orbit.periapsis.altitude and orbit.apoapsis.altitude <= orbit.periapsis.altitude*1.35 then -- conditions for a near perfect orbit BrakeIsOn = false PlayerThrottle = 0 @@ -6236,37 +6236,64 @@ function script.onTick(timerId) else orbitMsg = "Adjusting Orbit" orbitalRecover = true - if orbit.periapsis.altitude < OrbitTargetOrbit then - if orbit.apoapsis.altitude > orbit.periapsis.altitude*1.25 then + if vSpd > 125 then + orbitThrottle(0.5,-65) + BrakeIsOn = false + elseif orbit.periapsis.altitude < 0 then + -- if orbit.apoapsis.altitude > orbit.periapsis.altitude*1.25 then if velMag+10 > endSpeed then if vSpd > 5 then - orbitThrottle(0.5,-80) + orbitThrottle(0.5,-65) BrakeIsOn = false elseif vSpd < -5 then - orbitThrottle(0.5,80) + orbitThrottle(0.5,65) BrakeIsOn = false else cmdThrottle(0) - BrakeIsOn = true + BrakeIsOn = not BrakeIsOn end elseif velMag-10 < endSpeed then - orbitThrottle(0.5,80) + orbitThrottle(0.75,15) BrakeIsOn = false else cmdThrottle(0) - BrakeIsOn = true + BrakeIsOn = not BrakeIsOn end + -- else + -- orbitThrottle(0.5,15) + -- BrakeIsOn = false + -- end + elseif orbit.periapsis.altitude > 0 and orbit.periapsis.altitude < OrbitTargetOrbit*1.25 then + if velMag*0.5 > endSpeed then + cmdThrottle(0) + BrakeIsOn = not BrakeIsOn + elseif velMag+20 > endSpeed and vSpd > 35 then + orbitThrottle(0.5,-80) + BrakeIsOn = false + elseif velMag+20 > endSpeed and vSpd < -35 then + orbitThrottle(0.5,80) + BrakeIsOn = false + -- elseif velMag*0.5 > endSpeed then + -- cmdThrottle(0) + -- BrakeIsOn = not BrakeIsOn + -- else + -- orbitThrottle(0.5,15) + -- BrakeIsOn = false + -- end + elseif velMag-20 < endSpeed then + orbitThrottle(0.75,15) + BrakeIsOn = false + -- elseif orbit.apoapsis.altitude > orbit.periapsis.altitude*1.3 then + -- cmdThrottle(0) + -- BrakeIsOn = not BrakeIsOn else - orbitThrottle(0.5,80) + orbitThrottle(0.5,15) BrakeIsOn = false end else - if orbit.apoapsis.altitude > orbit.periapsis.altitude*1.25 then + if orbit.apoapsis.altitude > orbit.periapsis.altitude*1.3 then cmdThrottle(0) - BrakeIsOn = true - elseif orbit.periapsis.altitude < OrbitTargetOrbit*1.2 then - orbitThrottle(0.5,-80) - BrakeIsOn = false + BrakeIsOn = not BrakeIsOn end end end @@ -6306,17 +6333,19 @@ function script.onTick(timerId) else if coreAltitude < OrbitTargetOrbit*0.8 then orbitMsg = "Escaping planet gravity" - orbitPitch = 35 - elseif coreAltitude >= OrbitTargetOrbit*0.8 and coreAltitude < OrbitTargetOrbit*1.01 then + orbitPitch = utils.map(vSpd, 200, 0, -15, 80) + elseif coreAltitude >= OrbitTargetOrbit*0.8 and coreAltitude < OrbitTargetOrbit*1.15 then orbitMsg = "Approaching orbital corridor" - if vSpd > 100 then - pcs = pcs*0.75 - orbitPitch = -50 - else - orbitPitch = utils.map(coreAltitude, OrbitTargetOrbit*0.6, OrbitTargetOrbit, 35, 0) - end - elseif coreAltitude >= OrbitTargetOrbit*1.01 and coreAltitude < OrbitTargetOrbit*1.5 then + pcs = pcs*0.75 + -- if vSpd > 100 then + -- orbitPitch = -30 + -- else + -- orbitPitch = utils.map(coreAltitude, OrbitTargetOrbit*0.6, OrbitTargetOrbit, 45, 10) + -- end + orbitPitch = utils.map(vSpd, 100, -100, -15, 65) + elseif coreAltitude >= OrbitTargetOrbit*1.15 and coreAltitude < OrbitTargetOrbit*1.5 then orbitMsg = "Approaching orbital corridor" + pcs = pcs*0.75 if vSpd < 0 or orbitalRecover then orbitPitch = utils.map(coreAltitude, OrbitTargetOrbit*1.5, OrbitTargetOrbit*1.01, -30, 0) -- Going down? pitch up. else From af7361bfd1335442e160baf5889945be2cb048a9 Mon Sep 17 00:00:00 2001 From: Jean Delgado Date: Wed, 17 Mar 2021 10:26:32 -0700 Subject: [PATCH 2/3] adjustments of the adjustments --- ButtonHUD.conf | 4 ++-- src/ButtonHUD.lua | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ButtonHUD.conf b/ButtonHUD.conf index c942f3a..747449b 100644 --- a/ButtonHUD.conf +++ b/ButtonHUD.conf @@ -1,4 +1,4 @@ -name: ButtonsHud - Dimencia and Archaegeo v5.441 (Minified) +name: ButtonsHud - Dimencia and Archaegeo v5.442 (Minified) slots: core: class: CoreUnit @@ -385,7 +385,7 @@ handlers: Keyboard Scheme must be selected]],ConvertResolutionX(960),ConvertResolutionY(600))ct[#ct+1]=e([[ Set your preferred scheme in Lua Parameters instead]],ConvertResolutionX(960),ConvertResolutionY(650))end;local f7=ConvertResolutionX(960)local f8=ConvertResolutionY(860)local f9=ConvertResolutionY(880)local fa=ConvertResolutionY(900)local fb=ConvertResolutionY(960)local fc=ConvertResolutionY(200)local fd=ConvertResolutionY(150)local fe=ConvertResolutionY(960)if o()==1 and not RemoteHud then f8=ConvertResolutionY(135)f9=ConvertResolutionY(155)fa=ConvertResolutionY(175)fc=ConvertResolutionY(115)fd=ConvertResolutionY(95)end;if BrakeIsOn then ct[#ct+1]=e([[Brake Engaged]],f7,f8)elseif A>0 then ct[#ct+1]=e([[Auto-Brake Engaged]],f7,f8,A)end;if am and bi and hoverDetectGround()==-1 then ct[#ct+1]=e([[** STALL WARNING **]],f7,fc+50)end;if aq then ct[#ct+1]=e([[Gyro Enabled]],f7,fe)end;if GearExtended then if M then ct[#ct+1]=e([[Gear Extended]],f7,f9)else ct[#ct+1]=e([[Landed (G: Takeoff)]],f7,f9)end;local dy,dz=getDistanceDisplayString(Nav:getTargetGroundAltitude())ct[#ct+1]=e([[Hover Height: %s]],f7,fa,dy..dz)end;if Z then ct[#ct+1]=e([[ROCKET BOOST ENABLED]],f7,fb+20)end;if antigrav and not ExternalAGG and antigrav.getState()==1 and AntigravTargetAltitude~=nil then if math.abs(an-antigrav.getBaseAltitude())<501 then ct[#ct+1]=e([[AGG On - Target Altitude: %d Singluarity Altitude: %d]],f7,fc+20,d(AntigravTargetAltitude),d(antigrav.getBaseAltitude()))else ct[#ct+1]=e([[AGG On - Target Altitude: %d Singluarity Altitude: %d]],f7,fc+20,d(AntigravTargetAltitude),d(antigrav.getBaseAltitude()))end elseif Autopilot and AutopilotTargetName~="None"then ct[#ct+1]=e([[Autopilot %s]],f7,fc+20,AutopilotStatus)elseif LockPitch~=nil then ct[#ct+1]=e([[LockedPitch: %d]],f7,fc+20,d(LockPitch))elseif U then ct[#ct+1]=e([[Follow Mode Engaged]],f7,fc+20)elseif Reentry then ct[#ct+1]=e([[Re-entry in Progress]],f7,fc+20)end;local ff,fg,fh=b6:getPlanetarySystem(0):castIntersections(vec3(core.getConstructWorldPos()),bd:normalize(),function(fi)if fi.noAtmosphericDensityAltitude>0 then return fi.radius+fi.noAtmosphericDensityAltitude else return fi.radius+fi.surfaceMaxAltitude*1.5 end end)local fj=fg;if fh~=nil and fg~=nil then fj=math.min(fh,fg)end;if AltitudeHold then if AutoTakeoff and not IntoOrbit then local dy,dz=getDistanceDisplayString(HoldAltitude)ct[#ct+1]=e([[Ascent to %s]],f7,fc,dy..dz)if BrakeIsOn then ct[#ct+1]=e([[Throttle Up and Disengage Brake For Takeoff]],f7,fc+50)end else local dy,dz=getDistanceDisplayString2(HoldAltitude)ct[#ct+1]=e([[Altitude Hold: %s]],f7,fc,dy..dz)end end;if VertTakeOff and(antigrav~=nil and antigrav)then if j()>0.1 then ct[#ct+1]=e([[Beginning ascent]],f7,fc)elseif j()<0.09 and j()>0.05 then ct[#ct+1]=e([[Aligning trajectory]],f7,fc)elseif j()<0.05 then ct[#ct+1]=e([[Leaving atmosphere]],f7,fc)end end;if IntoOrbit then if bo~=nil then ct[#ct+1]=e([[%s]],f7,fc,bo)end end;if BrakeLanding then if StrongBrakes then ct[#ct+1]=e([[Brake-Landing]],f7,fc)else ct[#ct+1]=e([[Coast-Landing]],f7,fc)end end;if ProgradeIsOn then ct[#ct+1]=e([[Prograde Alignment]],f7,fc)end;if RetrogradeIsOn then ct[#ct+1]=e([[Retrograde Alignment]],f7,fc)end;if TurnBurn then ct[#ct+1]=e([[Turn & Burn Braking]],f7,fd)elseif fj~=nil and j()==0 then local dy,dz=getDistanceDisplayString(fj)local travelTime=b7.computeTravelTime(be,0,fj)local fk="Collision"if ff.noAtmosphericDensityAltitude>0 then fk="Atmosphere"end;ct[#ct+1]=e([[%s %s In %s (%s)]],f7,fd,ff.name,fk,FormatTimeString(travelTime),dy..dz)end;if VectorToTarget and not IntoOrbit then ct[#ct+1]=e([[%s]],f7,fc+30,VectorStatus)end;ct[#ct+1]=""end;function DisplayOrbitScreen(ct)if orbit~=nil and j()<0.2 and planet~=nil and orbit.apoapsis~=nil and orbit.periapsis~=nil and orbit.period~=nil and orbit.apoapsis.speed>5 and DisplayOrbit then local fl=OrbitMapX;local fm=OrbitMapY;local fn=OrbitMapSize;local fo=4;fm=fm+fo;local fp=15;local bY=fl+fn+fl/2+fo;local bZ=fm+fn/2+5+fo;local fq,fr,fs,ft;fq=fn/4;ft=0;ct[#ct+1]=[[]]ct[#ct+1]=e('',fn+fl*2,fn+fm,fo,fo)if orbit.periapsis~=nil and orbit.apoapsis~=nil then fs=(orbit.apoapsis.altitude+orbit.periapsis.altitude+planet.radius*2)/(fq*2)fr=(planet.radius+orbit.periapsis.altitude+(orbit.apoapsis.altitude-orbit.periapsis.altitude)/2)/fs*(1-orbit.eccentricity)ft=fq-orbit.periapsis.altitude/fs-planet.radius/fs;local fu=""if orbit.periapsis.altitude<=0 then fu='redout'end;ct[#ct+1]=e([[]],fu,fl+fn/2+ft+fo,fm+fn/2+fo,fq,fr)ct[#ct+1]=e('',fl+fn/2+fo,fm+fn/2+fo,planet.radius/fs)end;if orbit.apoapsis~=nil and orbit.apoapsis.speed1 then ct[#ct+1]=e([[]],bY-35,bZ-5,fl+fn/2+fq+ft,bZ-5)ct[#ct+1]=e([[Apoapsis]],bY,bZ)bZ=bZ+fp;local dy,dz=getDistanceDisplayString(orbit.apoapsis.altitude)ct[#ct+1]=e([[%s]],bY,bZ,dy..dz)bZ=bZ+fp;ct[#ct+1]=e([[%s]],bY,bZ,FormatTimeString(orbit.timeToApoapsis))bZ=bZ+fp;ct[#ct+1]=e([[%s]],bY,bZ,getSpeedDisplayString(orbit.apoapsis.speed))end;bZ=fm+fn/2+5+fo;bY=fl-fl/2+10+fo;if orbit.periapsis~=nil and orbit.periapsis.speed1 then ct[#ct+1]=e([[]],bY+35,bZ-5,fl+fn/2-fq+ft,bZ-5)ct[#ct+1]=e([[Periapsis]],bY,bZ)bZ=bZ+fp;local dy,dz=getDistanceDisplayString(orbit.periapsis.altitude)ct[#ct+1]=e([[%s]],bY,bZ,dy..dz)bZ=bZ+fp;ct[#ct+1]=e([[%s]],bY,bZ,FormatTimeString(orbit.timeToPeriapsis))bZ=bZ+fp;ct[#ct+1]=e([[%s]],bY,bZ,getSpeedDisplayString(orbit.periapsis.speed))end;ct[#ct+1]=e([[%s]],fl+fn/2+fo,20+fo,planet.name)if orbit.period~=nil and orbit.periapsis~=nil and orbit.apoapsis~=nil and orbit.apoapsis.speed>1 then local fv=orbit.timeToApoapsis/orbit.period*2*math.pi;local fw=fq*math.cos(fv)local fx=fr*math.sin(fv)ct[#ct+1]=e('',fl+fn/2+fw+ft+fo,fm+fn/2+fx+fo)end;ct[#ct+1]=[[]]end end;function getDistanceDisplayString(ac)local fy=ac>100000;local bD,dz=""if fy then bD,dz=round(ac/1000/200,1),"SU"elseif ac<1000 then bD,dz=round(ac,1),"m"else bD,dz=round(ac/1000,1),"Km"end;return bD,dz end;function getDistanceDisplayString2(ac)local fy=ac>100000;local bD,dz=""if fy then bD,dz=round(ac/1000/200,2)," SU"elseif ac<1000 then bD,dz=round(ac,2)," M"else bD,dz=round(ac/1000,2)," KM"end;return bD,dz end;function getSpeedDisplayString(bS)return d(round(bS*3.6,0)+0.5).." km/h"end;function FormatTimeString(fz)local fA=0;local fB=0;local fC=0;if fz<60 then fz=d(fz)elseif fz<3600 then fA=d(fz/60)fz=d(fz%60)elseif fz<86400 then fB=d(fz/3600)fA=d(fz%3600/60)else fC=d(fz/86400)fB=d(fz%86400/3600)end;if fC>0 then return fC.."d "..fB.."h "elseif fB>0 then return fB.."h "..fA.."m "elseif fA>0 then return fA.."m "..fz.."s"elseif fz>0 then return fz.."s"else return"0s"end end;function getMagnitudeInDirection(dr,fD)dr=vec3(dr)fD=vec3(fD):normalize()local bD=dr*fD;return bD.x+bD.y+bD.z end;function UpdateAutopilotTarget()if AutopilotTargetIndex==0 then AutopilotTargetName="None"a4=nil;CustomTarget=nil;return true end;local fE=AtlasOrdered[AutopilotTargetIndex].index;local fF=b0[0][fE]if fF.center then AutopilotTargetName=fF.name;a4=b6[0][fE]if CustomTarget~=nil then if j()==0 then if system.updateData(widgetMaxBrakeTimeText,widgetMaxBrakeTime)~=1 then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;if system.updateData(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)~=1 then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;if system.updateData(widgetCurBrakeTimeText,widgetCurBrakeTime)~=1 then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;if system.updateData(widgetCurBrakeDistanceText,widgetCurBrakeDistance)~=1 then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;if system.updateData(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)~=1 then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end end;if system.updateData(widgetMaxMassText,widgetMaxMass)~=1 then system.addDataToWidget(widgetMaxMassText,widgetMaxMass)end;if system.updateData(widgetTravelTimeText,widgetTravelTime)~=1 then system.addDataToWidget(widgetTravelTimeText,widgetTravelTime)end;if system.updateData(widgetTargetOrbitText,widgetTargetOrbit)~=1 then system.addDataToWidget(widgetTargetOrbitText,widgetTargetOrbit)end end;CustomTarget=nil else CustomTarget=fF;for _,bC in pairs(b6[0])do if bC.name==CustomTarget.planetname then a4=bC;AutopilotTargetName=CustomTarget.name;break end end;if system.updateData(widgetMaxMassText,widgetMaxMass)~=1 then system.addDataToWidget(widgetMaxMassText,widgetMaxMass)end;if system.updateData(widgetTravelTimeText,widgetTravelTime)~=1 then system.addDataToWidget(widgetTravelTimeText,widgetTravelTime)end end;if CustomTarget==nil then AutopilotTargetCoords=vec3(a4.center)else AutopilotTargetCoords=CustomTarget.position end;if a4.planetname~="Space"then if a4.hasAtmosphere then AutopilotTargetOrbit=math.floor(a4.radius*(TargetOrbitRadius-1)+a4.noAtmosphericDensityAltitude)else AutopilotTargetOrbit=math.floor(a4.radius*(TargetOrbitRadius-1)+a4.surfaceMaxAltitude)end else AutopilotTargetOrbit=1000 end;if CustomTarget~=nil and CustomTarget.planetname=="Space"then AutopilotEndSpeed=0 else _,AutopilotEndSpeed=b9(a4):escapeAndOrbitalSpeed(AutopilotTargetOrbit)end;AutopilotPlanetGravity=0;AutopilotAccelerating=false;AutopilotBraking=false;AutopilotCruising=false;Autopilot=false;AutopilotRealigned=false;AutopilotStatus="Aligning"return true end;function IncrementAutopilotTargetIndex()AutopilotTargetIndex=AutopilotTargetIndex+1;if AutopilotTargetIndex>#AtlasOrdered then AutopilotTargetIndex=0 end;if AutopilotTargetIndex==0 then UpdateAutopilotTarget()else local fE=AtlasOrdered[AutopilotTargetIndex].index;local fF=b0[0][fE]if fF.name=="Space"then IncrementAutopilotTargetIndex()else UpdateAutopilotTarget()end end end;function DecrementAutopilotTargetIndex()AutopilotTargetIndex=AutopilotTargetIndex-1;if AutopilotTargetIndex<0 then AutopilotTargetIndex=#AtlasOrdered end;if AutopilotTargetIndex==0 then UpdateAutopilotTarget()else local fE=AtlasOrdered[AutopilotTargetIndex].index;local fF=b0[0][fE]if fF.name=="Space"then DecrementAutopilotTargetIndex()else UpdateAutopilotTarget()end end end;function GetAutopilotMaxMass()local fG=LastMaxBrakeInAtmo/a4:getGravity(a4.center+vec3(0,0,1)*a4.radius):len()return fG end;function GetAutopilotTravelTime()if not Autopilot then if CustomTarget==nil or CustomTarget.planetname~=planet.name then AutopilotDistance=(a4.center-vec3(core.getConstructWorldPos())):len()else AutopilotDistance=(CustomTarget.position-vec3(core.getConstructWorldPos())):len()end end;local bd=core.getWorldVelocity()local bS=vec3(bd):len()local fH=unit.getThrottle()/100;if AtmoSpeedAssist then fH=z end;local fI,fJ=b7.computeDistanceAndTime(vec3(bd):len(),MaxGameVelocity,n(),Nav:maxForceForward()*fH,warmup,0)local a0,a1;if not TurnBurn then a0,a1=GetAutopilotBrakeDistanceAndTime(MaxGameVelocity)else a0,a1=GetAutopilotTBBrakeDistanceAndTime(MaxGameVelocity)end;local _,fK;if not TurnBurn and bS>0 then _,fK=GetAutopilotBrakeDistanceAndTime(bS)else _,fK=GetAutopilotTBBrakeDistanceAndTime(bS)end;local fL=0;local fM=0;if AutopilotCruising or not Autopilot and bS>5 then fM=b7.computeTravelTime(bS,0,AutopilotDistance)elseif a0+fI0 then return b7.computeDistanceAndTime(bS,AutopilotEndSpeed,n(),0,0,LastMaxBrakeInAtmo-AutopilotPlanetGravity*n())else return 0,0 end end end;function GetAutopilotTBBrakeDistanceAndTime(bS)RefreshLastMaxBrake()return b7.computeDistanceAndTime(bS,AutopilotEndSpeed,n(),Nav:maxForceForward(),warmup,LastMaxBrake-AutopilotPlanetGravity*n())end;function hoverDetectGround()local fO=-1;local fP=-1;if vBooster then fO=vBooster.distance()end;if hover then fP=hover.distance()end;if fO~=-1 and fP~=-1 then if fOProfileTimeMax then ProfileTimeMax=fV end;if fV0 then local g4=g1:find('identifiedConstructs":%[%]')if g4==nil and perisPanelID==nil then af=1;ToggleRadarPanel()end;if g4~=nil and perisPanelID~=nil then ToggleRadarPanel()end;if radarPanelID==nil then ToggleRadarPanel()end;ad=e([[Radar: %i contacts]],g2,g3,#g0)local g5={}for bB,bC in pairs(g0)do if radar_1.hasMatchingTransponder(bC)==1 then table.insert(g5,bC)end end;if#g5>0 then local bZ=ConvertResolutionY(15)local bY=ConvertResolutionX(1370)ad=e([[%sFriendlies In Range]],ad,bY,bZ)for bB,bC in pairs(g5)do bZ=bZ+20;ad=e([[%s%s]],ad,bY,bZ,radar_1.getConstructName(bC))end end else local g6;g6=g1:find('worksInEnvironment":false')if g6 then ad=e([[ Radar: Jammed]],g2,g3)else ad=e([[ - Radar: No Contacts]],g2,g3)end;if radarPanelID~=nil then af=0;ToggleRadarPanel()end end end end;function DisplayMessage(ct,dy)if dy~="empty"then ct[#ct+1]=[[]]for g7 in string.gmatch(dy,"([^\n]+)")do ct[#ct+1]=e([[%s]],g7)end;ct[#ct+1]=[[]]end;if ab~=0 then unit.setTimer("msgTick",ab)ab=0 end end;function updateDistance()local bL=system.getTime()local bd=vec3(core.getWorldVelocity())local dU=vec3(bd):len()local g8=bL-ap;if dU>1.38889 then dU=dU/1000;local g9=dU*(bL-ap)TotalDistanceTravelled=TotalDistanceTravelled+g9;a5=a5+g9 end;a6=a6+g8;TotalFlightTime=TotalFlightTime+g8;ap=bL end;function composeAxisAccelerationFromTargetSpeedV(ga,gb)local gc=vec3()local gd=vec3()if ga==axisCommandId.longitudinal then gc=vec3(core.getConstructOrientationForward())gd=vec3(core.getConstructWorldOrientationForward())elseif ga==axisCommandId.vertical then gc=vec3(core.getConstructOrientationUp())gd=vec3(core.getConstructWorldOrientationUp())elseif ga==axisCommandId.lateral then gc=vec3(core.getConstructOrientationRight())gd=vec3(core.getConstructWorldOrientationRight())else return vec3()end;local ge=vec3(core.getWorldGravity())local gf=ge:dot(gd)local gg=vec3(core.getWorldAirFrictionAcceleration())local gh=gg:dot(gd)local gi=vec3(core.getVelocity())local gj=gi:dot(gc)local gk=gb*constants.kph2m;if targetSpeedPID2==nil then targetSpeedPID2=pid.new(10,0,10.0)end;targetSpeedPID2:inject(gk-gj)local gl=targetSpeedPID2:get()local gm=(gl-gh-gf)*gd;return gm end;function composeAxisAccelerationFromTargetSpeed(ga,gb)local gc=vec3()local gd=vec3()if ga==axisCommandId.longitudinal then gc=vec3(core.getConstructOrientationForward())gd=vec3(core.getConstructWorldOrientationForward())elseif ga==axisCommandId.vertical then gc=vec3(core.getConstructOrientationUp())gd=vec3(core.getConstructWorldOrientationUp())elseif ga==axisCommandId.lateral then gc=vec3(core.getConstructOrientationRight())gd=vec3(core.getConstructWorldOrientationRight())else return vec3()end;local ge=vec3(core.getWorldGravity())local gf=ge:dot(gd)local gg=vec3(core.getWorldAirFrictionAcceleration())local gh=gg:dot(gd)local gi=vec3(core.getVelocity())local gj=gi:dot(gc)local gk=gb*constants.kph2m;if targetSpeedPID==nil then targetSpeedPID=pid.new(10,0,10.0)end;targetSpeedPID:inject(gk-gj)local gl=targetSpeedPID:get()local gm=(gl-gh-gf)*gd;return gm end;function Atlas()return{[0]={[0]={GM=0,bodyId=0,center={x=0,y=0,z=0},name='Space',planetarySystemId=0,radius=0,hasAtmosphere=false,gravity=0,noAtmosphericDensityAltitude=0,surfaceMaxAltitude=0},[2]={name="Alioth",description="Alioth is the planet selected by the arkship for landfall; it is a typical goldilocks planet where humanity may rebuild in the coming decades. The arkship geological survey reports mountainous regions alongside deep seas and lush forests. This is where it all starts.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9401,atmosphericEngineMaxAltitude=5580,biosphere="Forest",classification="Mesoplanet",bodyId=2,GM=157470826617,gravity=1.0082568597356114,fullAtmosphericDensityMaxAltitude=-10,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=6272,numSatellites=2,positionFromSun=2,center={x=-8,y=-8,z=-126303},radius=126067.8984375,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=3410,surfaceArea=199718780928,surfaceAverageAltitude=200,surfaceMaxAltitude=1100,surfaceMinAltitude=-330,systemZone="High",territories=259472,type="Planet",waterLevel=0,planetarySystemId=0},[21]={name="Alioth Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=21,GM=2118960000,gravity=0.24006116402380084,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=457933,y=-1509011,z=115524},radius=30000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=11309733888,surfaceAverageAltitude=140,surfaceMaxAltitude=200,surfaceMinAltitude=10,systemZone=nil,territories=14522,type="",waterLevel=nil,planetarySystemId=0},[22]={name="Alioth Moon 4",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=22,GM=2165833514,gravity=0.2427018259886451,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-1692694,y=729681,z=-411464},radius=30330,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=0,surfaceArea=11559916544,surfaceAverageAltitude=-15,surfaceMaxAltitude=-5,surfaceMinAltitude=-50,systemZone=nil,territories=14522,type="",waterLevel=nil,planetarySystemId=0},[5]={name="Feli",description="Feli is easily identified by its massive and deep crater. Outside of the crater, the arkship geological survey reports a fairly bland and uniform planet, it also cannot explain the existence of the crater. Feli is particular for having an extremely small atmosphere, allowing life to develop in the deeper areas of its crater but limiting it drastically on the actual surface.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.5488,atmosphericEngineMaxAltitude=66725,biosphere="Barren",classification="Mesoplanet",bodyId=5,GM=16951680000,gravity=0.4801223280476017,fullAtmosphericDensityMaxAltitude=30,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=78500,numSatellites=1,positionFromSun=5,center={x=-43534464,y=22565536,z=-48934464},radius=41800,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=42800,surfaceArea=21956466688,surfaceAverageAltitude=18300,surfaceMaxAltitude=18500,surfaceMinAltitude=46,systemZone="Low",territories=27002,type="Planet",waterLevel=nil,planetarySystemId=0},[50]={name="Feli Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=50,GM=499917600,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-43902841.78,y=22261034.7,z=-48862386},radius=14000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=800,surfaceMaxAltitude=900,surfaceMinAltitude=0,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[120]={name="Ion",description="Ion is nothing more than an oversized ice cube frozen through and through. It is a largely inhospitable planet due to its extremely low temperatures. The arkship geological survey reports extremely rough mountainous terrain with little habitable land.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9522,atmosphericEngineMaxAltitude=10480,biosphere="Ice",classification="Hypopsychroplanet",bodyId=120,GM=7135606629,gravity=0.36009174603570127,fullAtmosphericDensityMaxAltitude=-30,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=17700,numSatellites=2,positionFromSun=12,center={x=2865536.7,y=-99034464,z=-934462.02},radius=44950,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=6410,surfaceArea=25390383104,surfaceAverageAltitude=500,surfaceMaxAltitude=1300,surfaceMinAltitude=250,systemZone="Average",territories=32672,type="Planet",waterLevel=nil,planetarySystemId=0},[121]={name="Ion Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=121,GM=106830900,gravity=0.08802242599860607,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=2472916.8,y=-99133747,z=-1133582.8},radius=11000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=1520530944,surfaceAverageAltitude=100,surfaceMaxAltitude=200,surfaceMinAltitude=3,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[122]={name="Ion Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=122,GM=176580000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=2995424.5,y=-99275010,z=-1378480.7},radius=15000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=-1900,surfaceMaxAltitude=-1400,surfaceMinAltitude=-2100,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[9]={name="Jago",description="Jago is a water planet. The large majority of the planet's surface is covered by large oceans dotted by small areas of landmass across the planet. The arkship geological survey reports deep seas across the majority of the planet with sub 15 percent coverage of solid ground.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9835,atmosphericEngineMaxAltitude=9695,biosphere="Water",classification="Mesoplanet",bodyId=9,GM=18606274330,gravity=0.5041284298678057,fullAtmosphericDensityMaxAltitude=-90,habitability="Very High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=10900,numSatellites=0,positionFromSun=9,center={x=-94134462,y=12765534,z=-3634464},radius=61590,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=5900,surfaceArea=47668367360,surfaceAverageAltitude=0,surfaceMaxAltitude=1200,surfaceMinAltitude=-500,systemZone="Very High",territories=60752,type="Planet",waterLevel=0,planetarySystemId=0},[100]={name="Lacobus",description="Lacobus is an ice planet that also features large bodies of water. The arkship geological survey reports deep oceans alongside a frozen and rough mountainous environment. Lacobus seems to feature regional geothermal activity allowing for the presence of water on the surface.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.7571,atmosphericEngineMaxAltitude=11120,biosphere="Ice",classification="Psychroplanet",bodyId=100,GM=13975172474,gravity=0.45611622622739767,fullAtmosphericDensityMaxAltitude=-20,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=12510,numSatellites=3,positionFromSun=10,center={x=98865536,y=-13534464,z=-934461.99},radius=55650,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=6790,surfaceArea=38917074944,surfaceAverageAltitude=800,surfaceMaxAltitude=1660,surfaceMinAltitude=250,systemZone="Average",territories=50432,type="Planet",waterLevel=0,planetarySystemId=0},[102]={name="Lacobus Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=102,GM=444981600,gravity=0.14403669598391783,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=99180968,y=-13783862,z=-926156.4},radius=18000,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=0,surfaceArea=4071504128,surfaceAverageAltitude=150,surfaceMaxAltitude=300,surfaceMinAltitude=10,systemZone=nil,territories=5072,type="",waterLevel=nil,planetarySystemId=0},[103]={name="Lacobus Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=103,GM=211503600,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=99250052,y=-13629215,z=-1059341.4},radius=14000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=-1380,surfaceMaxAltitude=-1280,surfaceMinAltitude=-1880,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[101]={name="Lacobus Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=101,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=98905288.17,y=-13950921.1,z=-647589.53},radius=15000,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=500,surfaceMaxAltitude=820,surfaceMinAltitude=3,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[1]={name="Madis",description="Madis is a barren wasteland of a rock; it sits closest to the sun and temperatures reach extreme highs during the day. The arkship geological survey reports long rocky valleys intermittently separated by small ravines.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.8629,atmosphericEngineMaxAltitude=7165,biosphere="Barren",classification="hyperthermoplanet",bodyId=1,GM=6930729684,gravity=0.36009174603570127,fullAtmosphericDensityMaxAltitude=220,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=8050,numSatellites=3,positionFromSun=1,center={x=17465536,y=22665536,z=-34464},radius=44300,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=4480,surfaceArea=24661377024,surfaceAverageAltitude=750,surfaceMaxAltitude=850,surfaceMinAltitude=670,systemZone="Low",territories=30722,type="Planet",waterLevel=nil,planetarySystemId=0},[10]={name="Madis Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=10,GM=78480000,gravity=0.08002039003323584,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17448118.224,y=22966846.286,z=143078.82},radius=10000,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=0,surfaceArea=1256637056,surfaceAverageAltitude=210,surfaceMaxAltitude=420,surfaceMinAltitude=0,systemZone=nil,territories=1472,type="",waterLevel=nil,planetarySystemId=0},[11]={name="Madis Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=11,GM=237402000,gravity=0.09602446196397631,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17194626,y=22243633.88,z=-214962.81},radius=12000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=1809557376,surfaceAverageAltitude=-700,surfaceMaxAltitude=300,surfaceMinAltitude=-2900,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[12]={name="Madis Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=12,GM=265046609,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17520614,y=22184730,z=-309989.99},radius=15000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=700,surfaceMaxAltitude=1100,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[26]={name="Sanctuary",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9666,atmosphericEngineMaxAltitude=6935,biosphere="",classification="",bodyId=26,GM=68234043600,gravity=1.0000000427743831,fullAtmosphericDensityMaxAltitude=-30,habitability="",hasAtmosphere=true,isSanctuary=true,noAtmosphericDensityAltitude=7800,numSatellites=0,positionFromSun=0,center={x=-1404835,y=562655,z=-285074},radius=83400,safeAreaEdgeAltitude=0,size="L",spaceEngineMinAltitude=4230,surfaceArea=87406149632,surfaceAverageAltitude=80,surfaceMaxAltitude=500,surfaceMinAltitude=-60,systemZone=nil,territories=111632,type="",waterLevel=0,planetarySystemId=0},[6]={name="Sicari",description="Sicari is a typical desert planet; it has survived for millenniums and will continue to endure. While not the most habitable of environments it remains a relatively untouched and livable planet of the Alioth sector. The arkship geological survey reports large flatlands alongside steep plateaus.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.897,atmosphericEngineMaxAltitude=7725,biosphere="Desert",classification="Mesoplanet",bodyId=6,GM=10502547741,gravity=0.4081039739797361,fullAtmosphericDensityMaxAltitude=-625,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=8770,numSatellites=0,positionFromSun=6,center={x=52765536,y=27165538,z=52065535},radius=51100,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=4480,surfaceArea=32813432832,surfaceAverageAltitude=130,surfaceMaxAltitude=220,surfaceMinAltitude=50,systemZone="Average",territories=41072,type="Planet",waterLevel=nil,planetarySystemId=0},[7]={name="Sinnen",description="Sinnen is a an empty and rocky hell. With no atmosphere to speak of it is one of the least hospitable planets in the sector. The arkship geological survey reports mostly flatlands alongside deep ravines which look to have once been riverbeds. This planet simply looks to have dried up and died, likely from solar winds.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9226,atmosphericEngineMaxAltitude=10335,biosphere="Desert",classification="Mesoplanet",bodyId=7,GM=13033380591,gravity=0.4401121421448438,fullAtmosphericDensityMaxAltitude=-120,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=11620,numSatellites=1,positionFromSun=7,center={x=58665538,y=29665535,z=58165535},radius=54950,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=6270,surfaceArea=37944188928,surfaceAverageAltitude=317,surfaceMaxAltitude=360,surfaceMinAltitude=23,systemZone="Average",territories=48002,type="Planet",waterLevel=nil,planetarySystemId=0},[70]={name="Sinnen Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=70,GM=396912600,gravity=0.1360346539426409,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=58969616,y=29797945,z=57969449},radius=17000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=3631681280,surfaceAverageAltitude=-2050,surfaceMaxAltitude=-1950,surfaceMinAltitude=-2150,systemZone=nil,territories=4322,type="",waterLevel=nil,planetarySystemId=0},[110]={name="Symeon",description="Symeon is an ice planet mysteriously split at the equator by a band of solid desert. Exactly how this phenomenon is possible is unclear but some sort of weather anomaly may be responsible. The arkship geological survey reports a fairly diverse mix of flat-lands alongside mountainous formations.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9559,atmosphericEngineMaxAltitude=6920,biosphere="Ice, Desert",classification="Hybrid",bodyId=110,GM=9204742375,gravity=0.3920998898971822,fullAtmosphericDensityMaxAltitude=-30,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=7800,numSatellites=0,positionFromSun=11,center={x=14165536,y=-85634465,z=-934464.3},radius=49050,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=4230,surfaceArea=30233462784,surfaceAverageAltitude=39,surfaceMaxAltitude=450,surfaceMinAltitude=126,systemZone="High",territories=38882,type="Planet",waterLevel=nil,planetarySystemId=0},[4]={name="Talemai",description="Talemai is a planet in the final stages of an Ice Age. It seems likely that the planet was thrown into tumult by a cataclysmic volcanic event which resulted in its current state. The arkship geological survey reports large mountainous regions across the entire planet.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.8776,atmosphericEngineMaxAltitude=9685,biosphere="Barren",classification="Psychroplanet",bodyId=4,GM=14893847582,gravity=0.4641182439650478,fullAtmosphericDensityMaxAltitude=-78,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=10890,numSatellites=3,positionFromSun=4,center={x=-13234464,y=55765536,z=465536},radius=57500,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=5890,surfaceArea=41547563008,surfaceAverageAltitude=580,surfaceMaxAltitude=610,surfaceMinAltitude=520,systemZone="Average",territories=52922,type="Planet",waterLevel=nil,planetarySystemId=0},[42]={name="Talemai Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=42,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-13058408,y=55781856,z=740177.76},radius=15000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=720,surfaceMaxAltitude=850,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[40]={name="Talemai Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=40,GM=141264000,gravity=0.09602446196397631,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-13503090,y=55594325,z=769838.64},radius=12000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=1809557376,surfaceAverageAltitude=250,surfaceMaxAltitude=450,surfaceMinAltitude=0,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[41]={name="Talemai Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=41,GM=106830900,gravity=0.08802242599860607,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-12800515,y=55700259,z=325207.84},radius=11000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=1520530944,surfaceAverageAltitude=190,surfaceMaxAltitude=400,surfaceMinAltitude=0,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[8]={name="Teoma",description="[REDACTED] The arkship geological survey [REDACTED]. This planet should not be here.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.7834,atmosphericEngineMaxAltitude=5580,biosphere="Forest",classification="Mesoplanet",bodyId=8,GM=18477723600,gravity=0.48812434578525177,fullAtmosphericDensityMaxAltitude=15,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=6280,numSatellites=0,positionFromSun=8,center={x=80865538,y=54665536,z=-934463.94},radius=62000,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=3420,surfaceArea=48305131520,surfaceAverageAltitude=700,surfaceMaxAltitude=1100,surfaceMinAltitude=-200,systemZone="High",territories=60752,type="Planet",waterLevel=0,planetarySystemId=0},[3]={name="Thades",description="Thades is a scorched desert planet. Perhaps it was once teaming with life but now all that remains is ash and dust. The arkship geological survey reports a rocky mountainous planet bisected by a massive unnatural ravine; something happened to this planet.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.03552,atmosphericEngineMaxAltitude=32180,biosphere="Desert",classification="Thermoplanet",bodyId=3,GM=11776905000,gravity=0.49612641213015557,fullAtmosphericDensityMaxAltitude=150,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=32800,numSatellites=2,positionFromSun=3,center={x=29165536,y=10865536,z=65536},radius=49000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=21400,surfaceArea=30171856896,surfaceAverageAltitude=13640,surfaceMaxAltitude=13690,surfaceMinAltitude=370,systemZone="Low",territories=38882,type="Planet",waterLevel=nil,planetarySystemId=0},[30]={name="Thades Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=30,GM=211564034,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=29214402,y=10907080.695,z=433858.2},radius=14000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=60,surfaceMaxAltitude=300,surfaceMinAltitude=0,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[31]={name="Thades Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=31,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=29404193,y=10432768,z=19554.131},radius=15000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=70,surfaceMaxAltitude=350,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0}}}end;function SetupAtlas()b0=Atlas()for bB,bC in pairs(b0[0])do if aE==nil or bC.center.xaF then aF=bC.center.x end;if aG==nil or bC.center.yaH then aH=bC.center.y end end;b1=""local gn=1.1*(aF-aE)/1920;local go=1.4*(aH-aG)/1080;for bB,bC in pairs(b0[0])do local bY=960+bC.center.x/gn;local bZ=540+bC.center.y/go;b1=b1 ..''if not string.match(bC.name,"Moon")and not string.match(bC.name,"Sanctuary")and not string.match(bC.name,"Space")then b1=b1 ..""..bC.name..""end end;local cg=vec3(core.getConstructWorldPos())local bY=960+cg.x/gn;local bZ=540+cg.y/go;b1=b1 ..''b1=b1 .."You Are Here"b1=b1 ..[[]]b2=gn;b3=go;if screen_2 then screen_2.setHTML(''..b1)local cg=vec3(core.getConstructWorldPos())local bY=960+cg.x/gn;local bZ=540+cg.y/go;b1=''b1=b1 .."You Are Here"b4=screen_2.addContent((bY-80)/19.20,(bZ-80)/10.80,b1)end end;function PlanetRef()local function gp(gq)return type(gq)=='number'end;local function gr(gq)return type(tonumber(gq))=='number'end;local function gs(gt)return type(gt)=='table'end;local function gu(gv)return type(gv)=='string'end;local function gw(bC)return gs(bC)and gp(bC.x and bC.y and bC.z)end;local function gx(gy)return gs(gy)and gp(gy.latitude and gy.longitude and gy.altitude and gy.bodyId and gy.systemId)end;local gz=math.pi/180;local gA=180/math.pi;local epsilon=1e-10;local q=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local ch='::pos{'..q..','..q..','..q..','..q..','..q..'}'local utils=require('cpml.utils')local vec3=require('cpml.vec3')local gB=utils.clamp;local function float_eq(c6,c7)if c6==0 then return math.abs(c7)<1e-09 end;if c7==0 then return math.abs(c6)<1e-09 end;return math.abs(c6-c7)=0 then local hp=math.sqrt(ho)local fg=hn+hp;local fh=hn-hp;if fh>0 then return fi,fg,fh elseif fg>0 then return fi,fg,nil end end end;return nil,nil,nil end;function gS:closestBody(hq)assert(type(hq)=='table','Invalid coordinates.')local hr,fi;local hs=vec3(hq)for _,ht in pairs(self)do local hu=(ht.center-hs):len2()if(not fi or hu=0 and cf or 2*math.pi+cf;cd=math.pi/2-math.acos(cb.z/ac)end;return setmetatable({latitude=cd,longitude=ce,altitude=cc,bodyId=self.bodyId,systemId=self.planetarySystemId},MapPosition)end;function gH:convertToWorldCoordinates(gR)local hv=gu(gR)and gQ(gR)or gR;if hv.bodyId==0 then return vec3(hv.latitude,hv.longitude,hv.altitude)end;assert(gx(hv),'Argument 1 (mapPosition) is not an instance of "MapPosition".')assert(hv.systemId==self.planetarySystemId,'Argument 1 (mapPosition) has a different planetary system ID.')assert(hv.bodyId==self.bodyId,'Argument 1 (mapPosition) has a different planetary body ID.')local ck=math.cos(hv.latitude)return self.center+(self.radius+hv.altitude)*vec3(ck*math.cos(hv.longitude),ck*math.sin(hv.longitude),math.sin(hv.latitude))end;function gH:getAltitude(c9)return(vec3(c9)-self.center):len()-self.radius end;function gH:getDistance(c9)return(vec3(c9)-self.center):len()end;function gH:getGravity(c9)local hw=self.center-vec3(c9)local hx=hw:len2()return self.GM/hx*hw/math.sqrt(hx)end;return setmetatable(b5,{__call=function(_,...)return g_(...)end})end;function Keplers()local vec3=require('cpml.vec3')local PlanetRef=PlanetRef()local function gu(gv)return type(gv)=='string'end;local function gs(gt)return type(gt)=='table'end;local function float_eq(c6,c7)if c6==0 then return math.abs(c7)<1e-09 end;if c7==0 then return math.abs(c6)<1e-09 end;return math.abs(c6-c7)0 then hO=hN;hP=hO+hI/2 end;if hP>hI then hP=hP-hI end end;return{periapsis={position=hF,speed=hH/hD,circularOrbitSpeed=math.sqrt(hA/hD),altitude=hD-self.body.radius},apoapsis=hG and{position=hG,speed=hH/hE,circularOrbitSpeed=math.sqrt(hA/hE),altitude=hE-self.body.radius},currentVelocity=bC,currentPosition=cg,eccentricity=hC,period=hI,eccentricAnomaly=hK,meanAnomaly=hM,timeToPeriapsis=hO,timeToApoapsis=hP}end;local function hQ(hR)local ht=PlanetRef.BodyParameters(hR.planetarySystemId,hR.bodyId,hR.radius,hR.center,hR.GM)return setmetatable({body=ht},Kepler)end;return setmetatable(Kepler,{__call=function(_,...)return hQ(...)end})end;function Kinematics()local b7={}local hS=30000000/3600;local hT=hS*hS;local hU=100;local function hV(bC)return 1/math.sqrt(1-bC*bC/hT)end;function b7.computeAccelerationTime(hW,hX,hY)local hZ=hS*math.asin(hW/hS)return(hS*math.asin(hY/hS)-hZ)/hX end;function b7.computeDistanceAndTime(hW,hY,h_,i0,i1,i2)i1=i1 or 0;i2=i2 or 0;local i3=hW<=hY;local i4=i0*(i3 and 1 or-1)/h_;local i5=-i2/h_;local i6=i4+i5;if i3 and i6<=0 or not i3 and i6>=0 then return-1,-1 end;local i7,i8=0,0;if i4~=0 and i1>0 then local hZ=math.asin(hW/hS)local i9=math.pi*(i4/2+i5)local ia=i4*i1;local ib=hS*math.pi;local bC=function(gt)local cV=(i9*gt-ia*math.sin(math.pi*gt/2/i1)+ib*hZ)/ib;local ic=math.tan(cV)return hS*ic/math.sqrt(ic*ic+1)end;local id=i3 and function(gv)return gv>=hY end or function(gv)return gv<=hY end;i8=2*i1;if id(bC(i8))then local ie=0;while math.abs(i8-ie)>0.5 do local gt=(i8+ie)/2;if id(bC(gt))then i8=gt else ie=gt end end end;local ig=hW;local ih=i8/hU;for ii=1,hU do local bS=bC(ii*ih)i7=i7+(bS+ig)*ih/2;ig=bS end;if i8<2*i1 then return i7,i8 end;hW=ig end;local hZ=hS*math.asin(hW/hS)local bE=(hS*math.asin(hY/hS)-hZ)/i6;local ij=hT*math.cos(hZ/hS)/i6;local ac=ij-hT*math.cos((i6*bE+hZ)/hS)/i6;return ac+i7,bE+i8 end;function b7.computeTravelTime(hW,hX,ac)if ac==0 then return 0 end;if hX>0 then local hZ=hS*math.asin(hW/hS)local ij=hT*math.cos(hZ/hS)/hX;return(hS*math.acos(hX*(ij-ac)/hT)-hZ)/hX end;if hW==0 then return-1 end;assert(hW>0,'Acceleration and initial speed are both zero.')return ac/hW end;function b7.lorentz(bC)return hV(bC)end;return b7 end;function safeZone(ik)local gN=500000;local il,im,io=math.huge;local ip=false;local iq=vec3({13771471,7435803,-128971})local ir=18000000;il=vec3(ik):dist(iq)if il0 or bN==0 and an<10000)then for _,bC in pairs(door)do bC.toggle()end end;if switch then for _,bC in pairs(switch)do bC.toggle()end end;if forcefield and(bN>0 or bN==0 and an<10000)then for _,bC in pairs(forcefield)do bC.toggle()end end;SaveDataBank()if button then button.activate()end end;local function it(ee,iu)if iu==nil then iu=false end;if Nav.axisCommandManager:getAxisCommandType(0)~=axisCommandType.byThrottle and not iu then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,ee)end;local function iv(ee,iu)if iu==nil then iu=false end;if Nav.axisCommandManager:getAxisCommandType(0)~=axisCommandType.byTargetSpeed and not iu then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setTargetSpeedCommand(axisCommandId.longitudinal,ee)end;function script.onTick(iw)if iw=="tenthSecond"then if j()>0 and not WasInAtmo then if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and AtmoSpeedAssist and(AltitudeHold or Reentry)then z=1;Nav.control.cancelCurrentControlMasterMode()D=false end end;if AutopilotTargetName~="None"then if panelInterplanetary==nil then SetupInterplanetaryPanel()end;if AutopilotTargetName~=nil then local ix=CustomTarget~=nil;planetMaxMass=GetAutopilotMaxMass()system.updateData(interplanetaryHeaderText,'{"label": "Target", "value": "'..AutopilotTargetName..'", "unit":""}')travelTime=GetAutopilotTravelTime()if ix and not Autopilot then ac=(vec3(core.getConstructWorldPos())-CustomTarget.position):len()else ac=(AutopilotTargetCoords-vec3(core.getConstructWorldPos())):len()end;if not TurnBurn then a0,a1=GetAutopilotBrakeDistanceAndTime(be)a2,a3=GetAutopilotBrakeDistanceAndTime(MaxGameVelocity)else a0,a1=GetAutopilotTBBrakeDistanceAndTime(be)a2,a3=GetAutopilotTBBrakeDistanceAndTime(MaxGameVelocity)end;local dy,dz=getDistanceDisplayString(ac)system.updateData(widgetDistanceText,'{"label": "distance", "value": "'..dy..'", "unit":"'..dz..'"}')system.updateData(widgetTravelTimeText,'{"label": "Travel Time", "value": "'..FormatTimeString(travelTime)..'", "unit":""}')dy,dz=getDistanceDisplayString(a0)system.updateData(widgetCurBrakeDistanceText,'{"label": "Cur Brake distance", "value": "'..dy..'", "unit":"'..dz..'"}')system.updateData(widgetCurBrakeTimeText,'{"label": "Cur Brake Time", "value": "'..FormatTimeString(a1)..'", "unit":""}')dy,dz=getDistanceDisplayString(a2)system.updateData(widgetMaxBrakeDistanceText,'{"label": "Max Brake distance", "value": "'..dy..'", "unit":"'..dz..'"}')system.updateData(widgetMaxBrakeTimeText,'{"label": "Max Brake Time", "value": "'..FormatTimeString(a3)..'", "unit":""}')system.updateData(widgetMaxMassText,'{"label": "Maximum Mass", "value": "'..e("%.2f",planetMaxMass/1000)..'", "unit":" Tons"}')dy,dz=getDistanceDisplayString(AutopilotTargetOrbit)system.updateData(widgetTargetOrbitText,'{"label": "Target Orbit", "value": "'..e("%.2f",dy)..'", "unit":"'..dz..'"}')if j()>0 and not WasInAtmo then system.removeDataFromWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)system.removeDataFromWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)system.removeDataFromWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)system.removeDataFromWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)system.removeDataFromWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)WasInAtmo=true end;if j()==0 and WasInAtmo then if system.updateData(widgetMaxBrakeTimeText,widgetMaxBrakeTime)==1 then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;if system.updateData(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)==1 then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;if system.updateData(widgetCurBrakeTimeText,widgetCurBrakeTime)==1 then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;if system.updateData(widgetCurBrakeDistanceText,widgetCurBrakeDistance)==1 then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;if system.updateData(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)==1 then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end;WasInAtmo=false end end else HideInterplanetaryPanel()end;if warpdrive~=nil then if f(warpdrive.getData()).destination~="Unknown"and f(warpdrive.getData()).distance>400000 then warpdrive.show()showWarpWidget=true else warpdrive.hide()showWarpWidget=false end end elseif iw=="oneSecond"then ak=false;RefreshLastMaxBrake(nil,true)updateDistance()updateRadar()updateWeapons()local ct={}local dK=GetFlightStyle()DrawOdometer(ct,a5,TotalDistanceTravelled,dK,a6)if ShouldCheckDamage then CheckDamage(ct)end;ae=table.concat(ct,"")collectgarbage("collect")elseif iw=="fiveSecond"then al=dbHud_1.getStringValue("SPBAutopilotTargetName")if al~=nil and al~=""and al~="SatNavNotChanged"then local bD=json.decode(dbHud_1.getStringValue("SavedLocations"))if bD~=nil then _G["SavedLocations"]=bD;local cr=-1;local cn;for bB,bC in pairs(SavedLocations)do if bC.name and bC.name=="SatNav Location"then cr=bB;break end end;if cr~=-1 then cn=SavedLocations[cr]cr=-1;for bB,bC in pairs(b0[0])do if bC.name and bC.name=="SatNav Location"then cr=bB;break end end;if cr>-1 then b0[0][cr]=cn end;UpdateAtlasLocationsList()W=cn.name.." position updated"end end;for i=1,#AtlasOrdered do if AtlasOrdered[i].name==al then AutopilotTargetIndex=i;system.print("Index = "..AutopilotTargetIndex.." "..AtlasOrdered[i].name)UpdateAutopilotTarget()dbHud_1.setStringValue("SPBAutopilotTargetName","SatNavNotChanged")break end end end elseif iw=="msgTick"then local ct={}DisplayMessage(ct,"empty")W="empty"unit.stopTimer("msgTick")ab=3 elseif iw=="animateTick"then bb=true;ba=false;a9=0;aa=0;unit.stopTimer("animateTick")elseif iw=="hudTick"then local ct={}HUDPrologue(ct)if showHud then UpdateHud(ct)else DisplayOrbitScreen(ct)DrawWarnings(ct)end;HUDEpilogue(ct)ct[#ct+1]=e([[]],ResolutionX,ResolutionY)if W~="empty"then DisplayMessage(ct,W)end;if o()==0 and userControlScheme=="virtual joystick"then if DisplayDeadZone then DrawDeadZone(ct)end end;if o()==1 and screen_1 and screen_1.getMouseY()~=-1 then SetButtonContains()DrawButtons(ct)if screen_1.getMouseState()==1 then CheckButtons()end;ct[#ct+1]=e([[]],E,F,a9,aa)elseif system.isViewLocked()==0 then if o()==1 and V then SetButtonContains()DrawButtons(ct)if not ba and not bb then local iy=table.concat(ct,"")ct={}ct[#ct+1]=e("",ResolutionX,ResolutionY)ct[#ct+1]=b1;ct[#ct+1]=iy;ct[#ct+1]=""ba=true;ct[#ct+1]=[[]]unit.setTimer("animateTick",0.5)local content=table.concat(ct,"")system.setScreen(content)elseif bb then local iy=table.concat(ct,"")ct={}ct[#ct+1]=e("",ResolutionX,ResolutionY)ct[#ct+1]=b1;ct[#ct+1]=iy;ct[#ct+1]=""end;if not ba then ct[#ct+1]=e([[]],E,F,a9,aa)end else CheckButtons()end else if not V and o()==0 then CheckButtons()if ac>DeadZone then if DisplayDeadZone then DrawCursorLine(ct)end end else SetButtonContains()DrawButtons(ct)end;ct[#ct+1]=e([[]],E,F,a9,aa)end;ct[#ct+1]=[[]]content=table.concat(ct,"")if not DidLogOutput then system.logInfo(LastContent)DidLogOutput=true end elseif iw=="apTick"then am=j()>0;local bE=system.getTime()local iz=bE-bj;bj=bE;local cw=vec3(core.getConstructWorldOrientationForward())local cx=vec3(core.getConstructWorldOrientationRight())local iA=vec3(core.getConstructWorldOrientationUp())local cy=vec3(core.getWorldVertical())local iB=vec3(core.getConstructWorldPos())local dM=getRoll(cy,cw,cx)local dN=dM/180*math.pi;local dO=math.cos(dN)local dP=math.sin(dN)local cz=getPitch(cy,cw,cx)local iC=getPitch(cy,cw,cx*dO+iA*dP)local iD=-math.deg(cQ(iA,bd,cw))local iE=math.deg(cQ(cx,bd,cw))bi=am and iD<-YawStallAngle or iD>YawStallAngle or iE<-PitchStallAngle or iE>PitchStallAngle;bg=system.getMouseDeltaX()bh=system.getMouseDeltaY()if InvertMouse and not V then bh=-bh end;P=0;T=0;O=0;bd=vec3(core.getWorldVelocity())be=vec3(bd):len()sys=b6[0]planet=sys:closestBody(core.getConstructWorldPos())kepPlanet=b9(planet)orbit=kepPlanet:orbitalParameters(core.getConstructWorldPos(),bd)aj=hoverDetectGround()local bP=planet:getGravity(core.getConstructWorldPos()):len()*n()bk=0;b8=core.getMaxKinematicsParametersAlongAxis("ground",core.getConstructOrientationUp())[1]w,x,y,_=safeZone(iB)if o()==1 and screen_1 and screen_1.getMouseY()~=-1 then a9=screen_1.getMouseX()*ResolutionX;aa=screen_1.getMouseY()*ResolutionY elseif system.isViewLocked()==0 then if o()==1 and V then if not ba then a9=a9+bg;aa=aa+bh end else a9=0;aa=0 end else a9=a9+bg;aa=aa+bh;ac=math.sqrt(a9*a9+aa*aa)if not V and o()==0 then if userControlScheme=="virtual joystick"then if a9>0 and a9>DeadZone then P=P-(a9-DeadZone)*MouseXSensitivity elseif a9<0 and a90 and aa>DeadZone then O=O-(aa-DeadZone)*MouseYSensitivity elseif aa<0 and aa8334;if be>SpaceSpeedLimit/3.6 and not am and not Autopilot and not iF then W="Space Speed Engine Shutoff reached"if Nav.axisCommandManager:getAxisCommandType(0)==1 then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)z=0 end;if not iF and LastIsWarping then if not BrakeIsOn then BrakeToggle()end;if Autopilot then ToggleAutopilot()end end;LastIsWarping=iF;if am and j()>0.09 then if be>bm/3.6 and not AtmoSpeedAssist and not ar then BrakeIsOn=true;ar=true elseif not AtmoSpeedAssist and ar then if be85)and be>=bm/3.6-1 then BrakeIsOn=false;ProgradeIsOn=false;J=true;ag=false;ai=true;Autopilot=false;BeginReentry()else iv(math.floor(bm))z=0 end elseif be>I then AlignToWorldVector(vec3(bd),0.01)end end;if RetrogradeIsOn then if am then RetrogradeIsOn=false elseif be>I then AlignToWorldVector(-vec3(bd))end end;if not ProgradeIsOn and ag then if j()==0 then J=true;BeginReentry()ag=false;ai=true else ag=false;ToggleAutopilot()end end;local ei=vec3(core.getWorldVertical())*-1;local eg=bd.x*ei.x+bd.y*ei.y+bd.z*ei.z;if ai and CustomTarget~=nil and(anHoldAltitude-200)and be*3.6>bm-100 and math.abs(eg)<20 and j()>=0.1 and(CustomTarget.position-iB):len()>2000+an then ToggleAutopilot()ai=false end;if VertTakeOff then bc=true;if eg<-30 then W="Unable to achieve lift. Safety Landing."a8=0;bc=autoRollPreference;VertTakeOff=false;BrakeLanding=true elseif antigrav and not ExternalAGG and antigrav.getState()==1 then if an0 then BrakeIsOn=true;a8=0 elseif eg<-30 then BrakeIsOn=true;a8=15 elseif an>=antigrav.getBaseAltitude()then BrakeIsOn=true;a8=0;VertTakeOff=false;W="Takeoff complete. Singularity engaged"end else if j()>0.08 then bn=0;BrakeIsOn=false;a8=20 elseif j()<0.08 and j()>0 then BrakeIsOn=false;if bz then bn=0;a8=20 else a8=0;bn=36;iv(3500)end else bc=autoRollPreference;IntoOrbit=true;bx=false;CancelIntoOrbit=false;br=false;bp=nil;bq=nil;if bw==nil then bw=planet end;VertTakeOff=false end end;if bn~=nil then if vTpitchPID==nil then vTpitchPID=pid.new(2*0.01,0,2*0.1)end;local iH=utils.clamp(bn-iC,-PitchStallAngle*0.85,PitchStallAngle*0.85)vTpitchPID:inject(iH)local iI=utils.clamp(vTpitchPID:get(),-1,1)O=iI end end;if IntoOrbit then if bw==nil then if VectorToTarget then bw=a4 else bw=planet end end;if not bu then if bw.hasAtmosphere then bv=math.floor(bw.radius*(TargetOrbitRadius-1)+bw.noAtmosphericDensityAltitude)else bv=math.floor(bw.radius*(TargetOrbitRadius-1)+bw.surfaceMaxAltitude)end;bu=true end;if AltitudeHold or VectorToTarget then if not ah then bv=HoldAltitude;br=true;AltitudeHold=false end;if VectorToTarget then bt.VectorToTarget=VectorToTarget;VectorToTarget=false end end;local iJ,iK=b9(bw):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-bw.center):len()-bw.radius)local iL=dM;if orbit.periapsis~=nil and orbit.eccentricity<1 and an>bv and an=iN-3 then z=ee;it(ee)else z=0.05;it(0.05)end end;if orbit.apoapsis~=nil then if orbit.periapsis.altitude>bv*0.95 and orbit.periapsis.altitudeorbit.periapsis.altitude and orbit.apoapsis.altitude<=orbit.periapsis.altitude*1.35 then BrakeIsOn=false;z=0;it(0)bx=true;if iC>2 or iC<-2 then bp=0 else bo=nil;bs=false;bu=false;bw=nil;bc=autoRollPreference;W="Orbit established"if bt.VectorToTarget then VectorToTarget=bt.VectorToTarget end;bt.VectorToTarget=false;CancelIntoOrbit=false;IntoOrbit=false;br=false;bp=nil;bq=nil;bw=nil end else bo="Adjusting Orbit"bs=true;if eg>125 then iM(0.5,-65)BrakeIsOn=false elseif orbit.periapsis.altitude<0 then if be+10>iK then if eg>5 then iM(0.5,-65)BrakeIsOn=false elseif eg<-5 then iM(0.5,65)BrakeIsOn=false else it(0)BrakeIsOn=not BrakeIsOn end elseif be-100 and orbit.periapsis.altitudeiK then it(0)BrakeIsOn=not BrakeIsOn elseif be+20>iK then if eg>35 then iM(0.5,-80)BrakeIsOn=false elseif eg<-35 then iM(0.5,80)BrakeIsOn=false end elseif be-20orbit.periapsis.altitude*1.3 then it(0)BrakeIsOn=not BrakeIsOn end end end end else local iO=2.75;local iP=math.abs(utils.round(iJ*iO))local iQ=iP%50;if iQ>0 then iP=iP-iQ+50 end;BrakeIsOn=false;if not br then local iR=false;local iS=false;if an=bp-1 then iR=true else iR=false end;if iL<=bq+1 and iL>=bq-1 then iS=true else iS=false end;if iR and iS then bp=nil;bq=nil;br=true end else if an=bv*0.8 and an=bv*1.15 and anbv*1.5 then bo="Reentering orbital corridor"if eg<-100 then bp=45;iP=iP*1.25 else bp=-80;iP=iP*0.75 end end end;iv(math.floor(iP))end;if bp~=nil then if OrbitPitchPID==nil then OrbitPitchPID=pid.new(2*0.01,0,2*0.1)end;local iT=bp-iC;OrbitPitchPID:inject(iT)local iU=utils.clamp(OrbitPitchPID:get(),-0.5,0.5)O=iU end;if bq~=nil then if iC<85 then local iV=math.max(autoRollFactor,0.01)/4;if OrbitRollPID==nil then OrbitRollPID=pid.new(iV*0.01,0,iV*0.1)end;local iW=bq-iL;OrbitRollPID:inject(iW)local iX=utils.clamp(OrbitRollPID:get(),-0.5,0.5)T=iX end end elseif CancelIntoOrbit then bu=false;bw=nil;it(0)CancelIntoOrbit=false end;if Autopilot and j()==0 and not ag then local iY,iZ=AutopilotTargetCoords,false;if CustomTarget~=nil and CustomTarget.planetname~="Space"then AutopilotRealigned=true;if not TargetSet then local i_=(CustomTarget.position-a4.center):normalize()local j0=i_:project_on_plane((a4.center-iB):normalize()):normalize()local j1=a4.center+j0*(a4.radius+AutopilotTargetOrbit)local j2=CustomTarget.position+(CustomTarget.position-a4.center):normalize()*(AutopilotTargetOrbit-a4:getAltitude(CustomTarget.position))if(iB-j1):len()<(iB-j2):len()then iY=j1;AutopilotTargetCoords=iY else iY=CustomTarget.position+(CustomTarget.position-a4.center):normalize()*(AutopilotTargetOrbit-a4:getAltitude(CustomTarget.position))AutopilotTargetCoords=iY end;local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)iZ=true;TargetSet=true end;AutopilotPlanetGravity=0 elseif CustomTarget~=nil and CustomTarget.planetname=="Space"then AutopilotPlanetGravity=0;iZ=true;TargetSet=true;AutopilotRealigned=true;iY=CustomTarget.position+(iB-CustomTarget.position)*AutopilotTargetOrbit elseif CustomTarget==nil then AutopilotPlanetGravity=0;if not TargetSet then local i_=(iB+bd*100000-a4.center):normalize()local j0=i_:project_on_plane((a4.center-iB):normalize()):normalize()if j0:len()<1 then i_=(iB+vec3(core.getConstructWorldOrientationForward())*100000-a4.center):normalize()j0=i_:project_on_plane((a4.center-iB):normalize()):normalize()end;iY=a4.center+j0*(a4.radius+AutopilotTargetOrbit)AutopilotTargetCoords=iY;TargetSet=true;iZ=true;AutopilotRealigned=true;local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)end end;AutopilotDistance=(vec3(iY)-vec3(core.getConstructWorldPos())):len()local ff,fg,fh=b6:getPlanetarySystem(0):castIntersections(iB,bd:normalize(),function(fi)if fi.noAtmosphericDensityAltitude>0 then return fi.radius+fi.noAtmosphericDensityAltitude else return fi.radius+fi.surfaceMaxAltitude*1.5 end end)local fj=fg;if fh~=nil and fg~=nil then fj=math.min(fh,fg)end;if fj~=nil and fj300 and AutopilotAccelerating then local dv=vec3(iY)-vec3(core.getConstructWorldPos())local j4=utils.clamp(math.deg(cQ(iA,bd:normalize(),dv:normalize()))*be/500,-90,90)local j5=utils.clamp(math.deg(cQ(cx,bd:normalize(),dv:normalize()))*be/500,-90,90)if math.abs(j4)<20 and math.abs(j5)<20 then j4=j4*2;j5=j5*2 end;if math.abs(j4)<2 and math.abs(j5)<2 then j4=j4*2;j5=j5*2 end;local iD=-math.deg(cQ(iA,cw,bd:normalize()))local iE=-math.deg(cQ(cx,cw,bd:normalize()))if apPitchPID==nil then apPitchPID=pid.new(2*0.01,0,2*0.1)end;apPitchPID:inject(j5-iE)local j6=utils.clamp(apPitchPID:get(),-1,1)O=O+j6;if apYawPID==nil then apYawPID=pid.new(2*0.01,0,2*0.1)end;apYawPID:inject(j4-iD)local j7=utils.clamp(apYawPID:get(),-1,1)P=P+j7;iZ=true;if math.abs(j4)>2 or math.abs(j5)>2 then AutopilotStatus="Adjusting Trajectory"else AutopilotStatus="Accelerating"end end;if j3=MaxGameVelocity or fH==0 and G then AutopilotAccelerating=false;AutopilotStatus="Cruising"AutopilotCruising=true;it(0)z=0 end;if AutopilotDistance<=a0 then AutopilotAccelerating=false;AutopilotStatus="Braking"AutopilotBraking=true;it(0)z=0;G=false end elseif AutopilotBraking then if AutopilotStatus~="Orbiting to Target"then BrakeIsOn=true;S=1 end;if TurnBurn then it(100,true)z=1 end;local _,iK=b9(a4):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-planet.center):len()-planet.radius)local dv;if CustomTarget~=nil then dv=CustomTarget.position-iB end;if CustomTarget~=nil and CustomTarget.planetname=="Space"and be<50 then W="Autopilot complete, arrived at space location"AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"elseif CustomTarget~=nil and CustomTarget.planetname~="Space"and be<=iK and(orbit.apoapsis==nil or orbit.periapsis==nil or orbit.apoapsis.altitude<=0 or orbit.periapsis.altitude<=0)then W="Autopilot complete, proceeding with reentry"AutopilotTargetCoords=CustomTarget.position;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"it(0)z=0;G=false;ProgradeIsOn=true;ag=true;local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)elseif orbit.periapsis~=nil and orbit.periapsis.altitude>0 and orbit.eccentricity<1 then AutopilotStatus="Circularizing"local _,iK=b9(a4):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-planet.center):len()-planet.radius)if be<=iK then if CustomTarget~=nil then if bd:normalize():dot(dv:normalize())>0.4 then AutopilotStatus="Orbiting to Target"if not WaypointSet then BrakeIsOn=false;local cA=zeroConvertToMapPosition(a4,CustomTarget.position)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)WaypointSet=true end else W="Autopilot complete, proceeding with reentry"AutopilotTargetCoords=CustomTarget.position;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"it(0)z=0;G=false;ProgradeIsOn=true;ag=true;BrakeIsOn=false;local cA=zeroConvertToMapPosition(a4,CustomTarget.position)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)WaypointSet=false end else BrakeIsOn=false;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"W="Autopilot completed, orbit established"S=0;z=0;G=false;if CustomTarget~=nil and CustomTarget.planetname~="Space"then ProgradeIsOn=true;ag=true end end end end elseif AutopilotCruising then if AutopilotDistance<=a0 then AutopilotAccelerating=false;AutopilotStatus="Braking"AutopilotBraking=true end;local fH=unit.getThrottle()if AtmoSpeedAssist then fH=z end;if fH>0 then AutopilotAccelerating=true;AutopilotStatus="Accelerating"AutopilotCruising=false end else if iG then if not AutopilotRealigned and CustomTarget==nil or not AutopilotRealigned and CustomTarget~=nil and CustomTarget.planetname~="Space"then if not ag then AutopilotTargetCoords=vec3(a4.center)+(AutopilotTargetOrbit+a4.radius)*vec3(core.getConstructWorldOrientationRight())AutopilotShipUp=core.getConstructWorldOrientationUp()AutopilotShipRight=core.getConstructWorldOrientationRight()end;AutopilotRealigned=true elseif iG then AutopilotAccelerating=true;AutopilotStatus="Accelerating"if not G then it(AutopilotInterplanetaryThrottle,true)z=round(AutopilotInterplanetaryThrottle,2)G=true;BrakeIsOn=false end end end end elseif Autopilot and(CustomTarget~=nil and CustomTarget.planetname~="Space"and j()>0)then W="Autopilot complete, proceeding with reentry"AutopilotTargetCoords=CustomTarget.position;BrakeIsOn=false;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"S=0;it(0)z=0;G=false;ProgradeIsOn=true;ag=true;local cA=zeroConvertToMapPosition(a4,CustomTarget.position)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)end;if U then bc=true;local j5=0;local cg=vec3(core.getConstructWorldPos())+vec3(unit.getMasterPlayerRelativePosition())local j8=cg-vec3(core.getConstructWorldPos())local j9=vec3(j8):project_on(vec3(core.getConstructWorldOrientationForward())):len()local ja=vec3(j8):project_on(vec3(core.getConstructWorldOrientationRight())):len()local ac=math.sqrt(j9*j9+ja*ja)AlignToWorldVector(j8:normalize())local jb=40;local jc=acje then if pitchPID==nil then pitchPID=pid.new(2*0.01,0,2*0.1)end;pitchPID:inject(j5-cz)local j6=pitchPID:get()O=j6 end end;if AltitudeHold or BrakeLanding or Reentry or VectorToTarget or LockPitch~=nil then local cB=unit.getClosestPlanetInfluence()>0;local jf=HoldAltitude-an;local jg=500+be;local jh=1;if AutoTakeoff then jh=utils.clamp(be/100,0.1,1)end;local j5=(utils.smoothstep(jf,-jg,jg)-0.5)*2*MaxPitch*jh;if not Reentry and not ag and not VectorToTarget and cw:dot(bd:normalize())<0.99 then j5=(utils.smoothstep(jf,-jg*utils.clamp(20-19*j()*10,1,20),jg*utils.clamp(20-19*j()*10,1,20))-0.5)*2*MaxPitch*utils.clamp(2-j()*10,1,2)*jh end;if not AltitudeHold then j5=0 end;if LockPitch~=nil then if cB and not IntoOrbit then j5=LockPitch else LockPitch=nil end end;bc=true;local ji=O;if Reentry then local ReentrySpeed=math.floor(bm)local jj,jk=b7.computeDistanceAndTime(be,ReentrySpeed/3.6,n(),0,0,LastMaxBrake-planet.gravity*9.8*n())local jl=an-(planet.noAtmosphericDensityAltitude+5000)if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and an>planet.noAtmosphericDensityAltitude+5000 and be<=ReentrySpeed/3.6 and be>ReentrySpeed/3.6-10 and math.abs(bd:normalize():dot(cw))>0.9 then Nav.control.cancelCurrentControlMasterMode()z=0 elseif Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byThrottle and(jj>-1 and jl<=jj or an<=planet.noAtmosphericDensityAltitude+5000)then BrakeIsOn=true else BrakeIsOn=false end;iv(ReentrySpeed,true)if not J then j5=-80;if j()>0.02 then W="PARACHUTE DEPLOYED"Reentry=false;BrakeLanding=true;j5=0;bc=autoRollPreference end elseif planet.noAtmosphericDensityAltitude>0 and an>planet.noAtmosphericDensityAltitude+5000 then bc=true elseif an<=planet.noAtmosphericDensityAltitude+5000 then iv(ReentrySpeed)if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)==bm then J=false;Reentry=false;bc=true end end end;if be>I and not ah and not VectorToTarget and not BrakeLanding and ForceAlignment then AlignToWorldVector(vec3(bd))end;if(VectorToTarget or ah)and AutopilotTargetIndex>0 and j()>0.01 then local dv;if CustomTarget~=nil then dv=CustomTarget.position-vec3(core.getConstructWorldPos())else dv=a4.center-iB end;local j4=math.deg(cQ(cy:normalize(),bd,dv))*2;local jm=math.rad(math.abs(dM))if be>minRollVelocity and j()>0.01 then local jn=utils.clamp(90-j5*2,-90,90)bk=utils.clamp(j4*2,-jn,jn)local jo=j4;j4=utils.clamp(utils.clamp(j4,-YawStallAngle*0.85,YawStallAngle*0.85)*math.cos(jm)+4*(iC-j5)*math.sin(math.rad(dM)),-YawStallAngle*0.85,YawStallAngle*0.85)j5=utils.clamp(utils.clamp(j5*math.cos(jm),-PitchStallAngle*0.85,PitchStallAngle*0.85)+math.abs(utils.clamp(math.abs(jo)*math.sin(jm),-PitchStallAngle*0.85,PitchStallAngle*0.85)),-PitchStallAngle*0.85,PitchStallAngle*0.85)else bk=0;j4=utils.clamp(j4,-YawStallAngle*0.85,YawStallAngle*0.85)end;local jp=iD-j4;if not bi and be>minRollVelocity and j()>0.01 then if yawPID==nil then yawPID=pid.new(2*0.01,0,2*0.1)end;yawPID:inject(jp)local j7=utils.clamp(yawPID:get(),-1,1)P=P+j7 elseif am and aj>-1 or be0.01 then if(iD<-YawStallAngle or iD>YawStallAngle)and j()>0.01 then AlignToWorldVector(bd)end;if(iE<-PitchStallAngle or iE>PitchStallAngle)and j()>0.01 then j5=utils.clamp(iC-iE,iC-PitchStallAngle*0.85,iC+PitchStallAngle*0.85)end end;if CustomTarget~=nil and not ah then local jq=planet:getAltitude(CustomTarget.position)local jl=math.sqrt(dv:len()^2-(an-jq)^2)local jr=LastMaxBrakeInAtmo;if jr then jr=jr*utils.clamp(be/100,0.1,1)*j()else jr=LastMaxBrake end;if j()<0.01 then jr=LastMaxBrake end;local js=bd:len()-math.abs(eg)local jt=vec3(core.getWorldAirFrictionAcceleration())local ju=math.sqrt(jt:len()-jt:project_on(ei):len())*n()if be>100 then a0,a1=b7.computeDistanceAndTime(be,100,n(),0,0,jr+ju)local jv,jw=b7.computeDistanceAndTime(100,0,n(),0,0,jr/2)a0=a0+jv else a0,a1=b7.computeDistanceAndTime(be,0,n(),0,0,jr/2)end;StrongBrakes=true;if not ah and not Reentry and jl<=a0+be*iz/2 and(bd:project_on_plane(cy):normalize():dot(dv:project_on_plane(cy):normalize())>0.99 or VectorStatus=="Finalizing Approach")then VectorStatus="Finalizing Approach"it(0)z=0;if AltitudeHold then ToggleAltitudeHold()VectorToTarget=true end;BrakeIsOn=true elseif not AutoTakeoff then BrakeIsOn=false end;if VectorStatus=="Finalizing Approach"and(js<0.1 or jl<0.1 or LastDistanceToTarget~=nil and LastDistanceToTargetplanet.noAtmosphericDensityAltitude and not(ah or Reentry)then if CustomTarget~=nil and a4.name==planet.name then local dv=CustomTarget.position-vec3(core.getConstructWorldPos())local jq=planet:getAltitude(CustomTarget.position)local jl=math.sqrt(dv:len()^2-(an-jq)^2)local jr=LastMaxBrakeInAtmo;if not bx and jl>100000 then bu=false;IntoOrbit=true else jr=LastMaxBrake;a0,a1=b7.computeDistanceAndTime(be,0,n(),0,0,jr/2)StrongBrakes=true;if jl<=a0+be*iz/2 and bd:project_on_plane(cy):normalize():dot(dv:project_on_plane(cy):normalize())>0.99 then if planet.hasAtmosphere then BrakeIsOn=false;ProgradeIsOn=false;J=true;ag=false;ai=true;Autopilot=false;BeginReentry()end end;LastDistanceToTarget=jl end end end;if j()==0 and(AltitudeHold and HoldAltitude>planet.noAtmosphericDensityAltitude)and not(ah or VectorToTarget or IntoOrbit or Reentry)then if not bx then IntoOrbit=true end end;if bi and j()>0.01 and aj==-1 and be>minRollVelocity and VectorStatus~="Finalizing Approach"then AlignToWorldVector(bd)j5=utils.clamp(iC-iE,iC-PitchStallAngle*0.85,iC+PitchStallAngle*0.85)end;O=ji;local fQ=-1;if BrakeLanding then j5=0;local jx=false;local jy=30;if b8~=nil and b8>0 then local ju=0;local dS=utils.clamp(j(),0.4,2)local jr=LastMaxBrakeInAtmo*utils.clamp(be/100,0.1,1)*dS;local jz=b8*dS+jr+ju-bP;local jA=jr/2+ju-bP;local jB=be-math.sqrt(math.abs(jA/2)*20/(0.5*n()))*utils.sign(jA)if jB<0 then jB=0 end;local jC;if be>100 then local jD,_=b7.computeDistanceAndTime(be,100,n(),0,0,jr)local jE,_=b7.computeDistanceAndTime(100,0,n(),0,0,math.sqrt(jr))jC=jD+jE else jC=b7.computeDistanceAndTime(be,0,n(),0,0,math.sqrt(jr))end;if jC<20 then BrakeIsOn=false else local jF=0;if jB>100 then local jG,_=b7.computeDistanceAndTime(jB,100,n(),0,0,jz)local jH,_=b7.computeDistanceAndTime(100,0,n(),0,0,b8*dS+math.sqrt(jr)+ju-bP)jF=jG+jH else jF,_=b7.computeDistanceAndTime(jB,0,n(),0,0,b8*dS+math.sqrt(jr)+ju-bP)end;jF=(jF+15+be*iz)*1.1;local jI=CustomTarget~=nil and planet:getAltitude(CustomTarget.position)>0 and CustomTarget.safe;if jI then local jq=planet:getAltitude(CustomTarget.position)local jJ=an-jq-100;local dv=CustomTarget.position-vec3(core.getConstructWorldPos())local jK=math.sqrt(dv:len()^2-(an-jq)^2)if jK>100 then jI=false elseif jJ<=jF or jF==-1 then BrakeIsOn=true;jx=true else BrakeIsOn=false;jx=true end end;if not jI and CalculateBrakeLandingSpeed then if jF>=jy then BrakeIsOn=true else BrakeIsOn=false end;jx=true end end end;if Nav.axisCommandManager:getAxisCommandType(0)==1 then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setTargetGroundAltitude(500)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(500)fQ=aj;if fQ>-1 then bc=autoRollPreference;if be<1 or bd:normalize():dot(cy)<0 then BrakeLanding=false;AltitudeHold=false;GearExtended=true;Nav.control.extendLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)a8=0;BrakeIsOn=true else BrakeIsOn=true end elseif StrongBrakes and bd:normalize():dot(-ei)<0.999 then BrakeIsOn=true elseif eg<-brakeLandingRate and not jx then BrakeIsOn=true elseif not jx then BrakeIsOn=false end end;if AutoTakeoff or ah then local ff,fh,fg;if AutopilotTargetCoords~=nil then ff,fh,fg=b6:getPlanetarySystem(0):castIntersections(iB,(AutopilotTargetCoords-iB):normalize(),function(fi)return fi.radius+fi.noAtmosphericDensityAltitude end)end;if antigrav and antigrav.getState()==1 then if an>=HoldAltitude-50 then AutoTakeoff=false;BrakeIsOn=true;it(0)z=0 else HoldAltitude=antigrav.getBaseAltitude()end elseif math.abs(j5)<15 and an/HoldAltitude>0.75 then AutoTakeoff=false;if not ah then if Nav.axisCommandManager:getAxisCommandType(0)==0 and not AtmoSpeedAssist then Nav.control.cancelCurrentControlMasterMode()end elseif ah and be-1;local jM=cz;if(VectorToTarget or ah)and not jL and be>minRollVelocity and j()>0.01 then local jm=math.rad(math.abs(dM))jM=cz*math.abs(math.cos(jm))+iE*math.sin(jm)end;local jN=utils.clamp(j5-jM,-PitchStallAngle*0.85,PitchStallAngle*0.85)if j()<0.01 and VectorToTarget then jN=utils.clamp(j5-jM,-85,MaxPitch)elseif j()<0.01 then jN=utils.clamp(j5-jM,-MaxPitch,MaxPitch)end;if math.abs(dM)<5 or VectorToTarget or BrakeLanding or jL or AltitudeHold then if pitchPID==nil then pitchPID=pid.new(5*0.01,0,5*0.1)end;pitchPID:inject(jN)local j6=pitchPID:get()O=O+j6 end end;if antigrav~=nil and(antigrav and not ExternalAGG and an<200000)then if AntigravTargetAltitude==nil or AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;if desiredBaseAltitude~=AntigravTargetAltitude then desiredBaseAltitude=AntigravTargetAltitude;antigrav.setBaseAltitude(desiredBaseAltitude)end end end end;function script.onFlush()if antigrav~=nil and(antigrav and not ExternalAGG)then if antigrav.getState()==0 and antigrav.getBaseAltitude()~=AntigravTargetAltitude then antigrav.setBaseAltitude(AntigravTargetAltitude)end end;if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byThrottle and D then z=0;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,z)D=false elseif Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and not D then z=0;D=true end;pitchSpeedFactor=math.max(pitchSpeedFactor,0.01)yawSpeedFactor=math.max(yawSpeedFactor,0.01)rollSpeedFactor=math.max(rollSpeedFactor,0.01)torqueFactor=math.max(torqueFactor,0.01)brakeSpeedFactor=math.max(brakeSpeedFactor,0.01)brakeFlatFactor=math.max(brakeFlatFactor,0.01)autoRollFactor=math.max(autoRollFactor,0.01)turnAssistFactor=math.max(turnAssistFactor,0.01)local jO=utils.clamp(N+O+system.getControlDeviceForwardInput(),-1,1)local jP=utils.clamp(Q+T+system.getControlDeviceYawInput(),-1,1)local jQ=utils.clamp(R+P-system.getControlDeviceLeftRightInput(),-1,1)local jR=S;local jS=vec3(core.getWorldVertical())if jS==nil or jS:len()==0 then jS=(planet.center-vec3(core.getConstructWorldPos())):normalize()end;local jT=vec3(core.getConstructWorldOrientationUp())local jU=vec3(core.getConstructWorldOrientationForward())local jV=vec3(core.getConstructWorldOrientationRight())local jW=vec3(core.getWorldVelocity())local jX=vec3(core.getWorldVelocity()):normalize()local jY=getRoll(jS,jU,jV)local jZ=math.abs(jY)local j_=utils.sign(jY)local j=j()local k0=vec3(core.getWorldAngularVelocity())local k1=jO*pitchSpeedFactor*jV+jP*rollSpeedFactor*jU+jQ*yawSpeedFactor*jT;if jS:len()>0.01 and(j>0.0 or ProgradeIsOn or Reentry or ag or AltitudeHold)then local dM=getRoll(jS,jU,jV)local dN=dM/180*math.pi;local dO=math.cos(dN)local dP=math.sin(dN)local iC=getPitch(jS,jU,jV*dO+jT*dP)if bc==true and math.abs(bk-jY)>autoRollRollThreshold and jP==0 and math.abs(iC)<85 then local k2=bk;local iV=autoRollFactor;if j==0 then iV=iV/4;bk=0;k2=0 end;if rollPID==nil then rollPID=pid.new(iV*0.01,0,iV*0.1)end;rollPID:inject(k2-jY)local k3=rollPID:get()k1=k1+k3*jU end end;if jS:len()>0.01 and j>0.0 then local k4=20.0;if turnAssist==true and jZ>k4 and jO==0 and jQ==0 then local k5=turnAssistFactor*0.1;local k6=turnAssistFactor*0.025;local k7=(jZ-k4)/(180-k4)*180;local k8=0;if k7<90 then k8=k7/90 elseif k7<180 then k8=(180-k7)/90 end;k8=k8*k8;local k9=-j_*k6*(1.0-k8)local ka=k5*k8;k1=k1+ka*jV+k9*jT end end;local kb=1;local kc=0;local kd=1;if system.getMouseWheel()>0 then if AltIsOn then if j>0 or Reentry then bm=utils.clamp(bm+speedChangeLarge,0,AtmoSpeedLimit)elseif Autopilot then MaxGameVelocity=utils.clamp(MaxGameVelocity+speedChangeLarge/3.6*100,0,8333.00)end;H=false else z=round(utils.clamp(z+speedChangeLarge/100,-1,1),2)end elseif system.getMouseWheel()<0 then if AltIsOn then if j>0 or Reentry then bm=utils.clamp(bm-speedChangeLarge,0,AtmoSpeedLimit)elseif Autopilot then MaxGameVelocity=utils.clamp(MaxGameVelocity-speedChangeLarge/3.6*100,0,8333.00)end;H=false else z=round(utils.clamp(z-speedChangeLarge/100,-1,1),2)end end;A=0;local eg=-jS:dot(jW)if am and AtmoSpeedAssist and Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byThrottle then if throttlePID==nil then throttlePID=pid.new(0.5,0,1)end;throttlePID:inject(bm/3.6-jW:dot(jU))local ke=throttlePID:get()C=utils.clamp(ke,-1,1)if C0.005 then B=true;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,utils.clamp(C,0.01,1))else B=false;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,z)end;if brakePID==nil then brakePID=pid.new(1*0.01,0,1*0.1)end;brakePID:inject(jW:len()-bm/3.6)local kf=utils.clamp(brakePID:get(),0,1)if j>0 and eg<-80 or j>0.005 then A=kf end;if A>0 then if B and C==0.01 then Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)end else C=utils.clamp(C,0.01,1)end;local kg=''local kh=vec3()local ki=composeAxisAccelerationFromTargetSpeedV(axisCommandId.vertical,a8*1000)Nav:setEngineForceCommand("vertical airfoil , vertical ground ",ki,kc)local kj='thrust analog longitudinal 'if ExtraLongitudeTags~="none"then kj=kj..ExtraLongitudeTags end;local kk=Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)local kl=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(kj,axisCommandId.longitudinal)local km=composeAxisAccelerationFromTargetSpeed(axisCommandId.lateral,LeftAmount*1000)kg=kg..' , '.."lateral airfoil , lateral ground "kh=kh+km;if kh:len()>constants.epsilon then Nav:setEngineForceCommand(kg,kh,kc,'','','',kd)end;Nav:setEngineForceCommand(kj,kl,kb)local kn='thrust analog vertical fueled 'local ko='thrust analog lateral fueled 'if ExtraLateralTags~="none"then ko=ko..ExtraLateralTags end;if ExtraVerticalTags~="none"then kn=kn..ExtraVerticalTags end;if a8~=0 or BrakeLanding and BrakeIsOn then Nav:setEngineForceCommand(kn,ki,kb)else Nav:setEngineForceCommand(kn,vec3(),kb)end;if LeftAmount~=0 then Nav:setEngineForceCommand(ko,km,kb)else Nav:setEngineForceCommand(ko,vec3(),kb)end;if jR==0 then jR=A end;local kp=-jR*(brakeSpeedFactor*jW+brakeFlatFactor*jX)Nav:setEngineForceCommand('brake',kp)else if AtmoSpeedAssist then Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,z)end;local kp=-jR*(brakeSpeedFactor*jW+brakeFlatFactor*jX)Nav:setEngineForceCommand('brake',kp)local kg=''local kh=vec3()local kq=false;local kj='thrust analog longitudinal 'if ExtraLongitudeTags~="none"then kj=kj..ExtraLongitudeTags end;local kk=Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)if kk==axisCommandType.byThrottle then local kl=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(kj,axisCommandId.longitudinal)Nav:setEngineForceCommand(kj,kl,kb)elseif kk==axisCommandType.byTargetSpeed then local kl=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.longitudinal)kg=kg..' , '..kj;kh=kh+kl;if Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)==0 or Nav.axisCommandManager:getCurrentToTargetDeltaSpeed(axisCommandId.longitudinal)<-Nav.axisCommandManager:getTargetSpeedCurrentStep(axisCommandId.longitudinal)*0.5 then kq=true end end;local ko='thrust analog lateral 'if ExtraLateralTags~="none"then ko=ko..ExtraLateralTags end;local kr=Nav.axisCommandManager:getAxisCommandType(axisCommandId.lateral)if kr==axisCommandType.byThrottle then local ks=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(ko,axisCommandId.lateral)Nav:setEngineForceCommand(ko,ks,kb)elseif kr==axisCommandType.byTargetSpeed then local km=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.lateral)kg=kg..' , '..ko;kh=kh+km end;local kn='thrust analog vertical 'if ExtraVerticalTags~="none"then kn=kn..ExtraVerticalTags end;local kt=Nav.axisCommandManager:getAxisCommandType(axisCommandId.vertical)if kt==axisCommandType.byThrottle then local ki=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(kn,axisCommandId.vertical)if a8~=0 or BrakeLanding and BrakeIsOn then Nav:setEngineForceCommand(kn,ki,kb,'airfoil','ground','',kd)else Nav:setEngineForceCommand(kn,vec3(),kb)Nav:setEngineForceCommand('airfoil vertical',ki,kb,'airfoil','','',kd)Nav:setEngineForceCommand('ground vertical',ki,kb,'ground','','',kd)end elseif kt==axisCommandType.byTargetSpeed then if a8<0 then Nav:setEngineForceCommand('hover',vec3(),kb)end;local ku=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.vertical)kg=kg..' , '..kn;kh=kh+ku end;local gb=unit.getAxisCommandValue(0)if kh:len()>constants.epsilon then if S~=0 or kq or math.abs(jX:dot(jU))<0.8 or bd:len()>gb/3.6 then kg=kg..', brake'end;Nav:setEngineForceCommand(kg,kh,kc,'','','',kd)end end;local kv=torqueFactor*(k1-k0)local kw=vec3(core.getWorldAirFrictionAngularAcceleration())kv=kv-kw;Nav:setEngineTorqueCommand('torque',kv,kb,'airfoil','','',kd)Nav:setBoosterCommand('rocket_engine')if Z and not VanillaRockets then local bS=vec3(core.getVelocity()):len()local kx=0.15;if Nav.axisCommandManager:getAxisCommandType(0)==1 then local ky=Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)if bS*3.6>ky*(1-kx)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bS*3.6=gb*(1-kx)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bS=gb*(1-kx)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bS0 or anHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude+Y;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude+Y end else AntigravTargetAltitude=desiredBaseAltitude+100 end elseif AltitudeHold then HoldAltitude=HoldAltitude+X else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(1.0)end elseif kz=="groundaltitudedown"then OldButtonMod=X;OldAntiMod=Y;if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitudeHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end end else AntigravTargetAltitude=desiredBaseAltitude end elseif AltitudeHold then HoldAltitude=HoldAltitude-X else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(-1.0)end elseif kz=="option1"then if not Autopilot then IncrementAutopilotTargetIndex()H=false end elseif kz=="option2"then if not Autopilot then DecrementAutopilotTargetIndex()H=false end elseif kz=="option3"then if hideHudOnToggleWidgets then if showHud then showHud=false else showHud=true end end;H=false;ToggleWidgets()elseif kz=="option4"then ToggleAutopilot()H=false elseif kz=="option5"then ToggleLockPitch()H=false elseif kz=="option6"then ToggleAltitudeHold()H=false elseif kz=="option7"then wipeSaveVariables()H=false elseif kz=="option8"then ToggleFollowMode()H=false elseif kz=="option9"then if gyro~=nil then gyro.toggle()aq=gyro.getState()==1 end;H=false elseif kz=="lshift"then if system.isViewLocked()==1 then V=true;PrevViewLock=system.isViewLocked()system.lockView(1)elseif o()==1 and ShiftShowsRemoteButtons then V=true;bb=false;ba=false end elseif kz=="brake"then if BrakeToggleStatus then BrakeToggle()elseif not BrakeIsOn then BrakeToggle()else BrakeIsOn=true end elseif kz=="lalt"then AltIsOn=true;if o()==0 and not freeLookToggle and userControlScheme=="keyboard"then system.lockView(1)end elseif kz=="booster"then if VanillaRockets then Nav:toggleBoosters()elseif not Z then if not IsRocketOn then Nav:toggleBoosters()IsRocketOn=true end;Z=true else if IsRocketOn then Nav:toggleBoosters()IsRocketOn=false end;Z=false end elseif kz=="stopengines"then Nav.axisCommandManager:resetCommand(axisCommandId.longitudinal)clearAll()z=0 elseif kz=="speedup"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z+speedChangeLarge/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal,speedChangeLarge)end else IncrementAutopilotTargetIndex()end elseif kz=="speeddown"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z-speedChangeLarge/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal,-speedChangeLarge)end else DecrementAutopilotTargetIndex()end elseif kz=="antigravity"and not ExternalAGG then if antigrav~=nil then ToggleAntigrav()end end end;function script.onActionStop(kz)if kz=="forward"then N=0 elseif kz=="backward"then N=0 elseif kz=="left"then Q=0 elseif kz=="right"then Q=0 elseif kz=="yawright"then R=0 elseif kz=="yawleft"then R=0 elseif kz=="straferight"then Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral,-1.0)LeftAmount=0 elseif kz=="strafeleft"then Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral,1.0)LeftAmount=0 elseif kz=="up"then a8=0;Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical,-1.0)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(currentGroundAltitudeStabilization)Nav:setEngineForceCommand('hover',vec3(),1)elseif kz=="down"then a8=0;Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical,1.0)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(currentGroundAltitudeStabilization)Nav:setEngineForceCommand('hover',vec3(),1)elseif kz=="groundaltitudeup"then if antigrav and not ExternalAGG and antigrav.getState()==1 then Y=OldAntiMod end;if AltitudeHold then X=OldButtonMod end;H=false elseif kz=="groundaltitudedown"then if antigrav and not ExternalAGG and antigrav.getState()==1 then Y=OldAntiMod end;if AltitudeHold then X=OldButtonMod end;H=false elseif kz=="lshift"then if system.isViewLocked()==1 then V=false;a9=0;aa=0;system.lockView(PrevViewLock)elseif o()==1 and ShiftShowsRemoteButtons then V=false;bb=false;ba=false end elseif kz=="brake"then if not BrakeToggleStatus then if BrakeIsOn then BrakeToggle()else BrakeIsOn=false end end elseif kz=="lalt"then if o()==0 and freeLookToggle then if H then if system.isViewLocked()==1 then system.lockView(0)else system.lockView(1)end else H=true end elseif o()==0 and not freeLookToggle and userControlScheme=="keyboard"then system.lockView(0)end;AltIsOn=false end end;function script.onActionLoop(kz)if kz=="groundaltitudeup"then if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitudeHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude+Y;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude+Y end;Y=Y*1.05;BrakeIsOn=false else AntigravTargetAltitude=desiredBaseAltitude+100;BrakeIsOn=false end elseif AltitudeHold then HoldAltitude=HoldAltitude+X;X=X*1.05 else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(1.0)end elseif kz=="groundaltitudedown"then if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitudeHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end end;Y=Y*1.05;BrakeIsOn=false else AntigravTargetAltitude=desiredBaseAltitude-100;BrakeIsOn=false end elseif AltitudeHold then HoldAltitude=HoldAltitude-X;X=X*1.05 else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(-1.0)end elseif kz=="speedup"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z+speedChangeSmall/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal,speedChangeSmall)end end elseif kz=="speeddown"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z-speedChangeSmall/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal,-speedChangeSmall)end end end end;function script.onInputText(dA)local i;local kA="/commands /setname /G /agg /addlocation /copydatabank"local kB,kC=nil,nil;local kD="Command List:\n/commands \n/setname - Updates current selected saved position name\n/G VariableName newValue - Updates global variable to new value\n".."/G dump - shows all updatable variables with /G\n/agg - Manually set agg target height\n".."/addlocation savename ::pos{0,2,46.4596,-155.1799,22.6572} - adds a saved location by waypoint, not as accurate as making one at location\n".."/copydatabank - copies dbHud databank to a blank databank"i=string.find(dA," ")kB=dA;if i~=nil then kB=string.sub(dA,0,i-1)kC=string.sub(dA,i+1)elseif not string.find(kA,kB)then for g7 in string.gmatch(kD,"([^\n]+)")do c(g7)end;return end;if kB=="/setname"then if kC==nil or kC==""then W="Usage: /setname Newname"return end;if AutopilotTargetIndex>0 and CustomTarget~=nil then UpdatePosition(kC)else W="Select a saved target to rename first"end elseif kB=="/addlocation"then if kC==nil or kC==""or string.find(kC,"::")==nil then W="Usage: /addlocation savename ::pos{0,2,46.4596,-155.1799,22.6572}"return end;i=string.find(kC,"::")local cm=string.sub(kC,1,i-2)local cg=string.sub(kC,i)local q=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local ch='::pos{'..q..','..q..','..q..','..q..','..q..'}'local ci,cj,cd,ce,cc=string.match(cg,ch)local planet=b0[tonumber(ci)][tonumber(cj)]AddNewLocationByWaypoint(cm,planet,cg)W="Added "..cm.." to saved locations,\nplanet "..planet.name.." at "..cg;ab=5 elseif kB=="/agg"then if kC==nil or kC==""then W="Usage: /agg targetheight"return end;kC=tonumber(kC)if kC<1000 then kC=1000 end;AntigravTargetAltitude=kC;W="AGG Target Height set to "..kC elseif kB=="/G"then if kC==nil or kC==""then W="Usage: /G VariableName variablevalue\n/G dump - shows all variables"return end;if kC=="dump"then for bB,bC in pairs(a)do if type(_G[bC])=="boolean"then if _G[bC]==true then c(bC.." true")else c(bC.." false")end elseif _G[bC]==nil then c(bC.." nil")else c(bC.." ".._G[bC])end end;return end;i=string.find(kC," ")local kE=string.sub(kC,0,i-1)local kF=string.sub(kC,i+1)for bB,bC in pairs(a)do if bC==kE then W="Variable "..kE.." changed to "..kF;local kG=type(_G[bC])if kG=="number"then kF=tonumber(kF)elseif kG=="boolean"then if string.lower(kF)=="true"then kF=true else kF=false end end;_G[bC]=kF;return end end;W="No such global variable: "..kE elseif kB=="/copydatabank"then if dbHud_2 then SaveDataBank(true)else W="Databank required to copy databank"end end end;script.onStart() + Radar: No Contacts]],g2,g3)end;if radarPanelID~=nil then af=0;ToggleRadarPanel()end end end end;function DisplayMessage(ct,dy)if dy~="empty"then ct[#ct+1]=[[]]for g7 in string.gmatch(dy,"([^\n]+)")do ct[#ct+1]=e([[%s]],g7)end;ct[#ct+1]=[[]]end;if ab~=0 then unit.setTimer("msgTick",ab)ab=0 end end;function updateDistance()local bL=system.getTime()local bd=vec3(core.getWorldVelocity())local dU=vec3(bd):len()local g8=bL-ap;if dU>1.38889 then dU=dU/1000;local g9=dU*(bL-ap)TotalDistanceTravelled=TotalDistanceTravelled+g9;a5=a5+g9 end;a6=a6+g8;TotalFlightTime=TotalFlightTime+g8;ap=bL end;function composeAxisAccelerationFromTargetSpeedV(ga,gb)local gc=vec3()local gd=vec3()if ga==axisCommandId.longitudinal then gc=vec3(core.getConstructOrientationForward())gd=vec3(core.getConstructWorldOrientationForward())elseif ga==axisCommandId.vertical then gc=vec3(core.getConstructOrientationUp())gd=vec3(core.getConstructWorldOrientationUp())elseif ga==axisCommandId.lateral then gc=vec3(core.getConstructOrientationRight())gd=vec3(core.getConstructWorldOrientationRight())else return vec3()end;local ge=vec3(core.getWorldGravity())local gf=ge:dot(gd)local gg=vec3(core.getWorldAirFrictionAcceleration())local gh=gg:dot(gd)local gi=vec3(core.getVelocity())local gj=gi:dot(gc)local gk=gb*constants.kph2m;if targetSpeedPID2==nil then targetSpeedPID2=pid.new(10,0,10.0)end;targetSpeedPID2:inject(gk-gj)local gl=targetSpeedPID2:get()local gm=(gl-gh-gf)*gd;return gm end;function composeAxisAccelerationFromTargetSpeed(ga,gb)local gc=vec3()local gd=vec3()if ga==axisCommandId.longitudinal then gc=vec3(core.getConstructOrientationForward())gd=vec3(core.getConstructWorldOrientationForward())elseif ga==axisCommandId.vertical then gc=vec3(core.getConstructOrientationUp())gd=vec3(core.getConstructWorldOrientationUp())elseif ga==axisCommandId.lateral then gc=vec3(core.getConstructOrientationRight())gd=vec3(core.getConstructWorldOrientationRight())else return vec3()end;local ge=vec3(core.getWorldGravity())local gf=ge:dot(gd)local gg=vec3(core.getWorldAirFrictionAcceleration())local gh=gg:dot(gd)local gi=vec3(core.getVelocity())local gj=gi:dot(gc)local gk=gb*constants.kph2m;if targetSpeedPID==nil then targetSpeedPID=pid.new(10,0,10.0)end;targetSpeedPID:inject(gk-gj)local gl=targetSpeedPID:get()local gm=(gl-gh-gf)*gd;return gm end;function Atlas()return{[0]={[0]={GM=0,bodyId=0,center={x=0,y=0,z=0},name='Space',planetarySystemId=0,radius=0,hasAtmosphere=false,gravity=0,noAtmosphericDensityAltitude=0,surfaceMaxAltitude=0},[2]={name="Alioth",description="Alioth is the planet selected by the arkship for landfall; it is a typical goldilocks planet where humanity may rebuild in the coming decades. The arkship geological survey reports mountainous regions alongside deep seas and lush forests. This is where it all starts.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9401,atmosphericEngineMaxAltitude=5580,biosphere="Forest",classification="Mesoplanet",bodyId=2,GM=157470826617,gravity=1.0082568597356114,fullAtmosphericDensityMaxAltitude=-10,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=6272,numSatellites=2,positionFromSun=2,center={x=-8,y=-8,z=-126303},radius=126067.8984375,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=3410,surfaceArea=199718780928,surfaceAverageAltitude=200,surfaceMaxAltitude=1100,surfaceMinAltitude=-330,systemZone="High",territories=259472,type="Planet",waterLevel=0,planetarySystemId=0},[21]={name="Alioth Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=21,GM=2118960000,gravity=0.24006116402380084,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=457933,y=-1509011,z=115524},radius=30000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=11309733888,surfaceAverageAltitude=140,surfaceMaxAltitude=200,surfaceMinAltitude=10,systemZone=nil,territories=14522,type="",waterLevel=nil,planetarySystemId=0},[22]={name="Alioth Moon 4",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=22,GM=2165833514,gravity=0.2427018259886451,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-1692694,y=729681,z=-411464},radius=30330,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=0,surfaceArea=11559916544,surfaceAverageAltitude=-15,surfaceMaxAltitude=-5,surfaceMinAltitude=-50,systemZone=nil,territories=14522,type="",waterLevel=nil,planetarySystemId=0},[5]={name="Feli",description="Feli is easily identified by its massive and deep crater. Outside of the crater, the arkship geological survey reports a fairly bland and uniform planet, it also cannot explain the existence of the crater. Feli is particular for having an extremely small atmosphere, allowing life to develop in the deeper areas of its crater but limiting it drastically on the actual surface.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.5488,atmosphericEngineMaxAltitude=66725,biosphere="Barren",classification="Mesoplanet",bodyId=5,GM=16951680000,gravity=0.4801223280476017,fullAtmosphericDensityMaxAltitude=30,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=78500,numSatellites=1,positionFromSun=5,center={x=-43534464,y=22565536,z=-48934464},radius=41800,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=42800,surfaceArea=21956466688,surfaceAverageAltitude=18300,surfaceMaxAltitude=18500,surfaceMinAltitude=46,systemZone="Low",territories=27002,type="Planet",waterLevel=nil,planetarySystemId=0},[50]={name="Feli Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=50,GM=499917600,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-43902841.78,y=22261034.7,z=-48862386},radius=14000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=800,surfaceMaxAltitude=900,surfaceMinAltitude=0,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[120]={name="Ion",description="Ion is nothing more than an oversized ice cube frozen through and through. It is a largely inhospitable planet due to its extremely low temperatures. The arkship geological survey reports extremely rough mountainous terrain with little habitable land.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9522,atmosphericEngineMaxAltitude=10480,biosphere="Ice",classification="Hypopsychroplanet",bodyId=120,GM=7135606629,gravity=0.36009174603570127,fullAtmosphericDensityMaxAltitude=-30,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=17700,numSatellites=2,positionFromSun=12,center={x=2865536.7,y=-99034464,z=-934462.02},radius=44950,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=6410,surfaceArea=25390383104,surfaceAverageAltitude=500,surfaceMaxAltitude=1300,surfaceMinAltitude=250,systemZone="Average",territories=32672,type="Planet",waterLevel=nil,planetarySystemId=0},[121]={name="Ion Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=121,GM=106830900,gravity=0.08802242599860607,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=2472916.8,y=-99133747,z=-1133582.8},radius=11000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=1520530944,surfaceAverageAltitude=100,surfaceMaxAltitude=200,surfaceMinAltitude=3,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[122]={name="Ion Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=122,GM=176580000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=2995424.5,y=-99275010,z=-1378480.7},radius=15000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=-1900,surfaceMaxAltitude=-1400,surfaceMinAltitude=-2100,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[9]={name="Jago",description="Jago is a water planet. The large majority of the planet's surface is covered by large oceans dotted by small areas of landmass across the planet. The arkship geological survey reports deep seas across the majority of the planet with sub 15 percent coverage of solid ground.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9835,atmosphericEngineMaxAltitude=9695,biosphere="Water",classification="Mesoplanet",bodyId=9,GM=18606274330,gravity=0.5041284298678057,fullAtmosphericDensityMaxAltitude=-90,habitability="Very High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=10900,numSatellites=0,positionFromSun=9,center={x=-94134462,y=12765534,z=-3634464},radius=61590,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=5900,surfaceArea=47668367360,surfaceAverageAltitude=0,surfaceMaxAltitude=1200,surfaceMinAltitude=-500,systemZone="Very High",territories=60752,type="Planet",waterLevel=0,planetarySystemId=0},[100]={name="Lacobus",description="Lacobus is an ice planet that also features large bodies of water. The arkship geological survey reports deep oceans alongside a frozen and rough mountainous environment. Lacobus seems to feature regional geothermal activity allowing for the presence of water on the surface.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.7571,atmosphericEngineMaxAltitude=11120,biosphere="Ice",classification="Psychroplanet",bodyId=100,GM=13975172474,gravity=0.45611622622739767,fullAtmosphericDensityMaxAltitude=-20,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=12510,numSatellites=3,positionFromSun=10,center={x=98865536,y=-13534464,z=-934461.99},radius=55650,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=6790,surfaceArea=38917074944,surfaceAverageAltitude=800,surfaceMaxAltitude=1660,surfaceMinAltitude=250,systemZone="Average",territories=50432,type="Planet",waterLevel=0,planetarySystemId=0},[102]={name="Lacobus Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=102,GM=444981600,gravity=0.14403669598391783,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=99180968,y=-13783862,z=-926156.4},radius=18000,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=0,surfaceArea=4071504128,surfaceAverageAltitude=150,surfaceMaxAltitude=300,surfaceMinAltitude=10,systemZone=nil,territories=5072,type="",waterLevel=nil,planetarySystemId=0},[103]={name="Lacobus Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=103,GM=211503600,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=99250052,y=-13629215,z=-1059341.4},radius=14000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=-1380,surfaceMaxAltitude=-1280,surfaceMinAltitude=-1880,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[101]={name="Lacobus Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=101,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=98905288.17,y=-13950921.1,z=-647589.53},radius=15000,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=500,surfaceMaxAltitude=820,surfaceMinAltitude=3,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[1]={name="Madis",description="Madis is a barren wasteland of a rock; it sits closest to the sun and temperatures reach extreme highs during the day. The arkship geological survey reports long rocky valleys intermittently separated by small ravines.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.8629,atmosphericEngineMaxAltitude=7165,biosphere="Barren",classification="hyperthermoplanet",bodyId=1,GM=6930729684,gravity=0.36009174603570127,fullAtmosphericDensityMaxAltitude=220,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=8050,numSatellites=3,positionFromSun=1,center={x=17465536,y=22665536,z=-34464},radius=44300,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=4480,surfaceArea=24661377024,surfaceAverageAltitude=750,surfaceMaxAltitude=850,surfaceMinAltitude=670,systemZone="Low",territories=30722,type="Planet",waterLevel=nil,planetarySystemId=0},[10]={name="Madis Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=10,GM=78480000,gravity=0.08002039003323584,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17448118.224,y=22966846.286,z=143078.82},radius=10000,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=0,surfaceArea=1256637056,surfaceAverageAltitude=210,surfaceMaxAltitude=420,surfaceMinAltitude=0,systemZone=nil,territories=1472,type="",waterLevel=nil,planetarySystemId=0},[11]={name="Madis Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=11,GM=237402000,gravity=0.09602446196397631,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17194626,y=22243633.88,z=-214962.81},radius=12000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=1809557376,surfaceAverageAltitude=-700,surfaceMaxAltitude=300,surfaceMinAltitude=-2900,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[12]={name="Madis Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=12,GM=265046609,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17520614,y=22184730,z=-309989.99},radius=15000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=700,surfaceMaxAltitude=1100,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[26]={name="Sanctuary",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9666,atmosphericEngineMaxAltitude=6935,biosphere="",classification="",bodyId=26,GM=68234043600,gravity=1.0000000427743831,fullAtmosphericDensityMaxAltitude=-30,habitability="",hasAtmosphere=true,isSanctuary=true,noAtmosphericDensityAltitude=7800,numSatellites=0,positionFromSun=0,center={x=-1404835,y=562655,z=-285074},radius=83400,safeAreaEdgeAltitude=0,size="L",spaceEngineMinAltitude=4230,surfaceArea=87406149632,surfaceAverageAltitude=80,surfaceMaxAltitude=500,surfaceMinAltitude=-60,systemZone=nil,territories=111632,type="",waterLevel=0,planetarySystemId=0},[6]={name="Sicari",description="Sicari is a typical desert planet; it has survived for millenniums and will continue to endure. While not the most habitable of environments it remains a relatively untouched and livable planet of the Alioth sector. The arkship geological survey reports large flatlands alongside steep plateaus.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.897,atmosphericEngineMaxAltitude=7725,biosphere="Desert",classification="Mesoplanet",bodyId=6,GM=10502547741,gravity=0.4081039739797361,fullAtmosphericDensityMaxAltitude=-625,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=8770,numSatellites=0,positionFromSun=6,center={x=52765536,y=27165538,z=52065535},radius=51100,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=4480,surfaceArea=32813432832,surfaceAverageAltitude=130,surfaceMaxAltitude=220,surfaceMinAltitude=50,systemZone="Average",territories=41072,type="Planet",waterLevel=nil,planetarySystemId=0},[7]={name="Sinnen",description="Sinnen is a an empty and rocky hell. With no atmosphere to speak of it is one of the least hospitable planets in the sector. The arkship geological survey reports mostly flatlands alongside deep ravines which look to have once been riverbeds. This planet simply looks to have dried up and died, likely from solar winds.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9226,atmosphericEngineMaxAltitude=10335,biosphere="Desert",classification="Mesoplanet",bodyId=7,GM=13033380591,gravity=0.4401121421448438,fullAtmosphericDensityMaxAltitude=-120,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=11620,numSatellites=1,positionFromSun=7,center={x=58665538,y=29665535,z=58165535},radius=54950,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=6270,surfaceArea=37944188928,surfaceAverageAltitude=317,surfaceMaxAltitude=360,surfaceMinAltitude=23,systemZone="Average",territories=48002,type="Planet",waterLevel=nil,planetarySystemId=0},[70]={name="Sinnen Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=70,GM=396912600,gravity=0.1360346539426409,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=58969616,y=29797945,z=57969449},radius=17000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=3631681280,surfaceAverageAltitude=-2050,surfaceMaxAltitude=-1950,surfaceMinAltitude=-2150,systemZone=nil,territories=4322,type="",waterLevel=nil,planetarySystemId=0},[110]={name="Symeon",description="Symeon is an ice planet mysteriously split at the equator by a band of solid desert. Exactly how this phenomenon is possible is unclear but some sort of weather anomaly may be responsible. The arkship geological survey reports a fairly diverse mix of flat-lands alongside mountainous formations.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9559,atmosphericEngineMaxAltitude=6920,biosphere="Ice, Desert",classification="Hybrid",bodyId=110,GM=9204742375,gravity=0.3920998898971822,fullAtmosphericDensityMaxAltitude=-30,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=7800,numSatellites=0,positionFromSun=11,center={x=14165536,y=-85634465,z=-934464.3},radius=49050,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=4230,surfaceArea=30233462784,surfaceAverageAltitude=39,surfaceMaxAltitude=450,surfaceMinAltitude=126,systemZone="High",territories=38882,type="Planet",waterLevel=nil,planetarySystemId=0},[4]={name="Talemai",description="Talemai is a planet in the final stages of an Ice Age. It seems likely that the planet was thrown into tumult by a cataclysmic volcanic event which resulted in its current state. The arkship geological survey reports large mountainous regions across the entire planet.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.8776,atmosphericEngineMaxAltitude=9685,biosphere="Barren",classification="Psychroplanet",bodyId=4,GM=14893847582,gravity=0.4641182439650478,fullAtmosphericDensityMaxAltitude=-78,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=10890,numSatellites=3,positionFromSun=4,center={x=-13234464,y=55765536,z=465536},radius=57500,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=5890,surfaceArea=41547563008,surfaceAverageAltitude=580,surfaceMaxAltitude=610,surfaceMinAltitude=520,systemZone="Average",territories=52922,type="Planet",waterLevel=nil,planetarySystemId=0},[42]={name="Talemai Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=42,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-13058408,y=55781856,z=740177.76},radius=15000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=720,surfaceMaxAltitude=850,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[40]={name="Talemai Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=40,GM=141264000,gravity=0.09602446196397631,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-13503090,y=55594325,z=769838.64},radius=12000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=1809557376,surfaceAverageAltitude=250,surfaceMaxAltitude=450,surfaceMinAltitude=0,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[41]={name="Talemai Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=41,GM=106830900,gravity=0.08802242599860607,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-12800515,y=55700259,z=325207.84},radius=11000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=1520530944,surfaceAverageAltitude=190,surfaceMaxAltitude=400,surfaceMinAltitude=0,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[8]={name="Teoma",description="[REDACTED] The arkship geological survey [REDACTED]. This planet should not be here.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.7834,atmosphericEngineMaxAltitude=5580,biosphere="Forest",classification="Mesoplanet",bodyId=8,GM=18477723600,gravity=0.48812434578525177,fullAtmosphericDensityMaxAltitude=15,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=6280,numSatellites=0,positionFromSun=8,center={x=80865538,y=54665536,z=-934463.94},radius=62000,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=3420,surfaceArea=48305131520,surfaceAverageAltitude=700,surfaceMaxAltitude=1100,surfaceMinAltitude=-200,systemZone="High",territories=60752,type="Planet",waterLevel=0,planetarySystemId=0},[3]={name="Thades",description="Thades is a scorched desert planet. Perhaps it was once teaming with life but now all that remains is ash and dust. The arkship geological survey reports a rocky mountainous planet bisected by a massive unnatural ravine; something happened to this planet.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.03552,atmosphericEngineMaxAltitude=32180,biosphere="Desert",classification="Thermoplanet",bodyId=3,GM=11776905000,gravity=0.49612641213015557,fullAtmosphericDensityMaxAltitude=150,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=32800,numSatellites=2,positionFromSun=3,center={x=29165536,y=10865536,z=65536},radius=49000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=21400,surfaceArea=30171856896,surfaceAverageAltitude=13640,surfaceMaxAltitude=13690,surfaceMinAltitude=370,systemZone="Low",territories=38882,type="Planet",waterLevel=nil,planetarySystemId=0},[30]={name="Thades Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=30,GM=211564034,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=29214402,y=10907080.695,z=433858.2},radius=14000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=60,surfaceMaxAltitude=300,surfaceMinAltitude=0,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[31]={name="Thades Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=31,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=29404193,y=10432768,z=19554.131},radius=15000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=70,surfaceMaxAltitude=350,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0}}}end;function SetupAtlas()b0=Atlas()for bB,bC in pairs(b0[0])do if aE==nil or bC.center.xaF then aF=bC.center.x end;if aG==nil or bC.center.yaH then aH=bC.center.y end end;b1=""local gn=1.1*(aF-aE)/1920;local go=1.4*(aH-aG)/1080;for bB,bC in pairs(b0[0])do local bY=960+bC.center.x/gn;local bZ=540+bC.center.y/go;b1=b1 ..''if not string.match(bC.name,"Moon")and not string.match(bC.name,"Sanctuary")and not string.match(bC.name,"Space")then b1=b1 ..""..bC.name..""end end;local cg=vec3(core.getConstructWorldPos())local bY=960+cg.x/gn;local bZ=540+cg.y/go;b1=b1 ..''b1=b1 .."You Are Here"b1=b1 ..[[]]b2=gn;b3=go;if screen_2 then screen_2.setHTML(''..b1)local cg=vec3(core.getConstructWorldPos())local bY=960+cg.x/gn;local bZ=540+cg.y/go;b1=''b1=b1 .."You Are Here"b4=screen_2.addContent((bY-80)/19.20,(bZ-80)/10.80,b1)end end;function PlanetRef()local function gp(gq)return type(gq)=='number'end;local function gr(gq)return type(tonumber(gq))=='number'end;local function gs(gt)return type(gt)=='table'end;local function gu(gv)return type(gv)=='string'end;local function gw(bC)return gs(bC)and gp(bC.x and bC.y and bC.z)end;local function gx(gy)return gs(gy)and gp(gy.latitude and gy.longitude and gy.altitude and gy.bodyId and gy.systemId)end;local gz=math.pi/180;local gA=180/math.pi;local epsilon=1e-10;local q=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local ch='::pos{'..q..','..q..','..q..','..q..','..q..'}'local utils=require('cpml.utils')local vec3=require('cpml.vec3')local gB=utils.clamp;local function float_eq(c6,c7)if c6==0 then return math.abs(c7)<1e-09 end;if c7==0 then return math.abs(c6)<1e-09 end;return math.abs(c6-c7)=0 then local hp=math.sqrt(ho)local fg=hn+hp;local fh=hn-hp;if fh>0 then return fi,fg,fh elseif fg>0 then return fi,fg,nil end end end;return nil,nil,nil end;function gS:closestBody(hq)assert(type(hq)=='table','Invalid coordinates.')local hr,fi;local hs=vec3(hq)for _,ht in pairs(self)do local hu=(ht.center-hs):len2()if(not fi or hu=0 and cf or 2*math.pi+cf;cd=math.pi/2-math.acos(cb.z/ac)end;return setmetatable({latitude=cd,longitude=ce,altitude=cc,bodyId=self.bodyId,systemId=self.planetarySystemId},MapPosition)end;function gH:convertToWorldCoordinates(gR)local hv=gu(gR)and gQ(gR)or gR;if hv.bodyId==0 then return vec3(hv.latitude,hv.longitude,hv.altitude)end;assert(gx(hv),'Argument 1 (mapPosition) is not an instance of "MapPosition".')assert(hv.systemId==self.planetarySystemId,'Argument 1 (mapPosition) has a different planetary system ID.')assert(hv.bodyId==self.bodyId,'Argument 1 (mapPosition) has a different planetary body ID.')local ck=math.cos(hv.latitude)return self.center+(self.radius+hv.altitude)*vec3(ck*math.cos(hv.longitude),ck*math.sin(hv.longitude),math.sin(hv.latitude))end;function gH:getAltitude(c9)return(vec3(c9)-self.center):len()-self.radius end;function gH:getDistance(c9)return(vec3(c9)-self.center):len()end;function gH:getGravity(c9)local hw=self.center-vec3(c9)local hx=hw:len2()return self.GM/hx*hw/math.sqrt(hx)end;return setmetatable(b5,{__call=function(_,...)return g_(...)end})end;function Keplers()local vec3=require('cpml.vec3')local PlanetRef=PlanetRef()local function gu(gv)return type(gv)=='string'end;local function gs(gt)return type(gt)=='table'end;local function float_eq(c6,c7)if c6==0 then return math.abs(c7)<1e-09 end;if c7==0 then return math.abs(c6)<1e-09 end;return math.abs(c6-c7)0 then hO=hN;hP=hO+hI/2 end;if hP>hI then hP=hP-hI end end;return{periapsis={position=hF,speed=hH/hD,circularOrbitSpeed=math.sqrt(hA/hD),altitude=hD-self.body.radius},apoapsis=hG and{position=hG,speed=hH/hE,circularOrbitSpeed=math.sqrt(hA/hE),altitude=hE-self.body.radius},currentVelocity=bC,currentPosition=cg,eccentricity=hC,period=hI,eccentricAnomaly=hK,meanAnomaly=hM,timeToPeriapsis=hO,timeToApoapsis=hP}end;local function hQ(hR)local ht=PlanetRef.BodyParameters(hR.planetarySystemId,hR.bodyId,hR.radius,hR.center,hR.GM)return setmetatable({body=ht},Kepler)end;return setmetatable(Kepler,{__call=function(_,...)return hQ(...)end})end;function Kinematics()local b7={}local hS=30000000/3600;local hT=hS*hS;local hU=100;local function hV(bC)return 1/math.sqrt(1-bC*bC/hT)end;function b7.computeAccelerationTime(hW,hX,hY)local hZ=hS*math.asin(hW/hS)return(hS*math.asin(hY/hS)-hZ)/hX end;function b7.computeDistanceAndTime(hW,hY,h_,i0,i1,i2)i1=i1 or 0;i2=i2 or 0;local i3=hW<=hY;local i4=i0*(i3 and 1 or-1)/h_;local i5=-i2/h_;local i6=i4+i5;if i3 and i6<=0 or not i3 and i6>=0 then return-1,-1 end;local i7,i8=0,0;if i4~=0 and i1>0 then local hZ=math.asin(hW/hS)local i9=math.pi*(i4/2+i5)local ia=i4*i1;local ib=hS*math.pi;local bC=function(gt)local cV=(i9*gt-ia*math.sin(math.pi*gt/2/i1)+ib*hZ)/ib;local ic=math.tan(cV)return hS*ic/math.sqrt(ic*ic+1)end;local id=i3 and function(gv)return gv>=hY end or function(gv)return gv<=hY end;i8=2*i1;if id(bC(i8))then local ie=0;while math.abs(i8-ie)>0.5 do local gt=(i8+ie)/2;if id(bC(gt))then i8=gt else ie=gt end end end;local ig=hW;local ih=i8/hU;for ii=1,hU do local bS=bC(ii*ih)i7=i7+(bS+ig)*ih/2;ig=bS end;if i8<2*i1 then return i7,i8 end;hW=ig end;local hZ=hS*math.asin(hW/hS)local bE=(hS*math.asin(hY/hS)-hZ)/i6;local ij=hT*math.cos(hZ/hS)/i6;local ac=ij-hT*math.cos((i6*bE+hZ)/hS)/i6;return ac+i7,bE+i8 end;function b7.computeTravelTime(hW,hX,ac)if ac==0 then return 0 end;if hX>0 then local hZ=hS*math.asin(hW/hS)local ij=hT*math.cos(hZ/hS)/hX;return(hS*math.acos(hX*(ij-ac)/hT)-hZ)/hX end;if hW==0 then return-1 end;assert(hW>0,'Acceleration and initial speed are both zero.')return ac/hW end;function b7.lorentz(bC)return hV(bC)end;return b7 end;function safeZone(ik)local gN=500000;local il,im,io=math.huge;local ip=false;local iq=vec3({13771471,7435803,-128971})local ir=18000000;il=vec3(ik):dist(iq)if il0 or bN==0 and an<10000)then for _,bC in pairs(door)do bC.toggle()end end;if switch then for _,bC in pairs(switch)do bC.toggle()end end;if forcefield and(bN>0 or bN==0 and an<10000)then for _,bC in pairs(forcefield)do bC.toggle()end end;SaveDataBank()if button then button.activate()end end;local function it(ee,iu)if iu==nil then iu=false end;if Nav.axisCommandManager:getAxisCommandType(0)~=axisCommandType.byThrottle and not iu then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,ee)end;local function iv(ee,iu)if iu==nil then iu=false end;if Nav.axisCommandManager:getAxisCommandType(0)~=axisCommandType.byTargetSpeed and not iu then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setTargetSpeedCommand(axisCommandId.longitudinal,ee)end;function script.onTick(iw)if iw=="tenthSecond"then if j()>0 and not WasInAtmo then if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and AtmoSpeedAssist and(AltitudeHold or Reentry)then z=1;Nav.control.cancelCurrentControlMasterMode()D=false end end;if AutopilotTargetName~="None"then if panelInterplanetary==nil then SetupInterplanetaryPanel()end;if AutopilotTargetName~=nil then local ix=CustomTarget~=nil;planetMaxMass=GetAutopilotMaxMass()system.updateData(interplanetaryHeaderText,'{"label": "Target", "value": "'..AutopilotTargetName..'", "unit":""}')travelTime=GetAutopilotTravelTime()if ix and not Autopilot then ac=(vec3(core.getConstructWorldPos())-CustomTarget.position):len()else ac=(AutopilotTargetCoords-vec3(core.getConstructWorldPos())):len()end;if not TurnBurn then a0,a1=GetAutopilotBrakeDistanceAndTime(be)a2,a3=GetAutopilotBrakeDistanceAndTime(MaxGameVelocity)else a0,a1=GetAutopilotTBBrakeDistanceAndTime(be)a2,a3=GetAutopilotTBBrakeDistanceAndTime(MaxGameVelocity)end;local dy,dz=getDistanceDisplayString(ac)system.updateData(widgetDistanceText,'{"label": "distance", "value": "'..dy..'", "unit":"'..dz..'"}')system.updateData(widgetTravelTimeText,'{"label": "Travel Time", "value": "'..FormatTimeString(travelTime)..'", "unit":""}')dy,dz=getDistanceDisplayString(a0)system.updateData(widgetCurBrakeDistanceText,'{"label": "Cur Brake distance", "value": "'..dy..'", "unit":"'..dz..'"}')system.updateData(widgetCurBrakeTimeText,'{"label": "Cur Brake Time", "value": "'..FormatTimeString(a1)..'", "unit":""}')dy,dz=getDistanceDisplayString(a2)system.updateData(widgetMaxBrakeDistanceText,'{"label": "Max Brake distance", "value": "'..dy..'", "unit":"'..dz..'"}')system.updateData(widgetMaxBrakeTimeText,'{"label": "Max Brake Time", "value": "'..FormatTimeString(a3)..'", "unit":""}')system.updateData(widgetMaxMassText,'{"label": "Maximum Mass", "value": "'..e("%.2f",planetMaxMass/1000)..'", "unit":" Tons"}')dy,dz=getDistanceDisplayString(AutopilotTargetOrbit)system.updateData(widgetTargetOrbitText,'{"label": "Target Orbit", "value": "'..e("%.2f",dy)..'", "unit":"'..dz..'"}')if j()>0 and not WasInAtmo then system.removeDataFromWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)system.removeDataFromWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)system.removeDataFromWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)system.removeDataFromWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)system.removeDataFromWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)WasInAtmo=true end;if j()==0 and WasInAtmo then if system.updateData(widgetMaxBrakeTimeText,widgetMaxBrakeTime)==1 then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;if system.updateData(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)==1 then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;if system.updateData(widgetCurBrakeTimeText,widgetCurBrakeTime)==1 then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;if system.updateData(widgetCurBrakeDistanceText,widgetCurBrakeDistance)==1 then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;if system.updateData(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)==1 then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end;WasInAtmo=false end end else HideInterplanetaryPanel()end;if warpdrive~=nil then if f(warpdrive.getData()).destination~="Unknown"and f(warpdrive.getData()).distance>400000 then warpdrive.show()showWarpWidget=true else warpdrive.hide()showWarpWidget=false end end elseif iw=="oneSecond"then ak=false;RefreshLastMaxBrake(nil,true)updateDistance()updateRadar()updateWeapons()local ct={}local dK=GetFlightStyle()DrawOdometer(ct,a5,TotalDistanceTravelled,dK,a6)if ShouldCheckDamage then CheckDamage(ct)end;ae=table.concat(ct,"")collectgarbage("collect")elseif iw=="fiveSecond"then al=dbHud_1.getStringValue("SPBAutopilotTargetName")if al~=nil and al~=""and al~="SatNavNotChanged"then local bD=json.decode(dbHud_1.getStringValue("SavedLocations"))if bD~=nil then _G["SavedLocations"]=bD;local cr=-1;local cn;for bB,bC in pairs(SavedLocations)do if bC.name and bC.name=="SatNav Location"then cr=bB;break end end;if cr~=-1 then cn=SavedLocations[cr]cr=-1;for bB,bC in pairs(b0[0])do if bC.name and bC.name=="SatNav Location"then cr=bB;break end end;if cr>-1 then b0[0][cr]=cn end;UpdateAtlasLocationsList()W=cn.name.." position updated"end end;for i=1,#AtlasOrdered do if AtlasOrdered[i].name==al then AutopilotTargetIndex=i;system.print("Index = "..AutopilotTargetIndex.." "..AtlasOrdered[i].name)UpdateAutopilotTarget()dbHud_1.setStringValue("SPBAutopilotTargetName","SatNavNotChanged")break end end end elseif iw=="msgTick"then local ct={}DisplayMessage(ct,"empty")W="empty"unit.stopTimer("msgTick")ab=3 elseif iw=="animateTick"then bb=true;ba=false;a9=0;aa=0;unit.stopTimer("animateTick")elseif iw=="hudTick"then local ct={}HUDPrologue(ct)if showHud then UpdateHud(ct)else DisplayOrbitScreen(ct)DrawWarnings(ct)end;HUDEpilogue(ct)ct[#ct+1]=e([[]],ResolutionX,ResolutionY)if W~="empty"then DisplayMessage(ct,W)end;if o()==0 and userControlScheme=="virtual joystick"then if DisplayDeadZone then DrawDeadZone(ct)end end;if o()==1 and screen_1 and screen_1.getMouseY()~=-1 then SetButtonContains()DrawButtons(ct)if screen_1.getMouseState()==1 then CheckButtons()end;ct[#ct+1]=e([[]],E,F,a9,aa)elseif system.isViewLocked()==0 then if o()==1 and V then SetButtonContains()DrawButtons(ct)if not ba and not bb then local iy=table.concat(ct,"")ct={}ct[#ct+1]=e("",ResolutionX,ResolutionY)ct[#ct+1]=b1;ct[#ct+1]=iy;ct[#ct+1]=""ba=true;ct[#ct+1]=[[]]unit.setTimer("animateTick",0.5)local content=table.concat(ct,"")system.setScreen(content)elseif bb then local iy=table.concat(ct,"")ct={}ct[#ct+1]=e("",ResolutionX,ResolutionY)ct[#ct+1]=b1;ct[#ct+1]=iy;ct[#ct+1]=""end;if not ba then ct[#ct+1]=e([[]],E,F,a9,aa)end else CheckButtons()end else if not V and o()==0 then CheckButtons()if ac>DeadZone then if DisplayDeadZone then DrawCursorLine(ct)end end else SetButtonContains()DrawButtons(ct)end;ct[#ct+1]=e([[]],E,F,a9,aa)end;ct[#ct+1]=[[]]content=table.concat(ct,"")if not DidLogOutput then system.logInfo(LastContent)DidLogOutput=true end elseif iw=="apTick"then am=j()>0;local bE=system.getTime()local iz=bE-bj;bj=bE;local cw=vec3(core.getConstructWorldOrientationForward())local cx=vec3(core.getConstructWorldOrientationRight())local iA=vec3(core.getConstructWorldOrientationUp())local cy=vec3(core.getWorldVertical())local iB=vec3(core.getConstructWorldPos())local dM=getRoll(cy,cw,cx)local dN=dM/180*math.pi;local dO=math.cos(dN)local dP=math.sin(dN)local cz=getPitch(cy,cw,cx)local iC=getPitch(cy,cw,cx*dO+iA*dP)local iD=-math.deg(cQ(iA,bd,cw))local iE=math.deg(cQ(cx,bd,cw))bi=am and iD<-YawStallAngle or iD>YawStallAngle or iE<-PitchStallAngle or iE>PitchStallAngle;bg=system.getMouseDeltaX()bh=system.getMouseDeltaY()if InvertMouse and not V then bh=-bh end;P=0;T=0;O=0;bd=vec3(core.getWorldVelocity())be=vec3(bd):len()sys=b6[0]planet=sys:closestBody(core.getConstructWorldPos())kepPlanet=b9(planet)orbit=kepPlanet:orbitalParameters(core.getConstructWorldPos(),bd)aj=hoverDetectGround()local bP=planet:getGravity(core.getConstructWorldPos()):len()*n()bk=0;b8=core.getMaxKinematicsParametersAlongAxis("ground",core.getConstructOrientationUp())[1]w,x,y,_=safeZone(iB)if o()==1 and screen_1 and screen_1.getMouseY()~=-1 then a9=screen_1.getMouseX()*ResolutionX;aa=screen_1.getMouseY()*ResolutionY elseif system.isViewLocked()==0 then if o()==1 and V then if not ba then a9=a9+bg;aa=aa+bh end else a9=0;aa=0 end else a9=a9+bg;aa=aa+bh;ac=math.sqrt(a9*a9+aa*aa)if not V and o()==0 then if userControlScheme=="virtual joystick"then if a9>0 and a9>DeadZone then P=P-(a9-DeadZone)*MouseXSensitivity elseif a9<0 and a90 and aa>DeadZone then O=O-(aa-DeadZone)*MouseYSensitivity elseif aa<0 and aa8334;if be>SpaceSpeedLimit/3.6 and not am and not Autopilot and not iF then W="Space Speed Engine Shutoff reached"if Nav.axisCommandManager:getAxisCommandType(0)==1 then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)z=0 end;if not iF and LastIsWarping then if not BrakeIsOn then BrakeToggle()end;if Autopilot then ToggleAutopilot()end end;LastIsWarping=iF;if am and j()>0.09 then if be>bm/3.6 and not AtmoSpeedAssist and not ar then BrakeIsOn=true;ar=true elseif not AtmoSpeedAssist and ar then if be85)and be>=bm/3.6-1 then BrakeIsOn=false;ProgradeIsOn=false;J=true;ag=false;ai=true;Autopilot=false;BeginReentry()else iv(math.floor(bm))z=0 end elseif be>I then AlignToWorldVector(vec3(bd),0.01)end end;if RetrogradeIsOn then if am then RetrogradeIsOn=false elseif be>I then AlignToWorldVector(-vec3(bd))end end;if not ProgradeIsOn and ag then if j()==0 then J=true;BeginReentry()ag=false;ai=true else ag=false;ToggleAutopilot()end end;local ei=vec3(core.getWorldVertical())*-1;local eg=bd.x*ei.x+bd.y*ei.y+bd.z*ei.z;if ai and CustomTarget~=nil and(anHoldAltitude-200)and be*3.6>bm-100 and math.abs(eg)<20 and j()>=0.1 and(CustomTarget.position-iB):len()>2000+an then ToggleAutopilot()ai=false end;if VertTakeOff then bc=true;if eg<-30 then W="Unable to achieve lift. Safety Landing."a8=0;bc=autoRollPreference;VertTakeOff=false;BrakeLanding=true elseif antigrav and not ExternalAGG and antigrav.getState()==1 then if an0 then BrakeIsOn=true;a8=0 elseif eg<-30 then BrakeIsOn=true;a8=15 elseif an>=antigrav.getBaseAltitude()then BrakeIsOn=true;a8=0;VertTakeOff=false;W="Takeoff complete. Singularity engaged"end else if j()>0.08 then bn=0;BrakeIsOn=false;a8=20 elseif j()<0.08 and j()>0 then BrakeIsOn=false;if bz then bn=0;a8=20 else a8=0;bn=36;iv(3500)end else bc=autoRollPreference;IntoOrbit=true;bx=false;CancelIntoOrbit=false;br=false;bp=nil;bq=nil;if bw==nil then bw=planet end;VertTakeOff=false end end;if bn~=nil then if vTpitchPID==nil then vTpitchPID=pid.new(2*0.01,0,2*0.1)end;local iH=utils.clamp(bn-iC,-PitchStallAngle*0.85,PitchStallAngle*0.85)vTpitchPID:inject(iH)local iI=utils.clamp(vTpitchPID:get(),-1,1)O=iI end end;if IntoOrbit then if bw==nil then if VectorToTarget then bw=a4 else bw=planet end end;if not bu then if bw.hasAtmosphere then bv=math.floor(bw.radius*(TargetOrbitRadius-1)+bw.noAtmosphericDensityAltitude)else bv=math.floor(bw.radius*(TargetOrbitRadius-1)+bw.surfaceMaxAltitude)end;bu=true end;if AltitudeHold or VectorToTarget then if not ah then bv=HoldAltitude;br=true;AltitudeHold=false end;if VectorToTarget then bt.VectorToTarget=VectorToTarget;VectorToTarget=false end end;local iJ,iK=b9(bw):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-bw.center):len()-bw.radius)local iL=dM;if orbit.periapsis~=nil and orbit.eccentricity<1 and an>bv and an=iN-3 then z=ee;it(ee)else z=0.05;it(0.05)end end;if orbit.apoapsis~=nil then if orbit.periapsis.altitude>bv*0.85 and orbit.periapsis.altitudeorbit.periapsis.altitude and orbit.apoapsis.altitude<=orbit.periapsis.altitude*1.35 then BrakeIsOn=false;z=0;it(0)bx=true;if iC>2 or iC<-2 then bp=0 else bo=nil;bs=false;bu=false;bw=nil;bc=autoRollPreference;W="Orbit established"if bt.VectorToTarget then VectorToTarget=bt.VectorToTarget end;bt.VectorToTarget=false;CancelIntoOrbit=false;IntoOrbit=false;br=false;bp=nil;bq=nil;bw=nil end else bo="Adjusting Orbit"bs=true;if eg>125 then iM(0.5,-65)BrakeIsOn=false elseif orbit.periapsis.altitude<0 then if be+10>iK then if eg>5 then iM(0.5,-65)BrakeIsOn=false elseif eg<-5 then iM(0.5,65)BrakeIsOn=false else it(0)BrakeIsOn=not BrakeIsOn end elseif be-100 and orbit.periapsis.altitudeiK then it(0)BrakeIsOn=not BrakeIsOn elseif be>iK+100 and eg>35 then iM(0.5,-80)BrakeIsOn=false elseif be>iK+100 and eg<-35 then iM(0.5,80)BrakeIsOn=false elseif bebv then it(0)BrakeIsOn=not BrakeIsOn else iM(0.5,15)BrakeIsOn=false end else if orbit.apoapsis.altitude>orbit.periapsis.altitude*1.3 then it(0)BrakeIsOn=not BrakeIsOn end end end end else local iO=2.75;local iP=math.abs(utils.round(iJ*iO))local iQ=iP%50;if iQ>0 then iP=iP-iQ+50 end;BrakeIsOn=false;if not br then local iR=false;local iS=false;if an=bp-1 then iR=true else iR=false end;if iL<=bq+1 and iL>=bq-1 then iS=true else iS=false end;if iR and iS then bp=nil;bq=nil;br=true end else if an=bv*0.8 and an=bv*1.15 and anbv*1.5 then bo="Reentering orbital corridor"if eg<-100 then bp=45;iP=iP*1.25 else bp=-80;iP=iP*0.75 end end end;iv(math.floor(iP))end;if bp~=nil then if OrbitPitchPID==nil then OrbitPitchPID=pid.new(2*0.01,0,2*0.1)end;local iT=bp-iC;OrbitPitchPID:inject(iT)local iU=utils.clamp(OrbitPitchPID:get(),-0.5,0.5)O=iU end;if bq~=nil then if iC<85 then local iV=math.max(autoRollFactor,0.01)/4;if OrbitRollPID==nil then OrbitRollPID=pid.new(iV*0.01,0,iV*0.1)end;local iW=bq-iL;OrbitRollPID:inject(iW)local iX=utils.clamp(OrbitRollPID:get(),-0.5,0.5)T=iX end end elseif CancelIntoOrbit then bu=false;bw=nil;it(0)CancelIntoOrbit=false end;if Autopilot and j()==0 and not ag then local iY,iZ=AutopilotTargetCoords,false;if CustomTarget~=nil and CustomTarget.planetname~="Space"then AutopilotRealigned=true;if not TargetSet then local i_=(CustomTarget.position-a4.center):normalize()local j0=i_:project_on_plane((a4.center-iB):normalize()):normalize()local j1=a4.center+j0*(a4.radius+AutopilotTargetOrbit)local j2=CustomTarget.position+(CustomTarget.position-a4.center):normalize()*(AutopilotTargetOrbit-a4:getAltitude(CustomTarget.position))if(iB-j1):len()<(iB-j2):len()then iY=j1;AutopilotTargetCoords=iY else iY=CustomTarget.position+(CustomTarget.position-a4.center):normalize()*(AutopilotTargetOrbit-a4:getAltitude(CustomTarget.position))AutopilotTargetCoords=iY end;local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)iZ=true;TargetSet=true end;AutopilotPlanetGravity=0 elseif CustomTarget~=nil and CustomTarget.planetname=="Space"then AutopilotPlanetGravity=0;iZ=true;TargetSet=true;AutopilotRealigned=true;iY=CustomTarget.position+(iB-CustomTarget.position)*AutopilotTargetOrbit elseif CustomTarget==nil then AutopilotPlanetGravity=0;if not TargetSet then local i_=(iB+bd*100000-a4.center):normalize()local j0=i_:project_on_plane((a4.center-iB):normalize()):normalize()if j0:len()<1 then i_=(iB+vec3(core.getConstructWorldOrientationForward())*100000-a4.center):normalize()j0=i_:project_on_plane((a4.center-iB):normalize()):normalize()end;iY=a4.center+j0*(a4.radius+AutopilotTargetOrbit)AutopilotTargetCoords=iY;TargetSet=true;iZ=true;AutopilotRealigned=true;local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)end end;AutopilotDistance=(vec3(iY)-vec3(core.getConstructWorldPos())):len()local ff,fg,fh=b6:getPlanetarySystem(0):castIntersections(iB,bd:normalize(),function(fi)if fi.noAtmosphericDensityAltitude>0 then return fi.radius+fi.noAtmosphericDensityAltitude else return fi.radius+fi.surfaceMaxAltitude*1.5 end end)local fj=fg;if fh~=nil and fg~=nil then fj=math.min(fh,fg)end;if fj~=nil and fj300 and AutopilotAccelerating then local dv=vec3(iY)-vec3(core.getConstructWorldPos())local j4=utils.clamp(math.deg(cQ(iA,bd:normalize(),dv:normalize()))*be/500,-90,90)local j5=utils.clamp(math.deg(cQ(cx,bd:normalize(),dv:normalize()))*be/500,-90,90)if math.abs(j4)<20 and math.abs(j5)<20 then j4=j4*2;j5=j5*2 end;if math.abs(j4)<2 and math.abs(j5)<2 then j4=j4*2;j5=j5*2 end;local iD=-math.deg(cQ(iA,cw,bd:normalize()))local iE=-math.deg(cQ(cx,cw,bd:normalize()))if apPitchPID==nil then apPitchPID=pid.new(2*0.01,0,2*0.1)end;apPitchPID:inject(j5-iE)local j6=utils.clamp(apPitchPID:get(),-1,1)O=O+j6;if apYawPID==nil then apYawPID=pid.new(2*0.01,0,2*0.1)end;apYawPID:inject(j4-iD)local j7=utils.clamp(apYawPID:get(),-1,1)P=P+j7;iZ=true;if math.abs(j4)>2 or math.abs(j5)>2 then AutopilotStatus="Adjusting Trajectory"else AutopilotStatus="Accelerating"end end;if j3=MaxGameVelocity or fH==0 and G then AutopilotAccelerating=false;AutopilotStatus="Cruising"AutopilotCruising=true;it(0)z=0 end;if AutopilotDistance<=a0 then AutopilotAccelerating=false;AutopilotStatus="Braking"AutopilotBraking=true;it(0)z=0;G=false end elseif AutopilotBraking then if AutopilotStatus~="Orbiting to Target"then BrakeIsOn=true;S=1 end;if TurnBurn then it(100,true)z=1 end;local _,iK=b9(a4):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-planet.center):len()-planet.radius)local dv;if CustomTarget~=nil then dv=CustomTarget.position-iB end;if CustomTarget~=nil and CustomTarget.planetname=="Space"and be<50 then W="Autopilot complete, arrived at space location"AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"elseif CustomTarget~=nil and CustomTarget.planetname~="Space"and be<=iK and(orbit.apoapsis==nil or orbit.periapsis==nil or orbit.apoapsis.altitude<=0 or orbit.periapsis.altitude<=0)then W="Autopilot complete, proceeding with reentry"AutopilotTargetCoords=CustomTarget.position;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"it(0)z=0;G=false;ProgradeIsOn=true;ag=true;local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)elseif orbit.periapsis~=nil and orbit.periapsis.altitude>0 and orbit.eccentricity<1 then AutopilotStatus="Circularizing"local _,iK=b9(a4):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-planet.center):len()-planet.radius)if be<=iK then if CustomTarget~=nil then if bd:normalize():dot(dv:normalize())>0.4 then AutopilotStatus="Orbiting to Target"if not WaypointSet then BrakeIsOn=false;local cA=zeroConvertToMapPosition(a4,CustomTarget.position)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)WaypointSet=true end else W="Autopilot complete, proceeding with reentry"AutopilotTargetCoords=CustomTarget.position;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"it(0)z=0;G=false;ProgradeIsOn=true;ag=true;BrakeIsOn=false;local cA=zeroConvertToMapPosition(a4,CustomTarget.position)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)WaypointSet=false end else BrakeIsOn=false;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"W="Autopilot completed, orbit established"S=0;z=0;G=false;if CustomTarget~=nil and CustomTarget.planetname~="Space"then ProgradeIsOn=true;ag=true end end end end elseif AutopilotCruising then if AutopilotDistance<=a0 then AutopilotAccelerating=false;AutopilotStatus="Braking"AutopilotBraking=true end;local fH=unit.getThrottle()if AtmoSpeedAssist then fH=z end;if fH>0 then AutopilotAccelerating=true;AutopilotStatus="Accelerating"AutopilotCruising=false end else if iG then if not AutopilotRealigned and CustomTarget==nil or not AutopilotRealigned and CustomTarget~=nil and CustomTarget.planetname~="Space"then if not ag then AutopilotTargetCoords=vec3(a4.center)+(AutopilotTargetOrbit+a4.radius)*vec3(core.getConstructWorldOrientationRight())AutopilotShipUp=core.getConstructWorldOrientationUp()AutopilotShipRight=core.getConstructWorldOrientationRight()end;AutopilotRealigned=true elseif iG then AutopilotAccelerating=true;AutopilotStatus="Accelerating"if not G then it(AutopilotInterplanetaryThrottle,true)z=round(AutopilotInterplanetaryThrottle,2)G=true;BrakeIsOn=false end end end end elseif Autopilot and(CustomTarget~=nil and CustomTarget.planetname~="Space"and j()>0)then W="Autopilot complete, proceeding with reentry"AutopilotTargetCoords=CustomTarget.position;BrakeIsOn=false;AutopilotBraking=false;Autopilot=false;TargetSet=false;AutopilotStatus="Aligning"S=0;it(0)z=0;G=false;ProgradeIsOn=true;ag=true;local cA=zeroConvertToMapPosition(a4,CustomTarget.position)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)end;if U then bc=true;local j5=0;local cg=vec3(core.getConstructWorldPos())+vec3(unit.getMasterPlayerRelativePosition())local j8=cg-vec3(core.getConstructWorldPos())local j9=vec3(j8):project_on(vec3(core.getConstructWorldOrientationForward())):len()local ja=vec3(j8):project_on(vec3(core.getConstructWorldOrientationRight())):len()local ac=math.sqrt(j9*j9+ja*ja)AlignToWorldVector(j8:normalize())local jb=40;local jc=acje then if pitchPID==nil then pitchPID=pid.new(2*0.01,0,2*0.1)end;pitchPID:inject(j5-cz)local j6=pitchPID:get()O=j6 end end;if AltitudeHold or BrakeLanding or Reentry or VectorToTarget or LockPitch~=nil then local cB=unit.getClosestPlanetInfluence()>0;local jf=HoldAltitude-an;local jg=500+be;local jh=1;if AutoTakeoff then jh=utils.clamp(be/100,0.1,1)end;local j5=(utils.smoothstep(jf,-jg,jg)-0.5)*2*MaxPitch*jh;if not Reentry and not ag and not VectorToTarget and cw:dot(bd:normalize())<0.99 then j5=(utils.smoothstep(jf,-jg*utils.clamp(20-19*j()*10,1,20),jg*utils.clamp(20-19*j()*10,1,20))-0.5)*2*MaxPitch*utils.clamp(2-j()*10,1,2)*jh end;if not AltitudeHold then j5=0 end;if LockPitch~=nil then if cB and not IntoOrbit then j5=LockPitch else LockPitch=nil end end;bc=true;local ji=O;if Reentry then local ReentrySpeed=math.floor(bm)local jj,jk=b7.computeDistanceAndTime(be,ReentrySpeed/3.6,n(),0,0,LastMaxBrake-planet.gravity*9.8*n())local jl=an-(planet.noAtmosphericDensityAltitude+5000)if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and an>planet.noAtmosphericDensityAltitude+5000 and be<=ReentrySpeed/3.6 and be>ReentrySpeed/3.6-10 and math.abs(bd:normalize():dot(cw))>0.9 then Nav.control.cancelCurrentControlMasterMode()z=0 elseif Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byThrottle and(jj>-1 and jl<=jj or an<=planet.noAtmosphericDensityAltitude+5000)then BrakeIsOn=true else BrakeIsOn=false end;iv(ReentrySpeed,true)if not J then j5=-80;if j()>0.02 then W="PARACHUTE DEPLOYED"Reentry=false;BrakeLanding=true;j5=0;bc=autoRollPreference end elseif planet.noAtmosphericDensityAltitude>0 and an>planet.noAtmosphericDensityAltitude+5000 then bc=true elseif an<=planet.noAtmosphericDensityAltitude+5000 then iv(ReentrySpeed)if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)==bm then J=false;Reentry=false;bc=true end end end;if be>I and not ah and not VectorToTarget and not BrakeLanding and ForceAlignment then AlignToWorldVector(vec3(bd))end;if(VectorToTarget or ah)and AutopilotTargetIndex>0 and j()>0.01 then local dv;if CustomTarget~=nil then dv=CustomTarget.position-vec3(core.getConstructWorldPos())else dv=a4.center-iB end;local j4=math.deg(cQ(cy:normalize(),bd,dv))*2;local jm=math.rad(math.abs(dM))if be>minRollVelocity and j()>0.01 then local jn=utils.clamp(90-j5*2,-90,90)bk=utils.clamp(j4*2,-jn,jn)local jo=j4;j4=utils.clamp(utils.clamp(j4,-YawStallAngle*0.85,YawStallAngle*0.85)*math.cos(jm)+4*(iC-j5)*math.sin(math.rad(dM)),-YawStallAngle*0.85,YawStallAngle*0.85)j5=utils.clamp(utils.clamp(j5*math.cos(jm),-PitchStallAngle*0.85,PitchStallAngle*0.85)+math.abs(utils.clamp(math.abs(jo)*math.sin(jm),-PitchStallAngle*0.85,PitchStallAngle*0.85)),-PitchStallAngle*0.85,PitchStallAngle*0.85)else bk=0;j4=utils.clamp(j4,-YawStallAngle*0.85,YawStallAngle*0.85)end;local jp=iD-j4;if not bi and be>minRollVelocity and j()>0.01 then if yawPID==nil then yawPID=pid.new(2*0.01,0,2*0.1)end;yawPID:inject(jp)local j7=utils.clamp(yawPID:get(),-1,1)P=P+j7 elseif am and aj>-1 or be0.01 then if(iD<-YawStallAngle or iD>YawStallAngle)and j()>0.01 then AlignToWorldVector(bd)end;if(iE<-PitchStallAngle or iE>PitchStallAngle)and j()>0.01 then j5=utils.clamp(iC-iE,iC-PitchStallAngle*0.85,iC+PitchStallAngle*0.85)end end;if CustomTarget~=nil and not ah then local jq=planet:getAltitude(CustomTarget.position)local jl=math.sqrt(dv:len()^2-(an-jq)^2)local jr=LastMaxBrakeInAtmo;if jr then jr=jr*utils.clamp(be/100,0.1,1)*j()else jr=LastMaxBrake end;if j()<0.01 then jr=LastMaxBrake end;local js=bd:len()-math.abs(eg)local jt=vec3(core.getWorldAirFrictionAcceleration())local ju=math.sqrt(jt:len()-jt:project_on(ei):len())*n()if be>100 then a0,a1=b7.computeDistanceAndTime(be,100,n(),0,0,jr+ju)local jv,jw=b7.computeDistanceAndTime(100,0,n(),0,0,jr/2)a0=a0+jv else a0,a1=b7.computeDistanceAndTime(be,0,n(),0,0,jr/2)end;StrongBrakes=true;if not ah and not Reentry and jl<=a0+be*iz/2 and(bd:project_on_plane(cy):normalize():dot(dv:project_on_plane(cy):normalize())>0.99 or VectorStatus=="Finalizing Approach")then VectorStatus="Finalizing Approach"it(0)z=0;if AltitudeHold then ToggleAltitudeHold()VectorToTarget=true end;BrakeIsOn=true elseif not AutoTakeoff then BrakeIsOn=false end;if VectorStatus=="Finalizing Approach"and(js<0.1 or jl<0.1 or LastDistanceToTarget~=nil and LastDistanceToTargetplanet.noAtmosphericDensityAltitude and not(ah or Reentry)then if CustomTarget~=nil and a4.name==planet.name then local dv=CustomTarget.position-vec3(core.getConstructWorldPos())local jq=planet:getAltitude(CustomTarget.position)local jl=math.sqrt(dv:len()^2-(an-jq)^2)local jr=LastMaxBrakeInAtmo;if not bx and jl>100000 then bu=false;IntoOrbit=true else jr=LastMaxBrake;a0,a1=b7.computeDistanceAndTime(be,0,n(),0,0,jr/2)StrongBrakes=true;if jl<=a0+be*iz/2 and bd:project_on_plane(cy):normalize():dot(dv:project_on_plane(cy):normalize())>0.99 then if planet.hasAtmosphere then BrakeIsOn=false;ProgradeIsOn=false;J=true;ag=false;ai=true;Autopilot=false;BeginReentry()end end;LastDistanceToTarget=jl end end end;if j()==0 and(AltitudeHold and HoldAltitude>planet.noAtmosphericDensityAltitude)and not(ah or VectorToTarget or IntoOrbit or Reentry)then if not bx then IntoOrbit=true end end;if bi and j()>0.01 and aj==-1 and be>minRollVelocity and VectorStatus~="Finalizing Approach"then AlignToWorldVector(bd)j5=utils.clamp(iC-iE,iC-PitchStallAngle*0.85,iC+PitchStallAngle*0.85)end;O=ji;local fQ=-1;if BrakeLanding then j5=0;local jx=false;local jy=30;if b8~=nil and b8>0 then local ju=0;local dS=utils.clamp(j(),0.4,2)local jr=LastMaxBrakeInAtmo*utils.clamp(be/100,0.1,1)*dS;local jz=b8*dS+jr+ju-bP;local jA=jr/2+ju-bP;local jB=be-math.sqrt(math.abs(jA/2)*20/(0.5*n()))*utils.sign(jA)if jB<0 then jB=0 end;local jC;if be>100 then local jD,_=b7.computeDistanceAndTime(be,100,n(),0,0,jr)local jE,_=b7.computeDistanceAndTime(100,0,n(),0,0,math.sqrt(jr))jC=jD+jE else jC=b7.computeDistanceAndTime(be,0,n(),0,0,math.sqrt(jr))end;if jC<20 then BrakeIsOn=false else local jF=0;if jB>100 then local jG,_=b7.computeDistanceAndTime(jB,100,n(),0,0,jz)local jH,_=b7.computeDistanceAndTime(100,0,n(),0,0,b8*dS+math.sqrt(jr)+ju-bP)jF=jG+jH else jF,_=b7.computeDistanceAndTime(jB,0,n(),0,0,b8*dS+math.sqrt(jr)+ju-bP)end;jF=(jF+15+be*iz)*1.1;local jI=CustomTarget~=nil and planet:getAltitude(CustomTarget.position)>0 and CustomTarget.safe;if jI then local jq=planet:getAltitude(CustomTarget.position)local jJ=an-jq-100;local dv=CustomTarget.position-vec3(core.getConstructWorldPos())local jK=math.sqrt(dv:len()^2-(an-jq)^2)if jK>100 then jI=false elseif jJ<=jF or jF==-1 then BrakeIsOn=true;jx=true else BrakeIsOn=false;jx=true end end;if not jI and CalculateBrakeLandingSpeed then if jF>=jy then BrakeIsOn=true else BrakeIsOn=false end;jx=true end end end;if Nav.axisCommandManager:getAxisCommandType(0)==1 then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setTargetGroundAltitude(500)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(500)fQ=aj;if fQ>-1 then bc=autoRollPreference;if be<1 or bd:normalize():dot(cy)<0 then BrakeLanding=false;AltitudeHold=false;GearExtended=true;Nav.control.extendLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)a8=0;BrakeIsOn=true else BrakeIsOn=true end elseif StrongBrakes and bd:normalize():dot(-ei)<0.999 then BrakeIsOn=true elseif eg<-brakeLandingRate and not jx then BrakeIsOn=true elseif not jx then BrakeIsOn=false end end;if AutoTakeoff or ah then local ff,fh,fg;if AutopilotTargetCoords~=nil then ff,fh,fg=b6:getPlanetarySystem(0):castIntersections(iB,(AutopilotTargetCoords-iB):normalize(),function(fi)return fi.radius+fi.noAtmosphericDensityAltitude end)end;if antigrav and antigrav.getState()==1 then if an>=HoldAltitude-50 then AutoTakeoff=false;BrakeIsOn=true;it(0)z=0 else HoldAltitude=antigrav.getBaseAltitude()end elseif math.abs(j5)<15 and an/HoldAltitude>0.75 then AutoTakeoff=false;if not ah then if Nav.axisCommandManager:getAxisCommandType(0)==0 and not AtmoSpeedAssist then Nav.control.cancelCurrentControlMasterMode()end elseif ah and be-1;local jM=cz;if(VectorToTarget or ah)and not jL and be>minRollVelocity and j()>0.01 then local jm=math.rad(math.abs(dM))jM=cz*math.abs(math.cos(jm))+iE*math.sin(jm)end;local jN=utils.clamp(j5-jM,-PitchStallAngle*0.85,PitchStallAngle*0.85)if j()<0.01 and VectorToTarget then jN=utils.clamp(j5-jM,-85,MaxPitch)elseif j()<0.01 then jN=utils.clamp(j5-jM,-MaxPitch,MaxPitch)end;if math.abs(dM)<5 or VectorToTarget or BrakeLanding or jL or AltitudeHold then if pitchPID==nil then pitchPID=pid.new(5*0.01,0,5*0.1)end;pitchPID:inject(jN)local j6=pitchPID:get()O=O+j6 end end;if antigrav~=nil and(antigrav and not ExternalAGG and an<200000)then if AntigravTargetAltitude==nil or AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;if desiredBaseAltitude~=AntigravTargetAltitude then desiredBaseAltitude=AntigravTargetAltitude;antigrav.setBaseAltitude(desiredBaseAltitude)end end end end;function script.onFlush()if antigrav~=nil and(antigrav and not ExternalAGG)then if antigrav.getState()==0 and antigrav.getBaseAltitude()~=AntigravTargetAltitude then antigrav.setBaseAltitude(AntigravTargetAltitude)end end;if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byThrottle and D then z=0;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,z)D=false elseif Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed and not D then z=0;D=true end;pitchSpeedFactor=math.max(pitchSpeedFactor,0.01)yawSpeedFactor=math.max(yawSpeedFactor,0.01)rollSpeedFactor=math.max(rollSpeedFactor,0.01)torqueFactor=math.max(torqueFactor,0.01)brakeSpeedFactor=math.max(brakeSpeedFactor,0.01)brakeFlatFactor=math.max(brakeFlatFactor,0.01)autoRollFactor=math.max(autoRollFactor,0.01)turnAssistFactor=math.max(turnAssistFactor,0.01)local jO=utils.clamp(N+O+system.getControlDeviceForwardInput(),-1,1)local jP=utils.clamp(Q+T+system.getControlDeviceYawInput(),-1,1)local jQ=utils.clamp(R+P-system.getControlDeviceLeftRightInput(),-1,1)local jR=S;local jS=vec3(core.getWorldVertical())if jS==nil or jS:len()==0 then jS=(planet.center-vec3(core.getConstructWorldPos())):normalize()end;local jT=vec3(core.getConstructWorldOrientationUp())local jU=vec3(core.getConstructWorldOrientationForward())local jV=vec3(core.getConstructWorldOrientationRight())local jW=vec3(core.getWorldVelocity())local jX=vec3(core.getWorldVelocity()):normalize()local jY=getRoll(jS,jU,jV)local jZ=math.abs(jY)local j_=utils.sign(jY)local j=j()local k0=vec3(core.getWorldAngularVelocity())local k1=jO*pitchSpeedFactor*jV+jP*rollSpeedFactor*jU+jQ*yawSpeedFactor*jT;if jS:len()>0.01 and(j>0.0 or ProgradeIsOn or Reentry or ag or AltitudeHold)then local dM=getRoll(jS,jU,jV)local dN=dM/180*math.pi;local dO=math.cos(dN)local dP=math.sin(dN)local iC=getPitch(jS,jU,jV*dO+jT*dP)if bc==true and math.abs(bk-jY)>autoRollRollThreshold and jP==0 and math.abs(iC)<85 then local k2=bk;local iV=autoRollFactor;if j==0 then iV=iV/4;bk=0;k2=0 end;if rollPID==nil then rollPID=pid.new(iV*0.01,0,iV*0.1)end;rollPID:inject(k2-jY)local k3=rollPID:get()k1=k1+k3*jU end end;if jS:len()>0.01 and j>0.0 then local k4=20.0;if turnAssist==true and jZ>k4 and jO==0 and jQ==0 then local k5=turnAssistFactor*0.1;local k6=turnAssistFactor*0.025;local k7=(jZ-k4)/(180-k4)*180;local k8=0;if k7<90 then k8=k7/90 elseif k7<180 then k8=(180-k7)/90 end;k8=k8*k8;local k9=-j_*k6*(1.0-k8)local ka=k5*k8;k1=k1+ka*jV+k9*jT end end;local kb=1;local kc=0;local kd=1;if system.getMouseWheel()>0 then if AltIsOn then if j>0 or Reentry then bm=utils.clamp(bm+speedChangeLarge,0,AtmoSpeedLimit)elseif Autopilot then MaxGameVelocity=utils.clamp(MaxGameVelocity+speedChangeLarge/3.6*100,0,8333.00)end;H=false else z=round(utils.clamp(z+speedChangeLarge/100,-1,1),2)end elseif system.getMouseWheel()<0 then if AltIsOn then if j>0 or Reentry then bm=utils.clamp(bm-speedChangeLarge,0,AtmoSpeedLimit)elseif Autopilot then MaxGameVelocity=utils.clamp(MaxGameVelocity-speedChangeLarge/3.6*100,0,8333.00)end;H=false else z=round(utils.clamp(z-speedChangeLarge/100,-1,1),2)end end;A=0;local eg=-jS:dot(jW)if am and AtmoSpeedAssist and Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byThrottle then if throttlePID==nil then throttlePID=pid.new(0.5,0,1)end;throttlePID:inject(bm/3.6-jW:dot(jU))local ke=throttlePID:get()C=utils.clamp(ke,-1,1)if C0.005 then B=true;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,utils.clamp(C,0.01,1))else B=false;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,z)end;if brakePID==nil then brakePID=pid.new(1*0.01,0,1*0.1)end;brakePID:inject(jW:len()-bm/3.6)local kf=utils.clamp(brakePID:get(),0,1)if j>0 and eg<-80 or j>0.005 then A=kf end;if A>0 then if B and C==0.01 then Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)end else C=utils.clamp(C,0.01,1)end;local kg=''local kh=vec3()local ki=composeAxisAccelerationFromTargetSpeedV(axisCommandId.vertical,a8*1000)Nav:setEngineForceCommand("vertical airfoil , vertical ground ",ki,kc)local kj='thrust analog longitudinal 'if ExtraLongitudeTags~="none"then kj=kj..ExtraLongitudeTags end;local kk=Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)local kl=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(kj,axisCommandId.longitudinal)local km=composeAxisAccelerationFromTargetSpeed(axisCommandId.lateral,LeftAmount*1000)kg=kg..' , '.."lateral airfoil , lateral ground "kh=kh+km;if kh:len()>constants.epsilon then Nav:setEngineForceCommand(kg,kh,kc,'','','',kd)end;Nav:setEngineForceCommand(kj,kl,kb)local kn='thrust analog vertical fueled 'local ko='thrust analog lateral fueled 'if ExtraLateralTags~="none"then ko=ko..ExtraLateralTags end;if ExtraVerticalTags~="none"then kn=kn..ExtraVerticalTags end;if a8~=0 or BrakeLanding and BrakeIsOn then Nav:setEngineForceCommand(kn,ki,kb)else Nav:setEngineForceCommand(kn,vec3(),kb)end;if LeftAmount~=0 then Nav:setEngineForceCommand(ko,km,kb)else Nav:setEngineForceCommand(ko,vec3(),kb)end;if jR==0 then jR=A end;local kp=-jR*(brakeSpeedFactor*jW+brakeFlatFactor*jX)Nav:setEngineForceCommand('brake',kp)else if AtmoSpeedAssist then Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,z)end;local kp=-jR*(brakeSpeedFactor*jW+brakeFlatFactor*jX)Nav:setEngineForceCommand('brake',kp)local kg=''local kh=vec3()local kq=false;local kj='thrust analog longitudinal 'if ExtraLongitudeTags~="none"then kj=kj..ExtraLongitudeTags end;local kk=Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)if kk==axisCommandType.byThrottle then local kl=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(kj,axisCommandId.longitudinal)Nav:setEngineForceCommand(kj,kl,kb)elseif kk==axisCommandType.byTargetSpeed then local kl=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.longitudinal)kg=kg..' , '..kj;kh=kh+kl;if Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)==0 or Nav.axisCommandManager:getCurrentToTargetDeltaSpeed(axisCommandId.longitudinal)<-Nav.axisCommandManager:getTargetSpeedCurrentStep(axisCommandId.longitudinal)*0.5 then kq=true end end;local ko='thrust analog lateral 'if ExtraLateralTags~="none"then ko=ko..ExtraLateralTags end;local kr=Nav.axisCommandManager:getAxisCommandType(axisCommandId.lateral)if kr==axisCommandType.byThrottle then local ks=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(ko,axisCommandId.lateral)Nav:setEngineForceCommand(ko,ks,kb)elseif kr==axisCommandType.byTargetSpeed then local km=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.lateral)kg=kg..' , '..ko;kh=kh+km end;local kn='thrust analog vertical 'if ExtraVerticalTags~="none"then kn=kn..ExtraVerticalTags end;local kt=Nav.axisCommandManager:getAxisCommandType(axisCommandId.vertical)if kt==axisCommandType.byThrottle then local ki=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(kn,axisCommandId.vertical)if a8~=0 or BrakeLanding and BrakeIsOn then Nav:setEngineForceCommand(kn,ki,kb,'airfoil','ground','',kd)else Nav:setEngineForceCommand(kn,vec3(),kb)Nav:setEngineForceCommand('airfoil vertical',ki,kb,'airfoil','','',kd)Nav:setEngineForceCommand('ground vertical',ki,kb,'ground','','',kd)end elseif kt==axisCommandType.byTargetSpeed then if a8<0 then Nav:setEngineForceCommand('hover',vec3(),kb)end;local ku=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.vertical)kg=kg..' , '..kn;kh=kh+ku end;local gb=unit.getAxisCommandValue(0)if kh:len()>constants.epsilon then if S~=0 or kq or math.abs(jX:dot(jU))<0.8 or bd:len()>gb/3.6 then kg=kg..', brake'end;Nav:setEngineForceCommand(kg,kh,kc,'','','',kd)end end;local kv=torqueFactor*(k1-k0)local kw=vec3(core.getWorldAirFrictionAngularAcceleration())kv=kv-kw;Nav:setEngineTorqueCommand('torque',kv,kb,'airfoil','','',kd)Nav:setBoosterCommand('rocket_engine')if Z and not VanillaRockets then local bS=vec3(core.getVelocity()):len()local kx=0.15;if Nav.axisCommandManager:getAxisCommandType(0)==1 then local ky=Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)if bS*3.6>ky*(1-kx)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bS*3.6=gb*(1-kx)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bS=gb*(1-kx)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bS0 or anHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude+Y;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude+Y end else AntigravTargetAltitude=desiredBaseAltitude+100 end elseif AltitudeHold then HoldAltitude=HoldAltitude+X else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(1.0)end elseif kz=="groundaltitudedown"then OldButtonMod=X;OldAntiMod=Y;if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitudeHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end end else AntigravTargetAltitude=desiredBaseAltitude end elseif AltitudeHold then HoldAltitude=HoldAltitude-X else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(-1.0)end elseif kz=="option1"then if not Autopilot then IncrementAutopilotTargetIndex()H=false end elseif kz=="option2"then if not Autopilot then DecrementAutopilotTargetIndex()H=false end elseif kz=="option3"then if hideHudOnToggleWidgets then if showHud then showHud=false else showHud=true end end;H=false;ToggleWidgets()elseif kz=="option4"then ToggleAutopilot()H=false elseif kz=="option5"then ToggleLockPitch()H=false elseif kz=="option6"then ToggleAltitudeHold()H=false elseif kz=="option7"then wipeSaveVariables()H=false elseif kz=="option8"then ToggleFollowMode()H=false elseif kz=="option9"then if gyro~=nil then gyro.toggle()aq=gyro.getState()==1 end;H=false elseif kz=="lshift"then if system.isViewLocked()==1 then V=true;PrevViewLock=system.isViewLocked()system.lockView(1)elseif o()==1 and ShiftShowsRemoteButtons then V=true;bb=false;ba=false end elseif kz=="brake"then if BrakeToggleStatus then BrakeToggle()elseif not BrakeIsOn then BrakeToggle()else BrakeIsOn=true end elseif kz=="lalt"then AltIsOn=true;if o()==0 and not freeLookToggle and userControlScheme=="keyboard"then system.lockView(1)end elseif kz=="booster"then if VanillaRockets then Nav:toggleBoosters()elseif not Z then if not IsRocketOn then Nav:toggleBoosters()IsRocketOn=true end;Z=true else if IsRocketOn then Nav:toggleBoosters()IsRocketOn=false end;Z=false end elseif kz=="stopengines"then Nav.axisCommandManager:resetCommand(axisCommandId.longitudinal)clearAll()z=0 elseif kz=="speedup"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z+speedChangeLarge/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal,speedChangeLarge)end else IncrementAutopilotTargetIndex()end elseif kz=="speeddown"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z-speedChangeLarge/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal,-speedChangeLarge)end else DecrementAutopilotTargetIndex()end elseif kz=="antigravity"and not ExternalAGG then if antigrav~=nil then ToggleAntigrav()end end end;function script.onActionStop(kz)if kz=="forward"then N=0 elseif kz=="backward"then N=0 elseif kz=="left"then Q=0 elseif kz=="right"then Q=0 elseif kz=="yawright"then R=0 elseif kz=="yawleft"then R=0 elseif kz=="straferight"then Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral,-1.0)LeftAmount=0 elseif kz=="strafeleft"then Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral,1.0)LeftAmount=0 elseif kz=="up"then a8=0;Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical,-1.0)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(currentGroundAltitudeStabilization)Nav:setEngineForceCommand('hover',vec3(),1)elseif kz=="down"then a8=0;Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical,1.0)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(currentGroundAltitudeStabilization)Nav:setEngineForceCommand('hover',vec3(),1)elseif kz=="groundaltitudeup"then if antigrav and not ExternalAGG and antigrav.getState()==1 then Y=OldAntiMod end;if AltitudeHold then X=OldButtonMod end;H=false elseif kz=="groundaltitudedown"then if antigrav and not ExternalAGG and antigrav.getState()==1 then Y=OldAntiMod end;if AltitudeHold then X=OldButtonMod end;H=false elseif kz=="lshift"then if system.isViewLocked()==1 then V=false;a9=0;aa=0;system.lockView(PrevViewLock)elseif o()==1 and ShiftShowsRemoteButtons then V=false;bb=false;ba=false end elseif kz=="brake"then if not BrakeToggleStatus then if BrakeIsOn then BrakeToggle()else BrakeIsOn=false end end elseif kz=="lalt"then if o()==0 and freeLookToggle then if H then if system.isViewLocked()==1 then system.lockView(0)else system.lockView(1)end else H=true end elseif o()==0 and not freeLookToggle and userControlScheme=="keyboard"then system.lockView(0)end;AltIsOn=false end end;function script.onActionLoop(kz)if kz=="groundaltitudeup"then if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitudeHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude+Y;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude+Y end;Y=Y*1.05;BrakeIsOn=false else AntigravTargetAltitude=desiredBaseAltitude+100;BrakeIsOn=false end elseif AltitudeHold then HoldAltitude=HoldAltitude+X;X=X*1.05 else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(1.0)end elseif kz=="groundaltitudedown"then if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitudeHoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude-Y;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end end;Y=Y*1.05;BrakeIsOn=false else AntigravTargetAltitude=desiredBaseAltitude-100;BrakeIsOn=false end elseif AltitudeHold then HoldAltitude=HoldAltitude-X;X=X*1.05 else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(-1.0)end elseif kz=="speedup"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z+speedChangeSmall/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal,speedChangeSmall)end end elseif kz=="speeddown"then if not V then if AtmoSpeedAssist and not AltIsOn then z=utils.clamp(z-speedChangeSmall/100,-1,1)else Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal,-speedChangeSmall)end end end end;function script.onInputText(dA)local i;local kA="/commands /setname /G /agg /addlocation /copydatabank"local kB,kC=nil,nil;local kD="Command List:\n/commands \n/setname - Updates current selected saved position name\n/G VariableName newValue - Updates global variable to new value\n".."/G dump - shows all updatable variables with /G\n/agg - Manually set agg target height\n".."/addlocation savename ::pos{0,2,46.4596,-155.1799,22.6572} - adds a saved location by waypoint, not as accurate as making one at location\n".."/copydatabank - copies dbHud databank to a blank databank"i=string.find(dA," ")kB=dA;if i~=nil then kB=string.sub(dA,0,i-1)kC=string.sub(dA,i+1)elseif not string.find(kA,kB)then for g7 in string.gmatch(kD,"([^\n]+)")do c(g7)end;return end;if kB=="/setname"then if kC==nil or kC==""then W="Usage: /setname Newname"return end;if AutopilotTargetIndex>0 and CustomTarget~=nil then UpdatePosition(kC)else W="Select a saved target to rename first"end elseif kB=="/addlocation"then if kC==nil or kC==""or string.find(kC,"::")==nil then W="Usage: /addlocation savename ::pos{0,2,46.4596,-155.1799,22.6572}"return end;i=string.find(kC,"::")local cm=string.sub(kC,1,i-2)local cg=string.sub(kC,i)local q=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local ch='::pos{'..q..','..q..','..q..','..q..','..q..'}'local ci,cj,cd,ce,cc=string.match(cg,ch)local planet=b0[tonumber(ci)][tonumber(cj)]AddNewLocationByWaypoint(cm,planet,cg)W="Added "..cm.." to saved locations,\nplanet "..planet.name.." at "..cg;ab=5 elseif kB=="/agg"then if kC==nil or kC==""then W="Usage: /agg targetheight"return end;kC=tonumber(kC)if kC<1000 then kC=1000 end;AntigravTargetAltitude=kC;W="AGG Target Height set to "..kC elseif kB=="/G"then if kC==nil or kC==""then W="Usage: /G VariableName variablevalue\n/G dump - shows all variables"return end;if kC=="dump"then for bB,bC in pairs(a)do if type(_G[bC])=="boolean"then if _G[bC]==true then c(bC.." true")else c(bC.." false")end elseif _G[bC]==nil then c(bC.." nil")else c(bC.." ".._G[bC])end end;return end;i=string.find(kC," ")local kE=string.sub(kC,0,i-1)local kF=string.sub(kC,i+1)for bB,bC in pairs(a)do if bC==kE then W="Variable "..kE.." changed to "..kF;local kG=type(_G[bC])if kG=="number"then kF=tonumber(kF)elseif kG=="boolean"then if string.lower(kF)=="true"then kF=true else kF=false end end;_G[bC]=kF;return end end;W="No such global variable: "..kE elseif kB=="/copydatabank"then if dbHud_2 then SaveDataBank(true)else W="Databank required to copy databank"end end end;script.onStart() -- error handling code added by wrap.lua diff --git a/src/ButtonHUD.lua b/src/ButtonHUD.lua index 3155cda..a821274 100644 --- a/src/ButtonHUD.lua +++ b/src/ButtonHUD.lua @@ -5514,7 +5514,7 @@ function safeZone(WorldPos) -- Thanks to @SeM for the base code, modified to wor -- Start of actual HUD Script. Written by Dimencia and Archaegeo. Optimization and Automation of scripting by ChronosWS Linked sources where appropriate, most have been modified. function script.onStart() - VERSION_NUMBER = 5.441 + VERSION_NUMBER = 5.442 SetupComplete = false beginSetup = coroutine.create(function() Nav.axisCommandManager:setupCustomTargetSpeedRanges(axisCommandId.longitudinal, @@ -6206,7 +6206,7 @@ function script.onTick(timerId) end end if orbit.apoapsis ~= nil then - if orbit.periapsis.altitude > OrbitTargetOrbit*0.95 and orbit.periapsis.altitude < OrbitTargetOrbit*1.25 and orbit.apoapsis.altitude > orbit.periapsis.altitude and + if orbit.periapsis.altitude > OrbitTargetOrbit*0.85 and orbit.periapsis.altitude < OrbitTargetOrbit*1.15 and orbit.apoapsis.altitude > orbit.periapsis.altitude and orbit.apoapsis.altitude <= orbit.periapsis.altitude*1.35 then -- conditions for a near perfect orbit BrakeIsOn = false PlayerThrottle = 0 @@ -6267,10 +6267,10 @@ function script.onTick(timerId) if velMag*0.5 > endSpeed then cmdThrottle(0) BrakeIsOn = not BrakeIsOn - elseif velMag+20 > endSpeed and vSpd > 35 then + elseif velMag > endSpeed+100 and vSpd > 35 then orbitThrottle(0.5,-80) BrakeIsOn = false - elseif velMag+20 > endSpeed and vSpd < -35 then + elseif velMag > endSpeed+100 and vSpd < -35 then orbitThrottle(0.5,80) BrakeIsOn = false -- elseif velMag*0.5 > endSpeed then @@ -6280,12 +6280,15 @@ function script.onTick(timerId) -- orbitThrottle(0.5,15) -- BrakeIsOn = false -- end - elseif velMag-20 < endSpeed then + elseif velMag < endSpeed-100 then orbitThrottle(0.75,15) BrakeIsOn = false -- elseif orbit.apoapsis.altitude > orbit.periapsis.altitude*1.3 then -- cmdThrottle(0) -- BrakeIsOn = not BrakeIsOn + elseif orbit.periapsis.altitude > OrbitTargetOrbit then + cmdThrottle(0) + BrakeIsOn = not BrakeIsOn else orbitThrottle(0.5,15) BrakeIsOn = false From 305d189586dba996038625150e9787113df6fc39 Mon Sep 17 00:00:00 2001 From: archaegeo Date: Wed, 17 Mar 2021 14:29:11 -0400 Subject: [PATCH 3/3] Adjust orbit tolerances --- ButtonHUD.conf | 2 +- ChangeLog.md | 4 ++-- src/ButtonHUD.lua | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ButtonHUD.conf b/ButtonHUD.conf index 747449b..7603965 100644 --- a/ButtonHUD.conf +++ b/ButtonHUD.conf @@ -123,7 +123,7 @@ handlers: throtPosX = 1300 --export: (Default: 1300) throtPosY = 540 --export: (Default: 540) vSpdMeterX = 1525 --export: (Default: 1525) - vSpdMeterY = 250 --export: (Default: 250) + vSpdMeterY = 325 --export: (Default: 325) altMeterX = 550 --export: (Default: 550) altMeterY = 540 --export: (Default: 540) fuelX = 100 --export: (Default: 100) diff --git a/ChangeLog.md b/ChangeLog.md index 8b9a2fd..fe37e52 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,9 +3,9 @@ Fixed script unloading when away from control unit. Note: We are now at our script limit even minimized. We are trying to clean up to give more room, but this might be the limit of everything in the hud meaning new features would remove old features or we might have to get creative on some things. -Version 5.441 +Version 5.442 - Orbiting - - Adjusted tolerances. Should orbit better. + - Adjusted tolerances. Should orbit better at tight orbits Version 5.44 - Orbiting (note: Trying to establish super low orbits (i.e. 7000m at Alioth) could result in achieving luminary status (burning up)) diff --git a/src/ButtonHUD.lua b/src/ButtonHUD.lua index a821274..9bcbde4 100644 --- a/src/ButtonHUD.lua +++ b/src/ButtonHUD.lua @@ -27,7 +27,7 @@ centerY = 540 -- export: (Default: 540) throtPosX = 1300 -- export: (Default: 1300) throtPosY = 540 -- export: (Default: 540) vSpdMeterX = 1525 -- export: (Default: 1525) -vSpdMeterY = 250 -- export: (Default: 250) +vSpdMeterY = 325 -- export: (Default: 325) altMeterX = 550 -- export: (Default: 550) altMeterY = 540 -- export: (Default: 540) fuelX = 100 -- export: (Default: 100)