From a2b47980a7db371f33b87b10cd3f2ce395473879 Mon Sep 17 00:00:00 2001 From: archaegeo Date: Sun, 14 Mar 2021 09:22:09 -0400 Subject: [PATCH 1/2] Remove all user variable comments --- ButtonHUD.conf | 176 +++++++++++++++++++++++----------------------- ChangeLog.md | 3 + README.md | 150 +++++++++++++++++++++++---------------- src/ButtonHUD.lua | 174 ++++++++++++++++++++++----------------------- 4 files changed, 267 insertions(+), 236 deletions(-) diff --git a/ButtonHUD.conf b/ButtonHUD.conf index 99ec855..4dd1c0e 100644 --- a/ButtonHUD.conf +++ b/ButtonHUD.conf @@ -1,4 +1,4 @@ -name: ButtonsHud - Dimencia and Archaegeo v5.42 (Minified) +name: ButtonsHud - Dimencia and Archaegeo v5.43 (Minified) slots: core: class: CoreUnit @@ -102,93 +102,93 @@ handlers: -- script code useTheseSettings = false --export: (Default: false) Toggle on to use the below preferences. Toggle off to use saved preferences. Preferences will save regardless when exiting seat. - freeLookToggle = true --export: (Default: true) Set to false for vanilla DU free look behavior. - BrakeToggleDefault = true --export: (Default: true) Whether your brake toggle is on/off by default. Can be adjusted in the button menu. Of is vanilla DU brakes. - RemoteFreeze = false --export: (Default: false) Whether or not to freeze you when using a remote controller. Breaks some things, only freeze on surfboards - RemoteHud = false --export: (Default: false) Whether you want full HUD while in remote mode, experimental, might not look right. - brightHud = false --export: (Default: false) Enable to prevent hud dimming when in freelook. - VanillaRockets = false --export: (Default: false) If on, rockets behave like vanilla - InvertMouse = false --export: (Default: false) If true, then when controlling flight mouse Y axis is inverted (pushing up noses plane down) Does not affect selecting buttons or camera. + freeLookToggle = true --export: (Default: true) + BrakeToggleDefault = true --export: (Default: true) + RemoteFreeze = false --export: (Default: false) + RemoteHud = false --export: (Default: false) + brightHud = false --export: (Default: false) + VanillaRockets = false --export: (Default: false) + InvertMouse = false --export: (Default: false) userControlScheme = "virtual joystick" --export: (Default: "virtual joystick") Set to "virtual joystick", "mouse", or "keyboard" - ResolutionX = 1920 --export: (Default: 1920) Does not need to be set to same as game resolution. You can set 1920 on a 2560 to get larger resolution - ResolutionY = 1080 --export: (Default: 1080) Does not need to be set to same as game resolution. You can set 1080 on a 1440 to get larger resolution - SafeR = 130 --export: (Default: 130) Primary HUD color - SafeG = 224 --export: (Default: 224) Primary HUD color - SafeB = 255 --export: (Default: 255) Primary HUD color - PvPR = 255 --export: (Default: 255) PvP HUD color - PvPG = 0 --export: (Default: 0) PvP HUD color - PvPB = 0 --export: (Default: 0) PvP HUD color - centerX = 960 --export: (Default: 960) X postion of Artifical Horizon (KSP Navball), Default 960. Use centerX=700 and centerY=880 for lower left placement. - centerY = 540 --export: (Default: 540) Y postion of Artifical Horizon (KSP Navball), Default 540. Use centerX=700 and centerY=880 for lower left placement. - throtPosX = 1300 --export: (Default: 1300) X position of Throttle Indicator, default 1300 to put it to right of default AH centerX parameter. - throtPosY = 540 --export: (Default: 540) Y position of Throttle indicator, default is 540 to place it centered on default AH centerY parameter. - vSpdMeterX = 1525 --export: (Default: 1525) X postion of Vertical Speed Meter. Default 1525 (use 1920x1080, it will scale) - vSpdMeterY = 250 --export: (Default: 250) Y postion of Vertical Speed Meter. Default 250 (use 1920x1080, it will scale) - altMeterX = 550 --export: (Default: 550) X postion of Altimeter. Default 550 (use 1920x1080, it will scale) - altMeterY = 540 --export: (Default: 540) Y postion of Altimeter. Default 500 (use 1920x1080, it will scale) - fuelX = 100 --export: (Default: 100) X position of fuel tanks, default is 100 for left side, set both fuelX and fuelY to 0 to hide fuel - fuelY = 350 --export: (Default: 350) Y position of fuel tanks, default 350 for left side, set both fuelX and fuelY to 0 to hide fuel - circleRad = 400 --export: (Default: 400) The size of the artifical horizon circle, recommended minimum 100, maximum 400. Looks different > 200. Set to 0 to remove. - DeadZone = 50 --export: (Default: 50) Number of pixels of deadzone at the center of the screen - DisplayOrbit = true --export: (Default: true) Show Orbit display when valid or not. May be toggled with shift Buttons - OrbitMapSize = 250 --export: (Default: 250) Size of the orbit map, make sure it is divisible by 4 - OrbitMapX = 75 --export: (Default: 75) X postion of Orbit Display Disabled - OrbitMapY = 0 --export: (Default: 0) Y position of Orbit Display - showHud = true --export: (Default: true) Uncheck to hide the HUD and only use autopilot features via ALT+# keys. - ShowOdometer = true --export: (Default: true) Uncheck to hide the odometer panel up top. - hideHudOnToggleWidgets = true --export: (Default: true) Uncheck to keep showing HUD when you toggle on the widgets via ALT+3. - ShiftShowsRemoteButtons = true --export: (Default: true) Whether or not pressing Shift in remote controller mode shows you the buttons (otherwise no access to them) - YawStallAngle = 35 --export: (Default: 35) Angle at which the ship stalls when yawing (Stabilizers: 70, Wings: 55, Ailerons: 30) - PitchStallAngle = 35 --export: (Default: 35) Angle at which the ship stalls when pitching (Stabilizers: 70, Wings: 55, Ailerons: 30) - speedChangeLarge = 5 --export: (Default: 5) The speed change that occurs when you tap speed up/down, default is 5 (25% throttle change). - speedChangeSmall = 1 --export: (Default: 1) the speed change that occurs while you hold speed up/down, default is 1 (5% throttle change). - brakeLandingRate = 30 --export: (Default: 30) Max loss of altitude speed in m/s when doing a brake landing, default 30. This is to prevent "bouncing" as hover/boosters catch you. Do not use negative number. - MaxPitch = 30 --export: (Default: 30) Maximum allowed pitch during takeoff and altitude changes while in altitude hold. You can set higher or lower depending on your ships capabilities. - ReentrySpeed = 1050 --export: (Default: 1050) Target re-entry speed once in atmosphere in km/h. - AtmoSpeedLimit = 1050 --export: (Default: 1050) Speed limit in Atmosphere in km/h. If you exceed this limit the ship will attempt to break till below this limit. - SpaceSpeedLimit = 30000 --export: (Default: 30000) Space speed limit in KM/H. If you hit this speed but are not in active autopilot, engines will turn off. - ReentryAltitude = 2500 --export: (Default: 2500) Target alititude when using re-entry. - AutoTakeoffAltitude = 1000 --export: (Default: 1000) How high above your ground starting position AutoTakeoff tries to put you - TargetHoverHeight = 50 --export: (Default: 50) Hover height when retracting landing gear - LandingGearGroundHeight = 0 --export: (Default: 0) Set to AGL-1 when on ground (or 0) - MaxGameVelocity = 8333.00 --export: (Default: 8333.00) Max speed for your autopilot in m/s, do not go above 8333.055 (30000 km/hr), can be reduced to safe fuel, use 6944.4444 for 25000km/hr - TargetOrbitRadius = 1.4 --export: (Default: 1.4) How tight you want to orbit the planet at end of autopilot. The smaller the value the tighter the orbit. 1.4 sets an Alioth orbit of 56699m. - AutopilotInterplanetaryThrottle = 1.0 --export: (Default: 1.0) How much throttle, 0.0 to 1.0, you want it to use when in autopilot to another planet to reach MaxGameVelocity - warmup = 32 --export: (Default: 32) How long it takes your engines to warmup. Basic Space Engines, from XS to XL: 0.25,1,4,16,32 - MouseYSensitivity = 0.003 --export: (Default: 0.003) For virtual joystick only - MouseXSensitivity = 0.003 --export: (Default: 0.003) For virtual joystick only - autoRollPreference = false --export: (Default: false) [Only in atmosphere]
When the pilot stops rolling, flight model will try to get back to horizontal (no roll) - autoRollFactor = 2 --export: (Default: 2) [Only in atmosphere]
When autoRoll is engaged, this factor will increase to strength of the roll back to 0
Valid values: Superior or equal to 0.01 - rollSpeedFactor = 1.5 --export: (Default: 1.5) This factor will increase/decrease the player input along the roll axis
(higher value may be unstable)
Valid values: Superior or equal to 0.01 - turnAssist = true --export: (Default: true) [Only in atmosphere]
When the pilot is rolling, the flight model will try to add yaw and pitch to make the construct turn better
The flight model will start by adding more yaw the more horizontal the construct is and more pitch the more vertical it is - turnAssistFactor = 2 --export: (Default: 2) [Only in atmosphere]
This factor will increase/decrease the turnAssist effect
(higher value may be unstable)
Valid values: Superior or equal to 0.01 - TrajectoryAlignmentStrength = 0.002 --export: (Default: 0.002) How strongly AP tries to align your velocity vector to the target when not in orbit, recommend 0.002 - torqueFactor = 2 --export: (Default: 2) Force factor applied to reach rotationSpeed
(higher value may be unstable)
Valid values: Superior or equal to 0.01 - pitchSpeedFactor = 0.8 --export: (Default: 0.8) For keyboard control - yawSpeedFactor = 1 --export: (Default: 1) For keyboard control - brakeSpeedFactor = 3 --export: (Default: 3) When braking, this factor will increase the brake force by brakeSpeedFactor * velocity
Valid values: Superior or equal to 0.01 - brakeFlatFactor = 1 --export: (Default: 1) When braking, this factor will increase the brake force by a flat brakeFlatFactor * velocity direction>
(higher value may be unstable)
Valid values: Superior or equal to 0.01 - DampingMultiplier = 40 --export: (Default: 40) How strongly autopilot dampens when nearing the correct orientation - fuelTankHandlingAtmo = 0 --export: (Default: 0) For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. - fuelTankHandlingSpace = 0 --export: (Default: 0) For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. - fuelTankHandlingRocket = 0 --export: (Default: 0) For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. - ContainerOptimization = 0 --export: (Default: 0) For accurate estimates, set this to the Container Optimization level of the person who placed the tanks. Ignored for slotted tanks. - FuelTankOptimization = 0 --export: (Default: 0) For accurate unslotted fuel tank calculation, set this to the fuel tank optimization skill level of the person who placed the tank. Ignored for slotted tanks. - ExtraLongitudeTags = "none" --export: (Default: "none") Enter any extra longitudinal tags you use inside '' seperated by space, i.e. "forward faster major" These will be added to the engines that are control by longitude. - ExtraLateralTags = "none" --export: (Default: "none") Enter any extra lateral tags you use inside '' seperated by space, i.e. "left right" These will be added to the engines that are control by lateral. - ExtraVerticalTags = "none" --export: (Default: "none") Enter any extra longitudinal tags you use inside '' seperated by space, i.e. "up down" These will be added to the engines that are control by vertical. - ExternalAGG = false --export: (Default: false) Toggle On if using an external AGG system. If on will prevent this HUD from doing anything with AGG. - UseSatNav = false --export: (Default: false) Toggle on if using Trog SatNav script. This will provide SatNav support. - apTickRate = 0.0166667 --export: (Default: 0.0166667) Set the Tick Rate for your autopilot features. 0.016667 is effectively 60 fps and the default value. 0.03333333 is 30 fps. - hudTickRate = 0.0666667 --export: (Default: 0.0666667) Set the tick rate for your HUD. Default is 4 times slower than apTickRate - ShouldCheckDamage = true --export: (Default: true) Whether or not damage checks are performed. Disabled for performance on very large ships - CalculateBrakeLandingSpeed = false --export: (Default: false) Whether BrakeLanding speed at non-waypoints should be calculated or use the brakeLandingRate user setting. Only set to true for ships with low mass to lift capability. - autoRollRollThreshold = 0 --export: (Default: 0) The minimum amount of roll before autoRoll kicks in and stabilizes (if active) - AtmoSpeedAssist = true --export: (Default: true) Whether or not atmospheric speeds should be limited to a maximum of AtmoSpeedLimit - ForceAlignment = false --export: (Default: false) Whether velocity vector alignment should be forced when in Altitude Hold - minRollVelocity = 150 --export: (Default: 150) Min velocity, in m/s, over which advanced rolling can occur - VertTakeOffEngine = false --export: (Default: false) Set this to true if you have VTOL engines on your construct. Changes Auto Takeoff to Vertical Takeoff. - VertTakeOffMode = "Orbit" --export: (Default: "Orbit") Set to: "AGG" = turn on AGG when above 1km and near AGG activation height, "Orbit" = go directly to orbit based off of TargetOrbitRadius. Must keep quotes. Any case is fine. + ResolutionX = 1920 --export: (Default: 1920) + ResolutionY = 1080 --export: (Default: 1080) + SafeR = 130 --export: (Default: 130) + SafeG = 224 --export: (Default: 224) + SafeB = 255 --export: (Default: 255) + PvPR = 255 --export: (Default: 255) + PvPG = 0 --export: (Default: 0) + PvPB = 0 --export: (Default: 0) + centerX = 960 --export: (Default: 960) + 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) + altMeterX = 550 --export: (Default: 550) + altMeterY = 540 --export: (Default: 540) + fuelX = 100 --export: (Default: 100) + fuelY = 350 --export: (Default: 350) + circleRad = 400 --export: (Default: 400) + DeadZone = 50 --export: (Default: 50) + DisplayOrbit = true --export: (Default: true) + OrbitMapSize = 250 --export: (Default: 250) + OrbitMapX = 75 --export: (Default: 75) + OrbitMapY = 0 --export: (Default: 0) + showHud = true --export: (Default: true) + ShowOdometer = true --export: (Default: true) + hideHudOnToggleWidgets = true --export: (Default: true) + ShiftShowsRemoteButtons = true --export: (Default: true) + YawStallAngle = 35 --export: (Default: 35) + PitchStallAngle = 35 --export: (Default: 35) + speedChangeLarge = 5 --export: (Default: 5) + speedChangeSmall = 1 --export: (Default: 1) + brakeLandingRate = 30 --export: (Default: 30) + MaxPitch = 30 --export: (Default: 30) + ReentrySpeed = 1050 --export: (Default: 1050) + AtmoSpeedLimit = 1050 --export: (Default: 1050) + SpaceSpeedLimit = 30000 --export: (Default: 30000). + ReentryAltitude = 2500 --export: (Default: 2500) + AutoTakeoffAltitude = 1000 --export: (Default: 1000) + TargetHoverHeight = 50 --export: (Default: 50) + LandingGearGroundHeight = 0 --export: (Default: 0) + MaxGameVelocity = 8333.00 --export: (Default: 8333.00) + TargetOrbitRadius = 1.4 --export: (Default: 1.4) + AutopilotInterplanetaryThrottle = 1.0 --export: (Default: 1.0) + warmup = 32 --export: (Default: 32) + MouseYSensitivity = 0.003 --export: (Default: 0.003) + MouseXSensitivity = 0.003 --export: (Default: 0.003) + autoRollPreference = false --export: (Default: false) + autoRollFactor = 2 --export: (Default: 2) + rollSpeedFactor = 1.5 --export: (Default: 1.5) + turnAssist = true --export: (Default: true) + turnAssistFactor = 2 --export: (Default: 2) + TrajectoryAlignmentStrength = 0.002 --export: (Default: 0.002) + torqueFactor = 2 --export: (Default: 2) + pitchSpeedFactor = 0.8 --export: (Default: 0.8) + yawSpeedFactor = 1 --export: (Default: 1) + brakeSpeedFactor = 3 --export: (Default: 3) + brakeFlatFactor = 1 --export: (Default: 1) + DampingMultiplier = 40 --export: (Default: 40) + fuelTankHandlingAtmo = 0 --export: (Default: 0) + fuelTankHandlingSpace = 0 --export: (Default: 0) + fuelTankHandlingRocket = 0 --export: (Default: 0) + ContainerOptimization = 0 --export: (Default: 0) + FuelTankOptimization = 0 --export: (Default: 0) + ExtraLongitudeTags = "none" --export: (Default: "none") + ExtraLateralTags = "none" --export: (Default: "none") + ExtraVerticalTags = "none" --export: (Default: "none") + ExternalAGG = false --export: (Default: false) + UseSatNav = false --export: (Default: false) + apTickRate = 0.0166667 --export: (Default: 0.0166667) + hudTickRate = 0.0666667 --export: (Default: 0.0666667) + ShouldCheckDamage = true --export: (Default: true) + CalculateBrakeLandingSpeed = false --export: (Default: false) + autoRollRollThreshold = 0 --export: (Default: 0) + AtmoSpeedAssist = true --export: (Default: true) + ForceAlignment = false --export: (Default: false) + minRollVelocity = 150 --export: (Default: 150) + VertTakeOffEngine = false --export: (Default: false) + VertTakeOffMode = "Orbit" --export: (Default: "Orbit") Nav=Navigator.new(system,core,unit)script={}BrakeToggleStatus=BrakeToggleDefault;BrakeIsOn=false;RetrogradeIsOn=false;ProgradeIsOn=false;Autopilot=false;TurnBurn=false;AltitudeHold=false;BrakeLanding=false;AutoTakeoff=false;Reentry=false;VertTakeOff=false;HoldAltitude=1000;AutopilotAccelerating=false;AutopilotRealigned=false;AutopilotBraking=false;AutopilotCruising=false;AutopilotEndSpeed=0;AutopilotStatus="Aligning"AutopilotPlanetGravity=0;PrevViewLock=1;AutopilotTargetName="None"AutopilotTargetCoords=nil;AutopilotTargetIndex=0;GearExtended=nil;TotalDistanceTravelled=0.0;TotalFlightTime=0;SavedLocations={}VectorToTarget=false;LocationIndex=0;LastMaxBrake=0;LockPitch=nil;LastMaxBrakeInAtmo=0;AntigravTargetAltitude=core.getAltitude()LastStartTime=0;SpaceTarget=false;LeftAmount=0;IntoOrbit=false;local a={"userControlScheme","TargetOrbitRadius","apTickRate","freeLookToggle","turnAssist","SafeR","SafeG","SafeB","warmup","DeadZone","circleRad","MouseXSensitivity","MouseYSensitivity","MaxGameVelocity","showHud","autoRollPreference","InvertMouse","pitchSpeedFactor","yawSpeedFactor","rollSpeedFactor","brakeSpeedFactor","brakeFlatFactor","autoRollFactor","turnAssistFactor","torqueFactor","AutoTakeoffAltitude","TargetHoverHeight","AutopilotInterplanetaryThrottle","hideHudOnToggleWidgets","DampingMultiplier","fuelTankHandlingAtmo","ExternalAGG","ShouldCheckDamage","fuelTankHandlingSpace","fuelTankHandlingRocket","RemoteFreeze","hudTickRate","speedChangeLarge","speedChangeSmall","brightHud","brakeLandingRate","MaxPitch","ReentrySpeed","AtmoSpeedLimit","ReentryAltitude","centerX","centerY","SpaceSpeedLimit","AtmoSpeedAssist","vSpdMeterX","vSpdMeterY","altMeterX","altMeterY","fuelX","fuelY","LandingGearGroundHeight","TrajectoryAlignmentStrength","RemoteHud","YawStallAngle","PitchStallAngle","ResolutionX","ResolutionY","UseSatNav","FuelTankOptimization","ContainerOptimization","ExtraLongitudeTags","ExtraLateralTags","ExtraVerticalTags","OrbitMapSize","OrbitMapX","OrbitMapY","DisplayOrbit","CalculateBrakeLandingSpeed","ForceAlignment","autoRollRollThreshold","minRollVelocity","VertTakeOffEngine","VertTakeOffMode","PvPR","PvPG","PvPB"}local b={"SpaceTarget","BrakeToggleStatus","BrakeIsOn","RetrogradeIsOn","ProgradeIsOn","Autopilot","TurnBurn","AltitudeHold","BrakeLanding","Reentry","AutoTakeoff","HoldAltitude","AutopilotAccelerating","AutopilotBraking","AutopilotCruising","AutopilotRealigned","AutopilotEndSpeed","AutopilotStatus","AutopilotPlanetGravity","PrevViewLock","AutopilotTargetName","AutopilotTargetCoords","AutopilotTargetIndex","TotalDistanceTravelled","TotalFlightTime","SavedLocations","VectorToTarget","LocationIndex","LastMaxBrake","LockPitch","LastMaxBrakeInAtmo","AntigravTargetAltitude","LastStartTime"}local c=system.print;local d=math.floor;local e=string.format;local f=json.decode;local g=json.encode;local h=core.getElementMaxHitPointsById;local j=unit.getAtmosphereDensity;local k=core.getElementHitPointsById;local l=core.getElementTypeById;local m=core.getElementMassById;local n=core.getConstructMass;local o=Nav.control.isRemoteControlled;local p=math.atan;function round(q,r)local s=10^(r or 0)return d(q*s+0.5)/s end;local t=SafeR;local u=SafeB;local v=SafeG;local w=false;local x=0;local y=""local z=0;local A=0;local B=false;local C=0;local D=false;local E=round(ResolutionX/2,0)local F=round(ResolutionY/2,0)local G=false;local H=true;local I=55;local J=false;local K=1;local L=1;local M=false;local N=0;local O=0;local P=0;local Q=0;local R=0;local S=0;local T=0;local U=false;local V=false;local W="empty"local X=5;local Y=5;local Z=false;local a0,a1=0;local a2,a3=0;local a4=nil;local a5=0;local a6=0;local a7=false;local a8=0;local a9=0;local aa=0;local ab=3;local ac=0;local ad=""local ae=""local af=0;local ag=false;local ah=false;local ai=false;local aj=-1;local ak=false;local al=""local am=j()>0;local an=core.getAltitude()local ao=core.getElementIdList()local ap=system.getTime()local aq=nil;local ar=false;local as=[[rgb(]]..d(t+0.5)..","..d(v+0.5)..","..d(u+0.5)..[[)]]local at=[[rgb(]]..d(t*0.9+0.5)..","..d(v*0.9+0.5)..","..d(u*0.9+0.5)..[[)]]local au={}local av=0;local aw=0;local ax=""local ay=true;local az={}local aA=1;local aB=0.001;local aC=ResolutionX;local aD=ResolutionY;local aE=nil;local aF=nil;local aG=nil;local aH=nil;local aI=false;local aJ=false;local aK=0;local aL=nil;local aM={}local aN={}local aO={}local aP=0;local aQ=false;local aR={}local aS={}local aT=d(1/apTickRate)*2;local aU={}local aV={}local aW={}local aX={}local aY=false;local aZ=16;local a_=0;local b0=nil;local b1=""local b2=nil;local b3=nil;local b4=nil;local b5=nil;local b6=nil;local b7=nil;local b8=nil;local b9=nil;local ba=false;local bb=false;local bc=autoRollPreference;local bd=vec3(core.getWorldVelocity())local be=vec3(bd):len()local bf=LandingGearGroundHeight;local bg=system.getMouseDeltaX()local bh=system.getMouseDeltaY()local bi=false;local bj=system.getTime()local bk=0;local bl=0;local bm=AtmoSpeedLimit;local bn=0;local bo=nil;local bp=0;local bq=0;local br=false;local bs=false;local bt=false;local bu=false;local bv=0;local bw=nil;local bx=false;local by=false;local bz=false;function LoadVariables()if dbHud_1 then local bA=dbHud_1.hasKey;if not useTheseSettings then for bB,bC in pairs(a)do if bA(bC)then local bD=f(dbHud_1.getStringValue(bC))if bD~=nil then c(bC.." "..dbHud_1.getStringValue(bC))_G[bC]=bD;aI=true end end end end;coroutine.yield()for bB,bC in pairs(b)do if bA(bC)then local bD=f(dbHud_1.getStringValue(bC))if bD~=nil then c(bC.." "..dbHud_1.getStringValue(bC))_G[bC]=bD;aI=true end end end;if useTheseSettings then W="Updated user preferences used. Will be saved when you exit seat.\nToggle off useTheseSettings to use saved values"ab=5 elseif aI then W="Loaded Saved Variables (see Lua Chat Tab for list)"else W="No Saved Variables Found - Stand up / leave remote to save settings"end else W="No databank found, install one anywhere and rerun the autoconfigure to save variables"end;local bE=system.getTime()if LastStartTime+180bG then bG=bF end;if ContainerOptimization>0 then bG=bG-bG*ContainerOptimization*0.05 end;if FuelTankOptimization>0 then bG=bG-bG*FuelTankOptimization*0.05 end;return bG end;function ProcessElements()local bH=fuelX~=0 and fuelY~=0;for bB in pairs(ao)do local type=l(ao[bB])if string.match(type,'^.*Space Engine$')then if string.match(tostring(core.getElementTagsById(ao[bB])),'^.*vertical.*$')then local bI=core.getElementRotationById(ao[bB])if bI[4]<0 then if utils.round(-bI[4],0.1)==0.5 then by=true;system.print("Space Engine Up detected")end else if utils.round(bI[4],0.1)==0.5 then bz=true;system.print("Space Engine Down detected")end end end end;if type=="Landing Gear"then M=true end;if type=="Dynamic Core Unit"then local bJ=h(ao[bB])if bJ>10000 then aZ=128 elseif bJ>1000 then aZ=64 elseif bJ>150 then aZ=32 end end;aP=aP+h(ao[bB])if bH and(type=="Atmospheric Fuel Tank"or type=="Space Fuel Tank"or type=="Rocket Fuel Tank")then local bJ=h(ao[bB])local bK=m(ao[bB])local bF=0;local bL=system.getTime()if type=="Atmospheric Fuel Tank"then local bG=400;local bM=35.03;if bJ>10000 then bG=51200;bM=5480 elseif bJ>1300 then bG=6400;bM=988.67 elseif bJ>150 then bG=1600;bM=182.67 end;bF=bK-bM;if fuelTankHandlingAtmo>0 then bG=bG+bG*fuelTankHandlingAtmo*0.2 end;bG=CalculateFuelVolume(bF,bG)aM[#aM+1]={ao[bB],core.getElementNameById(ao[bB]),bG,bM,bF,bL}end;if type=="Rocket Fuel Tank"then local bG=320;local bM=173.42;if bJ>65000 then bG=40000;bM=25740 elseif bJ>6000 then bG=5120;bM=4720 elseif bJ>700 then bG=640;bM=886.72 end;bF=bK-bM;if fuelTankHandlingRocket>0 then bG=bG+bG*fuelTankHandlingRocket*0.1 end;bG=CalculateFuelVolume(bF,bG)aO[#aO+1]={ao[bB],core.getElementNameById(ao[bB]),bG,bM,bF,bL}end;if type=="Space Fuel Tank"then local bG=2400;local bM=182.67;if bJ>10000 then bG=76800;bM=5480 elseif bJ>1300 then bG=9600;bM=988.67 end;bF=bK-bM;if fuelTankHandlingSpace>0 then bG=bG+bG*fuelTankHandlingSpace*0.2 end;bG=CalculateFuelVolume(bF,bG)aN[#aN+1]={ao[bB],core.getElementNameById(ao[bB]),bG,bM,bF,bL}end end end end;function SetupChecks()if gyro~=nil then aq=gyro.getState()==1 end;if userControlScheme~="keyboard"then system.lockView(1)else system.lockView(0)end;if radar_1 then if l(radar_1.getId())=="Space Radar"then hasSpaceRadar=true else hasAtmoRadar=true end end;local bN=j()if door and(bN>0 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;if antigrav~=nil and not ExternalAGG then if antigrav.getState()==1 then antigrav.show()end end;if o()==1 and RemoteFreeze then system.freeze(1)else system.freeze(0)end;if M then GearExtended=Nav.control.isAnyLandingGearExtended()==1;if GearExtended then Nav.control.extendLandingGears()else Nav.control.retractLandingGears()end end;local bO=AboveGroundLevel()if bO~=-1 or not am and vec3(core.getVelocity()):len()<50 then BrakeIsOn=true;if not M then GearExtended=true end else BrakeIsOn=false end;if bf~=nil then Nav.axisCommandManager:setTargetGroundAltitude(bf)if bf==0 and not M then GearExtended=true;BrakeIsOn=true end else bf=Nav:getTargetGroundAltitude()if GearExtended then Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)else Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)end end;if am and bO~=-1 then b8=core.getMaxKinematicsParametersAlongAxis("ground",core.getConstructOrientationUp())[1]end;userControlScheme=string.lower(userControlScheme)WasInAtmo=am end;function ConvertResolutionX(bC)if ResolutionX==1920 then return bC else return round(ResolutionX*bC/1920,0)end end;function ConvertResolutionY(bC)if ResolutionY==1080 then return bC else return round(ResolutionY*bC/1080,0)end end;function RefreshLastMaxBrake(bP,bQ)if bP==nil then bP=core.g()end;bP=round(bP,5)local bR=j()if bQ~=nil and bQ or(aL==nil or aL~=bP)then local bd=core.getVelocity()local bS=vec3(bd):len()local bT=f(unit.getData()).maxBrake;if bT~=nil and bT>0 and am then bT=bT/utils.clamp(bS/100,0.1,1)bT=bT/bR;if bR>0.10 then if LastMaxBrakeInAtmo then LastMaxBrakeInAtmo=(LastMaxBrakeInAtmo+bT)/2 else LastMaxBrakeInAtmo=bT end end end;if bT~=nil and bT>0 then LastMaxBrake=bT end;aL=bP end end;function MakeButton(bU,bV,bW,bX,bY,bZ,b_,c0,c1)local c2={enableName=bU,disableName=bV,width=bW,height=bX,x=bY,y=bZ,toggleVar=b_,toggleFunction=c0,drawCondition=c1,hovered=false}table.insert(az,c2)return c2 end;function UpdateAtlasLocationsList()AtlasOrdered={}for bB,bC in pairs(b0[0])do table.insert(AtlasOrdered,{name=bC.name,index=bB})end;local function c3(c4,c5)return c4.name=0 and cf or 2*math.pi+cf;cd=math.pi/2-math.acos(cb.z/ac)end;return setmetatable({latitude=math.deg(cd),longitude=math.deg(ce),altitude=cc,bodyId=c8.bodyId,systemId=c8.planetarySystemId},MapPosition)end;function zeroConvertToWorldCoordinates(cg)local q=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local ch='::pos{'..q..','..q..','..q..','..q..','..q..'}'local ci,cj,cd,ce,cc=string.match(cg,ch)if ci=="0"and cj=="0"then return vec3(tonumber(cd),tonumber(ce),tonumber(cc))end;ce=math.rad(ce)cd=math.rad(cd)local planet=b0[tonumber(ci)][tonumber(cj)]local ck=math.cos(cd)local cl=vec3(ck*math.cos(ce),ck*math.sin(ce),math.sin(cd))return planet.center+(planet.radius+cc)*cl end;function AddNewLocationByWaypoint(cm,planet,cg)if dbHud_1 then local cn={}local position=zeroConvertToWorldCoordinates(cg)if planet.name=="Space"then cn={position=position,name=cm,atmosphere=false,planetname=planet.name,gravity=planet.gravity}else local bN=false;if planet.hasAtmosphere then bN=true else bN=false end;cn={position=position,name=cm,atmosphere=bN,planetname=planet.name,gravity=planet.gravity}end;SavedLocations[#SavedLocations+1]=cn;table.insert(b0[0],cn)UpdateAtlasLocationsList()else W="Databank must be installed to save locations"end end;function AddNewLocation()if dbHud_1 then local position=vec3(core.getConstructWorldPos())local co=planet.name..". "..#SavedLocations;if radar_1 then local cp,_=radar_1.getData():match('"constructId":"([0-9]*)","distance":([%d%.]*)')if cp~=nil and cp~=""then co=co.." "..radar_1.getConstructName(cp)end end;local cn={}local bN=false;if planet.hasAtmosphere then bN=true end;cn={position=position,name=co,atmosphere=bN,planetname=planet.name,gravity=planet.gravity,safe=true}SavedLocations[#SavedLocations+1]=cn;table.insert(b0[0],cn)UpdateAtlasLocationsList()W="Location saved as "..co else W="Databank must be installed to save locations"end end;function UpdatePosition(cq)local cr=-1;local cn;for bB,bC in pairs(SavedLocations)do if bC.name and bC.name==CustomTarget.name then cr=bB;break end end;if cr~=-1 then local cs;if cq~=nil then cn={position=SavedLocations[cr].position,name=cq,atmosphere=SavedLocations[cr].atmosphere,planetname=SavedLocations[cr].planetname,gravity=SavedLocations[cr].gravity}else cn={position=vec3(core.getConstructWorldPos()),name=SavedLocations[cr].name,atmosphere=j(),planetname=planet.name,gravity=unit.getClosestPlanetInfluence(),safe=true}end;SavedLocations[cr]=cn;cr=-1;for bB,bC in pairs(b0[0])do if bC.name and bC.name==CustomTarget.name then cr=bB end end;if cr>-1 then b0[0][cr]=cn end;UpdateAtlasLocationsList()W=CustomTarget.name.." position updated"AutopilotTargetIndex=0;UpdateAutopilotTarget()else W="Name Not Found"end end;function ClearCurrentPosition()local cr=-1;for bB,bC in pairs(b0[0])do if bC.name and bC.name==CustomTarget.name then cr=bB end end;if cr>-1 then table.remove(b0[0],cr)end;cr=-1;for bB,bC in pairs(SavedLocations)do if bC.name and bC.name==CustomTarget.name then W=bC.name.." saved location cleared"cr=bB;break end end;if cr~=-1 then table.remove(SavedLocations,cr)end;DecrementAutopilotTargetIndex()UpdateAtlasLocationsList()end;function DrawDeadZone(ct)ct[#ct+1]=e([[]],DeadZone)end;function ToggleRadarPanel()if radarPanelID~=nil and af==0 then system.destroyWidgetPanel(radarPanelID)radarPanelID=nil;if perisPanelID~=nil then system.destroyWidgetPanel(perisPanelID)perisPanelID=nil end else if af==1 then system.destroyWidgetPanel(radarPanelID)radarPanelID=nil;_autoconf.displayCategoryPanel(radar,radar_size,L_TEXT("ui_lua_widget_periscope", "Periscope"),"periscope")perisPanelID=_autoconf.panels[_autoconf.panels_size]end;placeRadar=true;if radarPanelID==nil and placeRadar then _autoconf.displayCategoryPanel(radar,radar_size,L_TEXT("ui_lua_widget_radar", "Radar"),"radar")radarPanelID=_autoconf.panels[_autoconf.panels_size]placeRadar=false end;af=0 end end;function ToggleWidgets()if ay then unit.show()core.show()if atmofueltank_size>0 then _autoconf.displayCategoryPanel(atmofueltank,atmofueltank_size,L_TEXT("ui_lua_widget_atmofuel", "Atmo Fuel"),"fuel_container")fuelPanelID=_autoconf.panels[_autoconf.panels_size]end;if spacefueltank_size>0 then _autoconf.displayCategoryPanel(spacefueltank,spacefueltank_size,L_TEXT("ui_lua_widget_spacefuel", "Space Fuel"),"fuel_container")spacefuelPanelID=_autoconf.panels[_autoconf.panels_size]end;if rocketfueltank_size>0 then _autoconf.displayCategoryPanel(rocketfueltank,rocketfueltank_size,L_TEXT("ui_lua_widget_rocketfuel", "Rocket Fuel"),"fuel_container")rocketfuelPanelID=_autoconf.panels[_autoconf.panels_size]end;ay=false else unit.hide()core.hide()if fuelPanelID~=nil then system.destroyWidgetPanel(fuelPanelID)fuelPanelID=nil end;if spacefuelPanelID~=nil then system.destroyWidgetPanel(spacefuelPanelID)spacefuelPanelID=nil end;if rocketfuelPanelID~=nil then system.destroyWidgetPanel(rocketfuelPanelID)rocketfuelPanelID=nil end;ay=true end end;function SetupInterplanetaryPanel()panelInterplanetary=system.createWidgetPanel("Interplanetary Helper")interplanetaryHeader=system.createWidget(panelInterplanetary,"value")interplanetaryHeaderText=system.createData('{"label": "Target Planet", "value": "N/A", "unit":""}')system.addDataToWidget(interplanetaryHeaderText,interplanetaryHeader)widgetDistance=system.createWidget(panelInterplanetary,"value")widgetDistanceText=system.createData('{"label": "distance", "value": "N/A", "unit":""}')system.addDataToWidget(widgetDistanceText,widgetDistance)widgetTravelTime=system.createWidget(panelInterplanetary,"value")widgetTravelTimeText=system.createData('{"label": "Travel Time", "value": "N/A", "unit":""}')system.addDataToWidget(widgetTravelTimeText,widgetTravelTime)widgetMaxMass=system.createWidget(panelInterplanetary,"value")widgetMaxMassText=system.createData('{"label": "Maximum Mass", "value": "N/A", "unit":""}')system.addDataToWidget(widgetMaxMassText,widgetMaxMass)widgetCurBrakeDistance=system.createWidget(panelInterplanetary,"value")widgetCurBrakeDistanceText=system.createData('{"label": "Cur Brake distance", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;widgetCurBrakeTime=system.createWidget(panelInterplanetary,"value")widgetCurBrakeTimeText=system.createData('{"label": "Cur Brake Time", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;widgetMaxBrakeDistance=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeDistanceText=system.createData('{"label": "Max Brake distance", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;widgetMaxBrakeTime=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeTimeText=system.createData('{"label": "Max Brake Time", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;widgetTrajectoryAltitude=system.createWidget(panelInterplanetary,"value")widgetTrajectoryAltitudeText=system.createData('{"label": "Projected Altitude", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end;widgetTargetOrbit=system.createWidget(panelInterplanetary,"value")widgetTargetOrbitText=system.createData('{"label": "Target Altitude", "value": "N/A", "unit":""}')system.addDataToWidget(widgetTargetOrbitText,widgetTargetOrbit)end;function Contains(cu,cv,bY,bZ,bW,bX)if cu>bY and cubZ and cv0 then IntoOrbit=true;bx=false;CancelIntoOrbit=false;br=false;bp=nil;bq=nil;if bw==nil then bw=planet end else W="Unable to engage orbiting, not near planet"end end end;function ToggleLockPitch()if LockPitch==nil then local cw=vec3(core.getConstructWorldOrientationForward())local cx=vec3(core.getConstructWorldOrientationRight())local cy=vec3(core.getWorldVertical())local cz=getPitch(cy,cw,cx)LockPitch=cz;AutoTakeoff=false;AltitudeHold=false;BrakeLanding=false else LockPitch=nil end end;function ToggleAltitudeHold()local bE=system.getTime()if bE-bl<1.5 then if planet.hasAtmosphere then HoldAltitude=planet.spaceEngineMinAltitude-50;bl=-1;if AltitudeHold then return end end else bl=bE end;AltitudeHold=not AltitudeHold;if AltitudeHold then Autopilot=false;ProgradeIsOn=false;RetrogradeIsOn=false;U=false;BrakeLanding=false;Reentry=false;bc=true;LockPitch=nil;if hoverDetectGround()==-1 or not am then AutoTakeoff=false;if bl>-1 then HoldAltitude=an end;if not ah and Nav.axisCommandManager:getAxisCommandType(0)==0 and not AtmoSpeedAssist then Nav.control.cancelCurrentControlMasterMode()end else AutoTakeoff=true;if bl>-1 then HoldAltitude=an+AutoTakeoffAltitude end;GearExtended=false;Nav.control.retractLandingGears()BrakeIsOn=true;Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)end;if ah then HoldAltitude=100000 end else bc=autoRollPreference;AutoTakeoff=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;VectorToTarget=false end end;function ToggleFollowMode()if o()==1 then U=not U;if U then Autopilot=false;RetrogradeIsOn=false;ProgradeIsOn=false;AltitudeHold=false;Reentry=false;BrakeLanding=false;AutoTakeoff=false;OldGearExtended=GearExtended;GearExtended=false;Nav.control.retractLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)else BrakeIsOn=true;bc=autoRollPreference;GearExtended=OldGearExtended;if GearExtended then Nav.control.extendLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)end end else W="Follow Mode only works with Remote controller"U=false end end;function ToggleAutopilot()TargetSet=false;if AutopilotTargetIndex>0 and not Autopilot and not VectorToTarget and not ah then UpdateAutopilotTarget()local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)if CustomTarget~=nil then LockPitch=nil;SpaceTarget=CustomTarget.planetname=="Space"if SpaceTarget then if j()~=0 then ah=true;ToggleAltitudeHold()else Autopilot=true end elseif planet.name==CustomTarget.planetname then StrongBrakes=true;if j()>0 then bx=false;if not VectorToTarget then ToggleVectorToTarget(SpaceTarget)end else if an>100000 or an==0 then bx=false;Autopilot=true else ag=true;ProgradeIsOn=true;if AltitudeHold then ToggleAltitudeHold()end end end else RetrogradeIsOn=false;ProgradeIsOn=false;if j()~=0 then ah=true;ToggleAltitudeHold()else Autopilot=true end end elseif j()==0 then local cB=unit.getClosestPlanetInfluence()>0;if CustomTarget==nil and(a4.name==planet.name and cB)then ToggleIntoOrbit()else Autopilot=true;RetrogradeIsOn=false;ProgradeIsOn=false;AutopilotRealigned=false;U=false;AltitudeHold=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;G=false;LockPitch=nil;WaypointSet=false end else ah=true;ToggleAltitudeHold()end else ah=false;Autopilot=false;AutopilotRealigned=false;VectorToTarget=false;G=false;AutoTakeoff=false;AltitudeHold=false;VectorToTarget=false;HoldAltitude=an;TargetSet=false end end;function ProgradeToggle()ProgradeIsOn=not ProgradeIsOn;RetrogradeIsOn=false;Autopilot=false;AltitudeHold=false;U=false;BrakeLanding=false;LockPitch=nil;Reentry=false;AutoTakeoff=false end;function RetrogradeToggle()RetrogradeIsOn=not RetrogradeIsOn;ProgradeIsOn=false;Autopilot=false;AltitudeHold=false;U=false;BrakeLanding=false;LockPitch=nil;Reentry=false;AutoTakeoff=false end;function BrakeToggle()BrakeIsOn=not BrakeIsOn;if BrakeLanding then BrakeLanding=false;bc=autoRollPreference end;if BrakeIsOn then AltitudeHold=false;VectorToTarget=false;AutoTakeoff=false;VertTakeOff=false;Reentry=false;ProgradeIsOn=false;BrakeLanding=false;AutoLanding=false;AltitudeHold=false;IntoOrbit=false;LockPitch=nil;bc=autoRollPreference;ag=false;ai=false;a8=0 end end;function CheckDamage(ct)local cC=0;ax=""local cD=aP;local cE=0;local cF=0;local cG=0;local cH=0;local cI=""for bB in pairs(ao)do local bJ=0;local cJ=0;cJ=h(ao[bB])bJ=k(ao[bB])cE=cE+bJ;if bJ0 and au[11]==ao[bB]then for cL in pairs(au)do core.deleteSticker(au[cL])end;au={}end end;cC=d(cE/cD*100)if cC<100 then ct[#ct+1]=[[]]cH=d(cC*2.55)cI=e("rgb(%d,%d,%d)",255-cH,cH,0)if cC<100 then ct[#ct+1]=e([[Elemental Integrity: %i %%]],cI,cC)if cG>0 then ct[#ct+1]=e([[Disabled Modules: %i Damaged Modules: %i]],cI,cG,cF)elseif cF>0 then ct[#ct+1]=e([[Damaged Modules: %i]],cI,cF)end end;ct[#ct+1]=[[<\g>]]end end;function DrawCursorLine(ct)local cM=d(utils.clamp(ac/(aC/4)*255,0,255))ct[#ct+1]=e("",a9,aa,d(t+0.5)+cM,d(v+0.5)-cM,d(u+0.5)-cM)end;function getPitch(cN,cO,c5)local cP=cN:cross(c5):normalize_inplace()local cz=math.acos(utils.clamp(cP:dot(-cO),-1,1))*constants.rad2deg;if cP:cross(-cO):dot(c5)<0 then cz=-cz end;return cz end;local function cQ(cR,cS,cT)cS=cS:project_on_plane(cR)cT=cT:project_on_plane(cR)return p(cS:cross(cT):dot(cR),cS:dot(cT))end;function clearAll()if ak then ak=false;AutopilotAccelerating=false;AutopilotBraking=false;AutopilotCruising=false;Autopilot=false;AutopilotRealigned=false;AutopilotStatus="Aligning"RetrogradeIsOn=false;ProgradeIsOn=false;AltitudeHold=false;Reentry=false;BrakeLanding=false;BrakeIsOn=false;AutoTakeoff=false;VertTakeOff=false;U=false;G=false;ag=false;ah=false;J=false;bc=autoRollPreference;VectorToTarget=false;TurnBurn=false;aq=false;LockPitch=nil else ak=true end end;function wipeSaveVariables()if not dbHud_1 then W="No Databank Found, unable to wipe. \nYou must have a Databank attached to ship prior to running the HUD autoconfigure"ab=5 else if aJ then for bB,bC in pairs(a)do dbHud_1.setStringValue(bC,g(nil))end;for bB,bC in pairs(b)do if bC~="SavedLocations"then dbHud_1.setStringValue(bC,g(nil))end end;W="Databank wiped. New variables will save after re-enter seat and exit"ab=5;aJ=false;aI=false;a7=true else W="Press ALT-7 again to confirm wipe of ALL data"aJ=true end end end;function CheckButtons()for _,bC in pairs(az)do if bC.hovered then if not bC.drawCondition or bC.drawCondition()then bC.toggleFunction()end;bC.hovered=false end end end;function SetButtonContains()local bY=a9+aC/2;local bZ=aa+aD/2;for _,bC in pairs(az)do bC.hovered=Contains(bY,bZ,bC.x,bC.y,bC.width,bC.height)end end;function DrawButton(ct,cU,hover,bY,bZ,cV,cW,cX,cY,cZ,c_)if type(cZ)=="function"then cZ=cZ()end;if type(c_)=="function"then c_=c_()end;ct[#ct+1]=e(""if cU then ct[#ct+1]=e("%s",cZ)else ct[#ct+1]=e("%s",c_)end end;function DrawButtons(ct)local d0="rgb(50,50,50)'"local d1="rgb(210,200,200)"local d2=DrawButton;for _,bC in pairs(az)do local bV=bC.disableName;local bU=bC.enableName;if type(bV)=="function"then bV=bV()end;if type(bU)=="function"then bU=bU()end;if not bC.drawCondition or bC.drawCondition()then d2(ct,bC.toggleVar(),bC.hovered,bC.x,bC.y,bC.width,bC.height,d1,d0,bV,bU)end end end;function DrawTank(ct,aY,bY,d3,d4,d5,d6,d7)local d8=1;local d9=2;local da=3;local db=4;local dc=5;local dd=6;local de=""local df=0;local dg=fuelY;local dh=fuelY+10;if o()==1 and not RemoteHud then dg=dg-50;dh=dh-50 end;ct[#ct+1]=[[]]if d4=="ATMO"then de="atmofueltank"elseif d4=="SPACE"then de="spacefueltank"else de="rocketfueltank"end;df=_G[de.."_size"]if#d5>0 then for i=1,#d5 do local co=string.sub(d5[i][d9],1,12)local di=0;for cL=1,df do if d5[i][d9]==f(unit[de.."_"..cL].getData()).name then di=cL;break end end;if aY or d6[i]==nil or d7[i]==nil then local dj=0;local dk=0;local dl=0;local dm=0;local bL=system.getTime()if di~=0 then d7[i]=f(unit[de.."_"..di].getData()).percentage;d6[i]=f(unit[de.."_"..di].getData()).timeLeft;if d6[i]=="n/a"then d6[i]=0 end else dl=m(d5[i][d8])-d5[i][db]dj=d5[i][da]d7[i]=d(0.5+dl*100/dj)dk=d5[i][dc]dm=d5[i][dd]if dk<=dl then d6[i]=0 else d6[i]=d(0.5+dl/((dk-dl)/(bL-dm)))end;d5[i][dc]=dl;d5[i][dd]=bL end end;if co==d3 then co=e("%s %d",d4,i)end;if di==0 then co=co.." *"end;local dn;if d6[i]==0 then dn="n/a"else dn=FormatTimeString(d6[i])end;if d7[i]~=nil then local cH=d(d7[i]*2.55)local cI=e("rgb(%d,%d,%d)",255-cH,cH,0)local dp=""if dn~="n/a"and d6[i]<120 or d7[i]<5 then if aY then dp=[[class="red"]]end end;ct[#ct+1]=e([[ %s %d%% %s @@ -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 DrawDeadZone(ct)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 DrawCursorLine(ct)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 rateOfChange=vec3(core.getConstructWorldOrientationForward()):dot(vec3(core.getWorldVelocity()):normalize())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(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;VertTakeOffMode=string.lower(VertTakeOffMode)if VertTakeOffMode=="agg"and not ExternalAGG and antigrav~=nil then antigrav.activate()antigrav.show()if an0 then BrakeIsOn=true;a8=0 elseif eg<-5 then BrakeIsOn=true;a8=15 elseif an>=antigrav.getBaseAltitude()then BrakeIsOn=true;a8=0;VertTakeOff=false;W="Singularity engaged"end elseif VertTakeOffMode=="orbit"then if eg<-30 then W="Unable to take off. Landing."a8=0;bc=autoRollPreference;VertTakeOff=false;BrakeLanding=true elseif 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 else W="Incorrect settings for ship configuration. Takeoff aborted."bc=autoRollPreference;VertTakeOff=false;BrakeLanding=true 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 AutoTakeoff or VectorToTarget then if VectorToTarget then if bw==nil then bw=a4 end;bt=VectorToTarget end;if bw==nil then bw=planet end;AltitudeHold=false;Autopilot=false;VectorToTarget=false;br=true end;local iJ,iK=b9(bw):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-bw.center):len()-bw.radius)local iL=dM;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;if bt or AutoTakeoff then bv=AutoTakeoffAltitude;AutoTakeoff=false end;bu=true end;if HoldAltitude>bv then bv=HoldAltitude end;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 then VectorToTarget=bt end;bt=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>15 then iM(0.5,-80)BrakeIsOn=false elseif eg<-15 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;bx=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 j()==0 and(a4~=nil and a4.name==planet.name)and not VectorToTarget and not Reentry and not BrakeLanding and LockPitch==nil and anplanet.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 LastDistanceToTarget0 and j()==0 and a4.name==planet.name then if not bx then Autopilot=false;ah=false;AltitudeHold=false;IntoOrbit=true;bu=false;bw=a4 else local dv;if CustomTarget~=nil then dv=CustomTarget.position-vec3(core.getConstructWorldPos())else dv=a4.center-iB end;local jq=planet:getAltitude(CustomTarget.position)local jl=math.sqrt(dv:len()^2-(an-jq)^2)local jr=LastMaxBrakeInAtmo;jr=LastMaxBrake;a0,a1=b7.computeDistanceAndTime(be,0,n(),0,0,jr/2)StrongBrakes=true;if not ah 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 if planet.hasAtmosphere then BrakeIsOn=false;ProgradeIsOn=false;J=true;ag=false;ai=true;Autopilot=false;VectorToTarget=false;BeginReentry()end end;LastDistanceToTarget=jl 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=b6:getPlanetarySystem(0):castIntersections(iB,(AutopilotTargetCoords-iB):normalize(),function(fi)return fi.radius+fi.noAtmosphericDensityAltitude 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 DrawDeadZone(ct)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 DrawCursorLine(ct)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 rateOfChange=vec3(core.getConstructWorldOrientationForward()):dot(vec3(core.getWorldVelocity()):normalize())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(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;VertTakeOffMode=string.lower(VertTakeOffMode)if VertTakeOffMode=="agg"and not ExternalAGG and antigrav~=nil then antigrav.activate()antigrav.show()if an0 then BrakeIsOn=true;a8=0 elseif eg<-5 then BrakeIsOn=true;a8=15 elseif an>=antigrav.getBaseAltitude()then BrakeIsOn=true;a8=0;VertTakeOff=false;W="Singularity engaged"end elseif VertTakeOffMode=="orbit"then if eg<-30 then W="Unable to take off. Landing."a8=0;bc=autoRollPreference;VertTakeOff=false;BrakeLanding=true elseif 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 else W="Incorrect settings for ship configuration. Takeoff aborted."bc=autoRollPreference;VertTakeOff=false;BrakeLanding=true 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 AutoTakeoff or VectorToTarget then if VectorToTarget then if bw==nil then bw=a4 end;bt=VectorToTarget end;if bw==nil then bw=planet end;AltitudeHold=false;Autopilot=false;VectorToTarget=false;br=true end;local iJ,iK=b9(bw):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-bw.center):len()-bw.radius)local iL=dM;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;if bt or AutoTakeoff then bv=AutoTakeoffAltitude;AutoTakeoff=false end;bu=true end;if HoldAltitude>bv then bv=HoldAltitude end;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 then VectorToTarget=bt end;bt=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>15 then iM(0.5,-80)BrakeIsOn=false elseif eg<-15 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;bx=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 j()==0 and(a4~=nil and a4.name==planet.name)and not VectorToTarget and not Reentry and not BrakeLanding and LockPitch==nil and anplanet.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 LastDistanceToTarget0 and j()==0 and a4.name==planet.name then if not bx then Autopilot=false;ah=false;AltitudeHold=false;IntoOrbit=true;bu=false;bw=a4 else local dv;if CustomTarget~=nil then dv=CustomTarget.position-vec3(core.getConstructWorldPos())else dv=a4.center-iB end;local jq=planet:getAltitude(CustomTarget.position)local jl=math.sqrt(dv:len()^2-(an-jq)^2)local jr=LastMaxBrakeInAtmo;jr=LastMaxBrake;a0,a1=b7.computeDistanceAndTime(be,0,n(),0,0,jr/2)StrongBrakes=true;if not ah 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 if planet.hasAtmosphere then BrakeIsOn=false;ProgradeIsOn=false;J=true;ag=false;ai=true;Autopilot=false;VectorToTarget=false;BeginReentry()end end;LastDistanceToTarget=jl 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=b6:getPlanetarySystem(0):castIntersections(iB,(AutopilotTargetCoords-iB):normalize(),function(fi)return fi.radius+fi.noAtmosphericDensityAltitude 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 6ed8427..f9b77fe 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +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.43 +- Removed description of user variables from code to Readme.md to free up code space and prevent unloading of script. File size reduced from 192k to 184k minimized. + Version 5.42 - VTO to Orbit or AGG Height, ATO to AGG, and Same Planet Orbital Hops. - Vertical Takeoff v3 - (`VertTakeOffEngine` must be set to True for the below to work) - When `VertTakeOffMode` is set to *"AGG"*, it will now activate AGG and vertically fly up just above AGG Singularity height and stay in the air until the Singularity is at your height, then the engines are turned off and the brakes are engaged. *Not available if you use ExternalAGG.* diff --git a/README.md b/README.md index 4ed7397..f783c20 100644 --- a/README.md +++ b/README.md @@ -141,69 +141,97 @@ This also means that when using autopilot, you can relatively easily move betwee [Return to Table of Contents](#table-of-contents) # Customization -The following LUA parameters were added Right click the seat and go to _Advanced_ -> _Edit Lua Parameters_ to see them all. Mouse over a name to see its purpose and potential settings. - -- USER DEFINABLE GLOBAL AND LOCAL VARIABLES THAT SAVE - * useTheseSettings = false -- export: Toggle on to use the below preferences. Toggle off to use saved preferences. Preferences will save regardless when exiting seat. - * freeLookToggle = true -- export: Set to false for vanilla DU free look behavior. - * BrakeToggleDefault = true -- export: Whether your brake toggle is on/off by default. Can be adjusted in the button menu. Of is vanilla DU brakes. - * RemoteFreeze = false -- export: Whether or not to freeze you when using a remote controller. Breaks some things, only freeze on surfboards - * RemoteHud = false -- export: Whether you want full HUD while in remote mode, experimental, might not look right. - * userControlScheme = "virtual joystick" -- export: Set to "virtual joystick", "mouse", or "keyboard" - * brightHud = false -- export: Enable to prevent hud dimming when in freelook. - * PrimaryR = 130 -- export: Primary HUD color - * PrimaryG = 224 -- export: Primary HUD color - * PrimaryB = 255 -- export: Primary HUD color - * centerX = 960 -- export: X postion of Artifical Horizon (KSP Navball), (use 1920x1080, it will scale) Default 960. Use centerX=700 and centerY=880 for lower left placement. - * centerY = 540 -- export: Y postion of Artifical Horizon (KSP Navball), (use 1920x1080, it will scale) Default 540. Use centerX=700 and centerY=880 for lower left placement. - * throtPosX = 1300 -- export: X position of Throttle Indicator, default 1300 to put it to right of default AH centerX parameter. - * throtPosY = 540 -- export: Y position of Throttle indicator, default is 540 to place it centered on default AH centerY parameter. - * vSpdMeterX = 1525 -- export: X postion of Vertical Speed Meter. Default 1525 (use 1920x1080, it will scale) - * vSpdMeterY = 250 -- export: Y postion of Vertical Speed Meter. Default 250 (use 1920x1080, it will scale) - * altMeterX = 550 -- export: X postion of Altimeter. Default 550 (use 1920x1080, it will scale) - * altMeterY = 540 -- export: Y postion of Altimeter. Default 500 (use 1920x1080, it will scale) - * fuelX = 100 -- export: X position of fuel tanks, default is 100 for left side, set both fuelX and fuelY to 0 to hide fuel - * fuelY = 350 -- export: Y position of fuel tanks, default 350 for left side, set both fuelX and fuelY to 0 to hide fuel - * circleRad = 400 -- export: The size of the artifical horizon circle, recommended minimum 100, maximum 400. Looks different > 200. Set to 0 to remove. - * DeadZone = 50 -- export: Number of pixels of deadzone at the center of the screen - * showHud = true -- export: Uncheck to hide the HUD and only use autopilot features via ALT+# keys. - * hideHudOnToggleWidgets = true -- export: Uncheck to keep showing HUD when you toggle on the widgets via ALT+3. - * ShiftShowsRemoteButtons = true -- export: Whether or not pressing Shift in remote controller mode shows you the buttons (otherwise no access to them) - * StallAngle = 35 --export: Determines how much Autopilot is allowed to make you yaw/pitch in atmosphere. Also gives a stall warning when not autopilot. (default 35, higher = more tolerance for yaw/pitch/roll) - * speedChangeLarge = 5 -- export: The speed change that occurs when you tap speed up/down, default is 5 (25% throttle change). - * speedChangeSmall = 1 -- export: the speed change that occurs while you hold speed up/down, default is 1 (5% throttle change). - * brakeLandingRate = 30 -- export: Max loss of altitude speed in m/s when doing a brake landing, default 30. This is to prevent "bouncing" as hover/boosters catch you. Do not use negative number. - * MaxPitch = 30 -- export: Maximum allowed pitch during takeoff and altitude changes while in altitude hold. Default is 20 deg. You can set higher or lower depending on your ships capabilities. - * ReentrySpeed = 1050 -- export: Target re-entry speed once in atmosphere in m/s. 291 = 1050 km/hr, higher might cause reentry burn. - * ReentryAltitude = 2500 -- export: Target alititude when using re-entry. - * EmergencyWarpDistance = 320000 -- export: Set to distance as which an emergency warp will occur if radar target within that distance. 320000 is lock range for large radar on large ship no special skills. - * IgnoreEmergencyWarpDistance = 500 -- export: Any targets within this distance are ignored for emergency warp. - * RequireLock = false -- export: Set to true to require a target to lock onto you before starting an emergency warp. - * AutoTakeoffAltitude = 1000 -- export: How high above your ground starting position AutoTakeoff tries to put you - * TargetHoverHeight = 50 -- export: Hover height when retracting landing gear - * LandingGearGroundHeight = 0 --export: Set to hover height reported - 1 when you use alt-spacebar to just lift off ground from landed postion. 4 is M size landing gear, - * MaxGameVelocity = 8333.00 -- export: Max speed for your autopilot in m/s, do not go above 8333.055 (30000 km/hr), can be reduced to safe fuel, use 6944.4444 for 25000km/hr - * AutopilotTargetOrbit = 50000 -- export: How far you want the orbit to be from the planet in m. 200,000 = 1SU (Default 50000) - * AutopilotInterplanetaryThrottle = 1.0 -- export: How much throttle, 0.0 to 1.0, you want it to use when in autopilot to another planet to reach MaxGameVelocity - * warmup = 32 -- export: How long it takes your engines to warmup. Basic Space Engines, from XS to XL: 0.25,1,4,16,32 - * MouseYSensitivity = 0.003 --export:1 For virtual joystick only - * MouseXSensitivity = 0.003 -- export: For virtual joystick only - * autoRollPreference = false -- export: [Only in atmosphere]
When the pilot stops rolling, flight model will try to get back to horizontal (no roll) - * autoRollFactor = 2 -- export: [Only in atmosphere]
When autoRoll is engaged, this factor will increase to strength of the roll back to 0
Valid values: Superior or equal to 0.01 - * rollSpeedFactor = 1.5 -- export: This factor will increase/decrease the player input along the roll axis
(higher value may be unstable)
Valid values: Superior or equal to 0.01 - * turnAssist = true -- export: [Only in atmosphere]
When the pilot is rolling, the flight model will try to add yaw and pitch to make the construct turn better
The flight model will start by adding more yaw the more horizontal the construct is and more pitch the more vertical it is - * turnAssistFactor = 2 -- export: [Only in atmosphere]
This factor will increase/decrease the turnAssist effect
(higher value may be unstable)
Valid values: Superior or equal to 0.01 - * TrajectoryAlignmentStrength = 0.002 -- export: How strongly AP tries to align your velocity vector to the target when not in orbit, recommend 0.002 - * pitchSpeedFactor = 0.8 -- export: For keyboard control - * yawSpeedFactor = 1 -- export: For keyboard control - * brakeSpeedFactor = 3 -- export: When braking, this factor will increase the brake force by brakeSpeedFactor * velocity
Valid values: Superior or equal to 0.01 - * brakeFlatFactor = 1 -- export: When braking, this factor will increase the brake force by a flat brakeFlatFactor * velocity direction>
(higher value may be unstable)
Valid values: Superior or equal to 0.01 - * DampingMultiplier = 40 -- export: How strongly autopilot dampens when nearing the correct orientation - * fuelTankHandlingAtmo = 0 -- export: For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. - * fuelTankHandlingSpace = 0 -- export: For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. - * fuelTankHandlingRocket = 0 -- export: For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. - * apTickRate = 0.0166667 -- export: Set the Tick Rate for your HUD. 0.016667 is effectively 60 fps and the default value. 0.03333333 is 30 fps. The bigger the number the less often the autopilot and hud updates but may help peformance on slower machings. +* -- Edit LUA Variable user settings. Must be global to work with databank system as set up due to using _G assignment +* useTheseSettings = false -- export: (Default: false) Toggle on to use the below preferences. Toggle off to use saved preferences. Preferences will save regardless when exiting seat. +* freeLookToggle = true -- export: (Default: true) Set to false for vanilla DU free look behavior. +* BrakeToggleDefault = true -- export: (Default: true) Whether your brake toggle is on/off by default. Can be adjusted in the button menu. Of is vanilla DU brakes. +* RemoteFreeze = false -- export: (Default: false) Whether or not to freeze you when using a remote controller. Breaks some things, only freeze on surfboards +* RemoteHud = false -- export: (Default: false) Whether you want full HUD while in remote mode, experimental, might not look right. +* brightHud = false -- export: (Default: false) Enable to prevent hud dimming when in freelook. +* VanillaRockets = false -- export: (Default: false) If on, rockets behave like vanilla +* InvertMouse = false -- export: (Default: false) If true, then when controlling flight mouse Y axis is inverted (pushing up noses plane down) Does not affect selecting buttons or camera. +* userControlScheme = "virtual joystick" -- export: (Default: "virtual joystick") Set to "virtual joystick", "mouse", or "keyboard" +* ResolutionX = 1920 -- export: (Default: 1920) Does not need to be set to same as game resolution. You can set 1920 on a 2560 to get larger resolution +* ResolutionY = 1080 -- export: (Default: 1080) Does not need to be set to same as game resolution. You can set 1080 on a 1440 to get larger resolution +* SafeR = 130 -- export: (Default: 130) Primary HUD color +* SafeG = 224 -- export: (Default: 224) Primary HUD color +* SafeB = 255 -- export: (Default: 255) Primary HUD color +* PvPR = 255 -- export: (Default: 255) PvP HUD color +* PvPG = 0 -- export: (Default: 0) PvP HUD color +* PvPB = 0 -- export: (Default: 0) PvP HUD color +* centerX = 960 -- export: (Default: 960) X postion of Artifical Horizon (KSP Navball), Default 960. Use centerX=700 and centerY=880 for lower left placement. +* centerY = 540 -- export: (Default: 540) Y postion of Artifical Horizon (KSP Navball), Default 540. Use centerX=700 and centerY=880 for lower left placement. +* throtPosX = 1300 -- export: (Default: 1300) X position of Throttle Indicator, default 1300 to put it to right of default AH centerX parameter. +* throtPosY = 540 -- export: (Default: 540) Y position of Throttle indicator, default is 540 to place it centered on default AH centerY parameter. +* vSpdMeterX = 1525 -- export: (Default: 1525) X postion of Vertical Speed Meter. Default 1525 (use 1920x1080, it will scale) +* vSpdMeterY = 250 -- export: (Default: 250) Y postion of Vertical Speed Meter. Default 250 (use 1920x1080, it will scale) +* altMeterX = 550 -- export: (Default: 550) X postion of Altimeter. Default 550 (use 1920x1080, it will scale) +* altMeterY = 540 -- export: (Default: 540) Y postion of Altimeter. Default 500 (use 1920x1080, it will scale) +* fuelX = 100 -- export: (Default: 100) X position of fuel tanks, default is 100 for left side, set both fuelX and fuelY to 0 to hide fuel +* fuelY = 350 -- export: (Default: 350) Y position of fuel tanks, default 350 for left side, set both fuelX and fuelY to 0 to hide fuel +* circleRad = 400 -- export: (Default: 400) The size of the artifical horizon circle, recommended minimum 100, maximum 400. Looks different > 200. Set to 0 to remove. +* DeadZone = 50 -- export: (Default: 50) Number of pixels of deadzone at the center of the screen +* DisplayOrbit = true -- export: (Default: true) Show Orbit display when valid or not. May be toggled with shift Buttons +* OrbitMapSize = 250 -- export: (Default: 250) Size of the orbit map, make sure it is divisible by 4 +* OrbitMapX = 75 -- export: (Default: 75) X postion of Orbit Display Disabled +* OrbitMapY = 0 -- export: (Default: 0) Y position of Orbit Display +* showHud = true -- export: (Default: true) Uncheck to hide the HUD and only use autopilot features via ALT+# keys. +* ShowOdometer = true -- export: (Default: true) Uncheck to hide the odometer panel up top. +* hideHudOnToggleWidgets = true -- export: (Default: true) Uncheck to keep showing HUD when you toggle on the widgets via ALT+3. +* ShiftShowsRemoteButtons = true -- export: (Default: true) Whether or not pressing Shift in remote controller mode shows you the buttons (otherwise no access to them) +* YawStallAngle = 35 --export: (Default: 35) Angle at which the ship stalls when yawing (Stabilizers: 70, Wings: 55, Ailerons: 30) +* PitchStallAngle = 35 --export: (Default: 35) Angle at which the ship stalls when pitching (Stabilizers: 70, Wings: 55, Ailerons: 30) +* speedChangeLarge = 5 -- export: (Default: 5) The speed change that occurs when you tap speed up/down, default is 5 (25% throttle change). +* speedChangeSmall = 1 -- export: (Default: 1) the speed change that occurs while you hold speed up/down, default is 1 (5% throttle change). +* brakeLandingRate = 30 -- export: (Default: 30) Max loss of altitude speed in m/s when doing a brake landing, default 30. This is to prevent "bouncing" as hover/boosters catch you. Do not use negative number. +* MaxPitch = 30 -- export: (Default: 30) Maximum allowed pitch during takeoff and altitude changes while in altitude hold. You can set higher or lower depending on your ships capabilities. +* ReentrySpeed = 1050 -- export: (Default: 1050) Target re-entry speed once in atmosphere in km/h. +* AtmoSpeedLimit = 1050 -- export: (Default: 1050) Speed limit in Atmosphere in km/h. If you exceed this limit the ship will attempt to break till below this limit. +* SpaceSpeedLimit = 30000 -- export: (Default: 30000) Space speed limit in KM/H. If you hit this speed but are not in active autopilot, engines will turn off. +* ReentryAltitude = 2500 -- export: (Default: 2500) Target alititude when using re-entry. +* AutoTakeoffAltitude = 1000 -- export: (Default: 1000) How high above your ground starting position AutoTakeoff tries to put you +* TargetHoverHeight = 50 -- export: (Default: 50) Hover height when retracting landing gear +* LandingGearGroundHeight = 0 --export: (Default: 0) Set to AGL-1 when on ground (or 0) +* MaxGameVelocity = 8333.00 -- export: (Default: 8333.00) Max speed for your autopilot in m/s, do not go above 8333.055 (30000 km/hr), can be reduced to safe fuel, use 6944.4444 for 25000km/hr +* TargetOrbitRadius = 1.4 -- export: (Default: 1.4) How tight you want to orbit the planet at end of autopilot. The smaller the value the tighter the orbit. 1.4 sets an Alioth orbit of 56699m. +* AutopilotInterplanetaryThrottle = 1.0 -- export: (Default: 1.0) How much throttle, 0.0 to 1.0, you want it to use when in autopilot to another planet to reach MaxGameVelocity +* warmup = 32 -- export: (Default: 32) How long it takes your engines to warmup. Basic Space Engines, from XS to XL: 0.25,1,4,16,32 +* MouseYSensitivity = 0.003 --export: (Default: 0.003) For virtual joystick only +* MouseXSensitivity = 0.003 -- export: (Default: 0.003) For virtual joystick only +* autoRollPreference = false -- export: (Default: false) [Only in atmosphere]
When the pilot stops rolling, flight model will try to get back to horizontal (no roll) +* autoRollFactor = 2 -- export: (Default: 2) [Only in atmosphere]
When autoRoll is engaged, this factor will increase to strength of the roll back to 0
Valid values: Superior or equal to 0.01 +* rollSpeedFactor = 1.5 -- export: (Default: 1.5) This factor will increase/decrease the player input along the roll axis
(higher value may be unstable)
Valid values: Superior or equal to 0.01 +* turnAssist = true -- export: (Default: true) [Only in atmosphere]
When the pilot is rolling, the flight model will try to add yaw and pitch to make the construct turn better
The flight model will start by adding more yaw the more horizontal the construct is and more pitch the more vertical it is +* turnAssistFactor = 2 -- export: (Default: 2) [Only in atmosphere]
This factor will increase/decrease the turnAssist effect
(higher value may be unstable)
Valid values: Superior or equal to 0.01 +* TrajectoryAlignmentStrength = 0.002 -- export: (Default: 0.002) How strongly AP tries to align your velocity vector to the target when not in orbit, recommend 0.002 +* torqueFactor = 2 -- export: (Default: 2) Force factor applied to reach rotationSpeed
(higher value may be unstable)
Valid values: Superior or equal to 0.01 +* pitchSpeedFactor = 0.8 -- export: (Default: 0.8) For keyboard control +* yawSpeedFactor = 1 -- export: (Default: 1) For keyboard control +* brakeSpeedFactor = 3 -- export: (Default: 3) When braking, this factor will increase the brake force by brakeSpeedFactor * velocity
Valid values: Superior or equal to 0.01 +* brakeFlatFactor = 1 -- export: (Default: 1) When braking, this factor will increase the brake force by a flat brakeFlatFactor * velocity direction>
(higher value may be unstable)
Valid values: Superior or equal to 0.01 +* DampingMultiplier = 40 -- export: (Default: 40) How strongly autopilot dampens when nearing the correct orientation +* fuelTankHandlingAtmo = 0 -- export: (Default: 0) For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. +* fuelTankHandlingSpace = 0 -- export: (Default: 0) For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. +* fuelTankHandlingRocket = 0 -- export: (Default: 0) For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. +* ContainerOptimization = 0 -- export: (Default: 0) For accurate estimates, set this to the Container Optimization level of the person who placed the tanks. Ignored for slotted tanks. +* FuelTankOptimization = 0 -- export: (Default: 0) For accurate unslotted fuel tank calculation, set this to the fuel tank optimization skill level of the person who placed the tank. Ignored for slotted tanks. +* ExtraLongitudeTags = "none" -- export: (Default: "none") Enter any extra longitudinal tags you use inside '' seperated by space, i.e. "forward faster major" These will be added to the engines that are control by longitude. +* ExtraLateralTags = "none" -- export: (Default: "none") Enter any extra lateral tags you use inside '' seperated by space, i.e. "left right" These will be added to the engines that are control by lateral. +* ExtraVerticalTags = "none" -- export: (Default: "none") Enter any extra longitudinal tags you use inside '' seperated by space, i.e. "up down" These will be added to the engines that are control by vertical. +* ExternalAGG = false -- export: (Default: false) Toggle On if using an external AGG system. If on will prevent this HUD from doing anything with AGG. +* UseSatNav = false -- export: (Default: false) Toggle on if using Trog SatNav script. This will provide SatNav support. +* apTickRate = 0.0166667 -- export: (Default: 0.0166667) Set the Tick Rate for your autopilot features. 0.016667 is effectively 60 fps and the default value. 0.03333333 is 30 fps. +* hudTickRate = 0.0666667 -- export: (Default: 0.0666667) Set the tick rate for your HUD. Default is 4 times slower than apTickRate +* ShouldCheckDamage = true --export: (Default: true) Whether or not damage checks are performed. Disabled for performance on very large ships +* CalculateBrakeLandingSpeed = false --export: (Default: false) Whether BrakeLanding speed at non-waypoints should be calculated or use the brakeLandingRate user setting. Only set to true for ships with low mass to lift capability. +* autoRollRollThreshold = 0 --export: (Default: 0) The minimum amount of roll before autoRoll kicks in and stabilizes (if active) +* AtmoSpeedAssist = true --export: (Default: true) Whether or not atmospheric speeds should be limited to a maximum of AtmoSpeedLimit +* ForceAlignment = false --export: (Default: false) Whether velocity vector alignment should be forced when in Altitude Hold +* minRollVelocity = 150 --export: (Default: 150) Min velocity, in m/s, over which advanced rolling can occur +* VertTakeOffEngine = false --export: (Default: false) Set this to true if you have VTOL engines on your construct. Changes Auto Takeoff to Vertical Takeoff. +* VertTakeOffMode = "Orbit" --export: (Default: "Orbit") Set to: "AGG" = turn on AGG when above 1km and near AGG activation height, "Orbit" = go directly to orbit based off of TargetOrbitRadius. Must keep quotes. Any case is fine. [Return to Table of Contents](#table-of-contents) diff --git a/src/ButtonHUD.lua b/src/ButtonHUD.lua index 11ffda9..aa421f1 100644 --- a/src/ButtonHUD.lua +++ b/src/ButtonHUD.lua @@ -6,93 +6,93 @@ script = {} -- wrappable container for all the code. Different than normal DU L -- Edit LUA Variable user settings. Must be global to work with databank system as set up due to using _G assignment useTheseSettings = false -- export: (Default: false) Toggle on to use the below preferences. Toggle off to use saved preferences. Preferences will save regardless when exiting seat. -freeLookToggle = true -- export: (Default: true) Set to false for vanilla DU free look behavior. -BrakeToggleDefault = true -- export: (Default: true) Whether your brake toggle is on/off by default. Can be adjusted in the button menu. Of is vanilla DU brakes. -RemoteFreeze = false -- export: (Default: false) Whether or not to freeze you when using a remote controller. Breaks some things, only freeze on surfboards -RemoteHud = false -- export: (Default: false) Whether you want full HUD while in remote mode, experimental, might not look right. -brightHud = false -- export: (Default: false) Enable to prevent hud dimming when in freelook. -VanillaRockets = false -- export: (Default: false) If on, rockets behave like vanilla -InvertMouse = false -- export: (Default: false) If true, then when controlling flight mouse Y axis is inverted (pushing up noses plane down) Does not affect selecting buttons or camera. +freeLookToggle = true -- export: (Default: true) +BrakeToggleDefault = true -- export: (Default: true) +RemoteFreeze = false -- export: (Default: false) +RemoteHud = false -- export: (Default: false) +brightHud = false -- export: (Default: false) +VanillaRockets = false -- export: (Default: false) +InvertMouse = false -- export: (Default: false) userControlScheme = "virtual joystick" -- export: (Default: "virtual joystick") Set to "virtual joystick", "mouse", or "keyboard" -ResolutionX = 1920 -- export: (Default: 1920) Does not need to be set to same as game resolution. You can set 1920 on a 2560 to get larger resolution -ResolutionY = 1080 -- export: (Default: 1080) Does not need to be set to same as game resolution. You can set 1080 on a 1440 to get larger resolution -SafeR = 130 -- export: (Default: 130) Primary HUD color -SafeG = 224 -- export: (Default: 224) Primary HUD color -SafeB = 255 -- export: (Default: 255) Primary HUD color -PvPR = 255 -- export: (Default: 255) PvP HUD color -PvPG = 0 -- export: (Default: 0) PvP HUD color -PvPB = 0 -- export: (Default: 0) PvP HUD color -centerX = 960 -- export: (Default: 960) X postion of Artifical Horizon (KSP Navball), Default 960. Use centerX=700 and centerY=880 for lower left placement. -centerY = 540 -- export: (Default: 540) Y postion of Artifical Horizon (KSP Navball), Default 540. Use centerX=700 and centerY=880 for lower left placement. -throtPosX = 1300 -- export: (Default: 1300) X position of Throttle Indicator, default 1300 to put it to right of default AH centerX parameter. -throtPosY = 540 -- export: (Default: 540) Y position of Throttle indicator, default is 540 to place it centered on default AH centerY parameter. -vSpdMeterX = 1525 -- export: (Default: 1525) X postion of Vertical Speed Meter. Default 1525 (use 1920x1080, it will scale) -vSpdMeterY = 250 -- export: (Default: 250) Y postion of Vertical Speed Meter. Default 250 (use 1920x1080, it will scale) -altMeterX = 550 -- export: (Default: 550) X postion of Altimeter. Default 550 (use 1920x1080, it will scale) -altMeterY = 540 -- export: (Default: 540) Y postion of Altimeter. Default 500 (use 1920x1080, it will scale) -fuelX = 100 -- export: (Default: 100) X position of fuel tanks, default is 100 for left side, set both fuelX and fuelY to 0 to hide fuel -fuelY = 350 -- export: (Default: 350) Y position of fuel tanks, default 350 for left side, set both fuelX and fuelY to 0 to hide fuel -circleRad = 400 -- export: (Default: 400) The size of the artifical horizon circle, recommended minimum 100, maximum 400. Looks different > 200. Set to 0 to remove. -DeadZone = 50 -- export: (Default: 50) Number of pixels of deadzone at the center of the screen -DisplayOrbit = true -- export: (Default: true) Show Orbit display when valid or not. May be toggled with shift Buttons -OrbitMapSize = 250 -- export: (Default: 250) Size of the orbit map, make sure it is divisible by 4 -OrbitMapX = 75 -- export: (Default: 75) X postion of Orbit Display Disabled -OrbitMapY = 0 -- export: (Default: 0) Y position of Orbit Display -showHud = true -- export: (Default: true) Uncheck to hide the HUD and only use autopilot features via ALT+# keys. -ShowOdometer = true -- export: (Default: true) Uncheck to hide the odometer panel up top. -hideHudOnToggleWidgets = true -- export: (Default: true) Uncheck to keep showing HUD when you toggle on the widgets via ALT+3. -ShiftShowsRemoteButtons = true -- export: (Default: true) Whether or not pressing Shift in remote controller mode shows you the buttons (otherwise no access to them) -YawStallAngle = 35 --export: (Default: 35) Angle at which the ship stalls when yawing (Stabilizers: 70, Wings: 55, Ailerons: 30) -PitchStallAngle = 35 --export: (Default: 35) Angle at which the ship stalls when pitching (Stabilizers: 70, Wings: 55, Ailerons: 30) -speedChangeLarge = 5 -- export: (Default: 5) The speed change that occurs when you tap speed up/down, default is 5 (25% throttle change). -speedChangeSmall = 1 -- export: (Default: 1) the speed change that occurs while you hold speed up/down, default is 1 (5% throttle change). -brakeLandingRate = 30 -- export: (Default: 30) Max loss of altitude speed in m/s when doing a brake landing, default 30. This is to prevent "bouncing" as hover/boosters catch you. Do not use negative number. -MaxPitch = 30 -- export: (Default: 30) Maximum allowed pitch during takeoff and altitude changes while in altitude hold. You can set higher or lower depending on your ships capabilities. -ReentrySpeed = 1050 -- export: (Default: 1050) Target re-entry speed once in atmosphere in km/h. -AtmoSpeedLimit = 1050 -- export: (Default: 1050) Speed limit in Atmosphere in km/h. If you exceed this limit the ship will attempt to break till below this limit. -SpaceSpeedLimit = 30000 -- export: (Default: 30000) Space speed limit in KM/H. If you hit this speed but are not in active autopilot, engines will turn off. -ReentryAltitude = 2500 -- export: (Default: 2500) Target alititude when using re-entry. -AutoTakeoffAltitude = 1000 -- export: (Default: 1000) How high above your ground starting position AutoTakeoff tries to put you -TargetHoverHeight = 50 -- export: (Default: 50) Hover height when retracting landing gear -LandingGearGroundHeight = 0 --export: (Default: 0) Set to AGL-1 when on ground (or 0) -MaxGameVelocity = 8333.00 -- export: (Default: 8333.00) Max speed for your autopilot in m/s, do not go above 8333.055 (30000 km/hr), can be reduced to safe fuel, use 6944.4444 for 25000km/hr -TargetOrbitRadius = 1.4 -- export: (Default: 1.4) How tight you want to orbit the planet at end of autopilot. The smaller the value the tighter the orbit. 1.4 sets an Alioth orbit of 56699m. -AutopilotInterplanetaryThrottle = 1.0 -- export: (Default: 1.0) How much throttle, 0.0 to 1.0, you want it to use when in autopilot to another planet to reach MaxGameVelocity -warmup = 32 -- export: (Default: 32) How long it takes your engines to warmup. Basic Space Engines, from XS to XL: 0.25,1,4,16,32 -MouseYSensitivity = 0.003 --export: (Default: 0.003) For virtual joystick only -MouseXSensitivity = 0.003 -- export: (Default: 0.003) For virtual joystick only -autoRollPreference = false -- export: (Default: false) [Only in atmosphere]
When the pilot stops rolling, flight model will try to get back to horizontal (no roll) -autoRollFactor = 2 -- export: (Default: 2) [Only in atmosphere]
When autoRoll is engaged, this factor will increase to strength of the roll back to 0
Valid values: Superior or equal to 0.01 -rollSpeedFactor = 1.5 -- export: (Default: 1.5) This factor will increase/decrease the player input along the roll axis
(higher value may be unstable)
Valid values: Superior or equal to 0.01 -turnAssist = true -- export: (Default: true) [Only in atmosphere]
When the pilot is rolling, the flight model will try to add yaw and pitch to make the construct turn better
The flight model will start by adding more yaw the more horizontal the construct is and more pitch the more vertical it is -turnAssistFactor = 2 -- export: (Default: 2) [Only in atmosphere]
This factor will increase/decrease the turnAssist effect
(higher value may be unstable)
Valid values: Superior or equal to 0.01 -TrajectoryAlignmentStrength = 0.002 -- export: (Default: 0.002) How strongly AP tries to align your velocity vector to the target when not in orbit, recommend 0.002 -torqueFactor = 2 -- export: (Default: 2) Force factor applied to reach rotationSpeed
(higher value may be unstable)
Valid values: Superior or equal to 0.01 -pitchSpeedFactor = 0.8 -- export: (Default: 0.8) For keyboard control -yawSpeedFactor = 1 -- export: (Default: 1) For keyboard control -brakeSpeedFactor = 3 -- export: (Default: 3) When braking, this factor will increase the brake force by brakeSpeedFactor * velocity
Valid values: Superior or equal to 0.01 -brakeFlatFactor = 1 -- export: (Default: 1) When braking, this factor will increase the brake force by a flat brakeFlatFactor * velocity direction>
(higher value may be unstable)
Valid values: Superior or equal to 0.01 -DampingMultiplier = 40 -- export: (Default: 40) How strongly autopilot dampens when nearing the correct orientation -fuelTankHandlingAtmo = 0 -- export: (Default: 0) For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. -fuelTankHandlingSpace = 0 -- export: (Default: 0) For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. -fuelTankHandlingRocket = 0 -- export: (Default: 0) For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. -ContainerOptimization = 0 -- export: (Default: 0) For accurate estimates, set this to the Container Optimization level of the person who placed the tanks. Ignored for slotted tanks. -FuelTankOptimization = 0 -- export: (Default: 0) For accurate unslotted fuel tank calculation, set this to the fuel tank optimization skill level of the person who placed the tank. Ignored for slotted tanks. -ExtraLongitudeTags = "none" -- export: (Default: "none") Enter any extra longitudinal tags you use inside '' seperated by space, i.e. "forward faster major" These will be added to the engines that are control by longitude. -ExtraLateralTags = "none" -- export: (Default: "none") Enter any extra lateral tags you use inside '' seperated by space, i.e. "left right" These will be added to the engines that are control by lateral. -ExtraVerticalTags = "none" -- export: (Default: "none") Enter any extra longitudinal tags you use inside '' seperated by space, i.e. "up down" These will be added to the engines that are control by vertical. -ExternalAGG = false -- export: (Default: false) Toggle On if using an external AGG system. If on will prevent this HUD from doing anything with AGG. -UseSatNav = false -- export: (Default: false) Toggle on if using Trog SatNav script. This will provide SatNav support. -apTickRate = 0.0166667 -- export: (Default: 0.0166667) Set the Tick Rate for your autopilot features. 0.016667 is effectively 60 fps and the default value. 0.03333333 is 30 fps. -hudTickRate = 0.0666667 -- export: (Default: 0.0666667) Set the tick rate for your HUD. Default is 4 times slower than apTickRate -ShouldCheckDamage = true --export: (Default: true) Whether or not damage checks are performed. Disabled for performance on very large ships -CalculateBrakeLandingSpeed = false --export: (Default: false) Whether BrakeLanding speed at non-waypoints should be calculated or use the brakeLandingRate user setting. Only set to true for ships with low mass to lift capability. -autoRollRollThreshold = 0 --export: (Default: 0) The minimum amount of roll before autoRoll kicks in and stabilizes (if active) -AtmoSpeedAssist = true --export: (Default: true) Whether or not atmospheric speeds should be limited to a maximum of AtmoSpeedLimit -ForceAlignment = false --export: (Default: false) Whether velocity vector alignment should be forced when in Altitude Hold -minRollVelocity = 150 --export: (Default: 150) Min velocity, in m/s, over which advanced rolling can occur -VertTakeOffEngine = false --export: (Default: false) Set this to true if you have VTOL engines on your construct. Changes Auto Takeoff to Vertical Takeoff. -VertTakeOffMode = "Orbit" --export: (Default: "Orbit") Set to: "AGG" = turn on AGG when above 1km and near AGG activation height, "Orbit" = go directly to orbit based off of TargetOrbitRadius. Must keep quotes. Any case is fine. +ResolutionX = 1920 -- export: (Default: 1920) +ResolutionY = 1080 -- export: (Default: 1080) +SafeR = 130 -- export: (Default: 130) +SafeG = 224 -- export: (Default: 224) +SafeB = 255 -- export: (Default: 255) +PvPR = 255 -- export: (Default: 255) +PvPG = 0 -- export: (Default: 0) +PvPB = 0 -- export: (Default: 0) +centerX = 960 -- export: (Default: 960) +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) +altMeterX = 550 -- export: (Default: 550) +altMeterY = 540 -- export: (Default: 540) +fuelX = 100 -- export: (Default: 100) +fuelY = 350 -- export: (Default: 350) +circleRad = 400 -- export: (Default: 400) +DeadZone = 50 -- export: (Default: 50) +DisplayOrbit = true -- export: (Default: true) +OrbitMapSize = 250 -- export: (Default: 250) +OrbitMapX = 75 -- export: (Default: 75) +OrbitMapY = 0 -- export: (Default: 0) +showHud = true -- export: (Default: true) +ShowOdometer = true -- export: (Default: true) +hideHudOnToggleWidgets = true -- export: (Default: true) +ShiftShowsRemoteButtons = true -- export: (Default: true) +YawStallAngle = 35 --export: (Default: 35) +PitchStallAngle = 35 --export: (Default: 35) +speedChangeLarge = 5 -- export: (Default: 5) +speedChangeSmall = 1 -- export: (Default: 1) +brakeLandingRate = 30 -- export: (Default: 30) +MaxPitch = 30 -- export: (Default: 30) +ReentrySpeed = 1050 -- export: (Default: 1050) +AtmoSpeedLimit = 1050 -- export: (Default: 1050) +SpaceSpeedLimit = 30000 -- export: (Default: 30000). +ReentryAltitude = 2500 -- export: (Default: 2500) +AutoTakeoffAltitude = 1000 -- export: (Default: 1000) +TargetHoverHeight = 50 -- export: (Default: 50) +LandingGearGroundHeight = 0 --export: (Default: 0) +MaxGameVelocity = 8333.00 -- export: (Default: 8333.00) +TargetOrbitRadius = 1.4 -- export: (Default: 1.4) +AutopilotInterplanetaryThrottle = 1.0 -- export: (Default: 1.0) +warmup = 32 -- export: (Default: 32) +MouseYSensitivity = 0.003 --export: (Default: 0.003) +MouseXSensitivity = 0.003 -- export: (Default: 0.003) +autoRollPreference = false -- export: (Default: false) +autoRollFactor = 2 -- export: (Default: 2) +rollSpeedFactor = 1.5 -- export: (Default: 1.5) +turnAssist = true -- export: (Default: true) +turnAssistFactor = 2 -- export: (Default: 2) +TrajectoryAlignmentStrength = 0.002 -- export: (Default: 0.002) +torqueFactor = 2 -- export: (Default: 2) +pitchSpeedFactor = 0.8 -- export: (Default: 0.8) +yawSpeedFactor = 1 -- export: (Default: 1) +brakeSpeedFactor = 3 -- export: (Default: 3) +brakeFlatFactor = 1 -- export: (Default: 1) +DampingMultiplier = 40 -- export: (Default: 40) +fuelTankHandlingAtmo = 0 -- export: (Default: 0) +fuelTankHandlingSpace = 0 -- export: (Default: 0) +fuelTankHandlingRocket = 0 -- export: (Default: 0) +ContainerOptimization = 0 -- export: (Default: 0) +FuelTankOptimization = 0 -- export: (Default: 0) +ExtraLongitudeTags = "none" -- export: (Default: "none") +ExtraLateralTags = "none" -- export: (Default: "none") +ExtraVerticalTags = "none" -- export: (Default: "none") +ExternalAGG = false -- export: (Default: false) +UseSatNav = false -- export: (Default: false) +apTickRate = 0.0166667 -- export: (Default: 0.0166667) +hudTickRate = 0.0666667 -- export: (Default: 0.0666667) +ShouldCheckDamage = true --export: (Default: true) +CalculateBrakeLandingSpeed = false --export: (Default: false) +autoRollRollThreshold = 0 --export: (Default: 0) +AtmoSpeedAssist = true --export: (Default: true) +ForceAlignment = false --export: (Default: false) +minRollVelocity = 150 --export: (Default: 150) +VertTakeOffEngine = false --export: (Default: false) +VertTakeOffMode = "Orbit" --export: (Default: "Orbit") -- Auto Variable declarations that store status of ship. Must be global because they get saved/read to Databank due to using _G assignment BrakeToggleStatus = BrakeToggleDefault @@ -5541,7 +5541,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.42 + VERSION_NUMBER = 5.43 SetupComplete = false beginSetup = coroutine.create(function() Nav.axisCommandManager:setupCustomTargetSpeedRanges(axisCommandId.longitudinal, From 4b92b402f5e55d7e6fa9a013653cd03ef08ac08d Mon Sep 17 00:00:00 2001 From: archaegeo Date: Sun, 14 Mar 2021 11:56:09 -0400 Subject: [PATCH 2/2] Fix low orbit hops --- ButtonHUD.conf | 5 +-- ChangeLog.md | 3 ++ README.md | 1 - src/ButtonHUD.lua | 99 ++++++++++------------------------------------- 4 files changed, 26 insertions(+), 82 deletions(-) diff --git a/ButtonHUD.conf b/ButtonHUD.conf index 4dd1c0e..f2c89b8 100644 --- a/ButtonHUD.conf +++ b/ButtonHUD.conf @@ -188,8 +188,7 @@ handlers: ForceAlignment = false --export: (Default: false) minRollVelocity = 150 --export: (Default: 150) VertTakeOffEngine = false --export: (Default: false) - VertTakeOffMode = "Orbit" --export: (Default: "Orbit") - Nav=Navigator.new(system,core,unit)script={}BrakeToggleStatus=BrakeToggleDefault;BrakeIsOn=false;RetrogradeIsOn=false;ProgradeIsOn=false;Autopilot=false;TurnBurn=false;AltitudeHold=false;BrakeLanding=false;AutoTakeoff=false;Reentry=false;VertTakeOff=false;HoldAltitude=1000;AutopilotAccelerating=false;AutopilotRealigned=false;AutopilotBraking=false;AutopilotCruising=false;AutopilotEndSpeed=0;AutopilotStatus="Aligning"AutopilotPlanetGravity=0;PrevViewLock=1;AutopilotTargetName="None"AutopilotTargetCoords=nil;AutopilotTargetIndex=0;GearExtended=nil;TotalDistanceTravelled=0.0;TotalFlightTime=0;SavedLocations={}VectorToTarget=false;LocationIndex=0;LastMaxBrake=0;LockPitch=nil;LastMaxBrakeInAtmo=0;AntigravTargetAltitude=core.getAltitude()LastStartTime=0;SpaceTarget=false;LeftAmount=0;IntoOrbit=false;local a={"userControlScheme","TargetOrbitRadius","apTickRate","freeLookToggle","turnAssist","SafeR","SafeG","SafeB","warmup","DeadZone","circleRad","MouseXSensitivity","MouseYSensitivity","MaxGameVelocity","showHud","autoRollPreference","InvertMouse","pitchSpeedFactor","yawSpeedFactor","rollSpeedFactor","brakeSpeedFactor","brakeFlatFactor","autoRollFactor","turnAssistFactor","torqueFactor","AutoTakeoffAltitude","TargetHoverHeight","AutopilotInterplanetaryThrottle","hideHudOnToggleWidgets","DampingMultiplier","fuelTankHandlingAtmo","ExternalAGG","ShouldCheckDamage","fuelTankHandlingSpace","fuelTankHandlingRocket","RemoteFreeze","hudTickRate","speedChangeLarge","speedChangeSmall","brightHud","brakeLandingRate","MaxPitch","ReentrySpeed","AtmoSpeedLimit","ReentryAltitude","centerX","centerY","SpaceSpeedLimit","AtmoSpeedAssist","vSpdMeterX","vSpdMeterY","altMeterX","altMeterY","fuelX","fuelY","LandingGearGroundHeight","TrajectoryAlignmentStrength","RemoteHud","YawStallAngle","PitchStallAngle","ResolutionX","ResolutionY","UseSatNav","FuelTankOptimization","ContainerOptimization","ExtraLongitudeTags","ExtraLateralTags","ExtraVerticalTags","OrbitMapSize","OrbitMapX","OrbitMapY","DisplayOrbit","CalculateBrakeLandingSpeed","ForceAlignment","autoRollRollThreshold","minRollVelocity","VertTakeOffEngine","VertTakeOffMode","PvPR","PvPG","PvPB"}local b={"SpaceTarget","BrakeToggleStatus","BrakeIsOn","RetrogradeIsOn","ProgradeIsOn","Autopilot","TurnBurn","AltitudeHold","BrakeLanding","Reentry","AutoTakeoff","HoldAltitude","AutopilotAccelerating","AutopilotBraking","AutopilotCruising","AutopilotRealigned","AutopilotEndSpeed","AutopilotStatus","AutopilotPlanetGravity","PrevViewLock","AutopilotTargetName","AutopilotTargetCoords","AutopilotTargetIndex","TotalDistanceTravelled","TotalFlightTime","SavedLocations","VectorToTarget","LocationIndex","LastMaxBrake","LockPitch","LastMaxBrakeInAtmo","AntigravTargetAltitude","LastStartTime"}local c=system.print;local d=math.floor;local e=string.format;local f=json.decode;local g=json.encode;local h=core.getElementMaxHitPointsById;local j=unit.getAtmosphereDensity;local k=core.getElementHitPointsById;local l=core.getElementTypeById;local m=core.getElementMassById;local n=core.getConstructMass;local o=Nav.control.isRemoteControlled;local p=math.atan;function round(q,r)local s=10^(r or 0)return d(q*s+0.5)/s end;local t=SafeR;local u=SafeB;local v=SafeG;local w=false;local x=0;local y=""local z=0;local A=0;local B=false;local C=0;local D=false;local E=round(ResolutionX/2,0)local F=round(ResolutionY/2,0)local G=false;local H=true;local I=55;local J=false;local K=1;local L=1;local M=false;local N=0;local O=0;local P=0;local Q=0;local R=0;local S=0;local T=0;local U=false;local V=false;local W="empty"local X=5;local Y=5;local Z=false;local a0,a1=0;local a2,a3=0;local a4=nil;local a5=0;local a6=0;local a7=false;local a8=0;local a9=0;local aa=0;local ab=3;local ac=0;local ad=""local ae=""local af=0;local ag=false;local ah=false;local ai=false;local aj=-1;local ak=false;local al=""local am=j()>0;local an=core.getAltitude()local ao=core.getElementIdList()local ap=system.getTime()local aq=nil;local ar=false;local as=[[rgb(]]..d(t+0.5)..","..d(v+0.5)..","..d(u+0.5)..[[)]]local at=[[rgb(]]..d(t*0.9+0.5)..","..d(v*0.9+0.5)..","..d(u*0.9+0.5)..[[)]]local au={}local av=0;local aw=0;local ax=""local ay=true;local az={}local aA=1;local aB=0.001;local aC=ResolutionX;local aD=ResolutionY;local aE=nil;local aF=nil;local aG=nil;local aH=nil;local aI=false;local aJ=false;local aK=0;local aL=nil;local aM={}local aN={}local aO={}local aP=0;local aQ=false;local aR={}local aS={}local aT=d(1/apTickRate)*2;local aU={}local aV={}local aW={}local aX={}local aY=false;local aZ=16;local a_=0;local b0=nil;local b1=""local b2=nil;local b3=nil;local b4=nil;local b5=nil;local b6=nil;local b7=nil;local b8=nil;local b9=nil;local ba=false;local bb=false;local bc=autoRollPreference;local bd=vec3(core.getWorldVelocity())local be=vec3(bd):len()local bf=LandingGearGroundHeight;local bg=system.getMouseDeltaX()local bh=system.getMouseDeltaY()local bi=false;local bj=system.getTime()local bk=0;local bl=0;local bm=AtmoSpeedLimit;local bn=0;local bo=nil;local bp=0;local bq=0;local br=false;local bs=false;local bt=false;local bu=false;local bv=0;local bw=nil;local bx=false;local by=false;local bz=false;function LoadVariables()if dbHud_1 then local bA=dbHud_1.hasKey;if not useTheseSettings then for bB,bC in pairs(a)do if bA(bC)then local bD=f(dbHud_1.getStringValue(bC))if bD~=nil then c(bC.." "..dbHud_1.getStringValue(bC))_G[bC]=bD;aI=true end end end end;coroutine.yield()for bB,bC in pairs(b)do if bA(bC)then local bD=f(dbHud_1.getStringValue(bC))if bD~=nil then c(bC.." "..dbHud_1.getStringValue(bC))_G[bC]=bD;aI=true end end end;if useTheseSettings then W="Updated user preferences used. Will be saved when you exit seat.\nToggle off useTheseSettings to use saved values"ab=5 elseif aI then W="Loaded Saved Variables (see Lua Chat Tab for list)"else W="No Saved Variables Found - Stand up / leave remote to save settings"end else W="No databank found, install one anywhere and rerun the autoconfigure to save variables"end;local bE=system.getTime()if LastStartTime+180bG then bG=bF end;if ContainerOptimization>0 then bG=bG-bG*ContainerOptimization*0.05 end;if FuelTankOptimization>0 then bG=bG-bG*FuelTankOptimization*0.05 end;return bG end;function ProcessElements()local bH=fuelX~=0 and fuelY~=0;for bB in pairs(ao)do local type=l(ao[bB])if string.match(type,'^.*Space Engine$')then if string.match(tostring(core.getElementTagsById(ao[bB])),'^.*vertical.*$')then local bI=core.getElementRotationById(ao[bB])if bI[4]<0 then if utils.round(-bI[4],0.1)==0.5 then by=true;system.print("Space Engine Up detected")end else if utils.round(bI[4],0.1)==0.5 then bz=true;system.print("Space Engine Down detected")end end end end;if type=="Landing Gear"then M=true end;if type=="Dynamic Core Unit"then local bJ=h(ao[bB])if bJ>10000 then aZ=128 elseif bJ>1000 then aZ=64 elseif bJ>150 then aZ=32 end end;aP=aP+h(ao[bB])if bH and(type=="Atmospheric Fuel Tank"or type=="Space Fuel Tank"or type=="Rocket Fuel Tank")then local bJ=h(ao[bB])local bK=m(ao[bB])local bF=0;local bL=system.getTime()if type=="Atmospheric Fuel Tank"then local bG=400;local bM=35.03;if bJ>10000 then bG=51200;bM=5480 elseif bJ>1300 then bG=6400;bM=988.67 elseif bJ>150 then bG=1600;bM=182.67 end;bF=bK-bM;if fuelTankHandlingAtmo>0 then bG=bG+bG*fuelTankHandlingAtmo*0.2 end;bG=CalculateFuelVolume(bF,bG)aM[#aM+1]={ao[bB],core.getElementNameById(ao[bB]),bG,bM,bF,bL}end;if type=="Rocket Fuel Tank"then local bG=320;local bM=173.42;if bJ>65000 then bG=40000;bM=25740 elseif bJ>6000 then bG=5120;bM=4720 elseif bJ>700 then bG=640;bM=886.72 end;bF=bK-bM;if fuelTankHandlingRocket>0 then bG=bG+bG*fuelTankHandlingRocket*0.1 end;bG=CalculateFuelVolume(bF,bG)aO[#aO+1]={ao[bB],core.getElementNameById(ao[bB]),bG,bM,bF,bL}end;if type=="Space Fuel Tank"then local bG=2400;local bM=182.67;if bJ>10000 then bG=76800;bM=5480 elseif bJ>1300 then bG=9600;bM=988.67 end;bF=bK-bM;if fuelTankHandlingSpace>0 then bG=bG+bG*fuelTankHandlingSpace*0.2 end;bG=CalculateFuelVolume(bF,bG)aN[#aN+1]={ao[bB],core.getElementNameById(ao[bB]),bG,bM,bF,bL}end end end end;function SetupChecks()if gyro~=nil then aq=gyro.getState()==1 end;if userControlScheme~="keyboard"then system.lockView(1)else system.lockView(0)end;if radar_1 then if l(radar_1.getId())=="Space Radar"then hasSpaceRadar=true else hasAtmoRadar=true end end;local bN=j()if door and(bN>0 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;if antigrav~=nil and not ExternalAGG then if antigrav.getState()==1 then antigrav.show()end end;if o()==1 and RemoteFreeze then system.freeze(1)else system.freeze(0)end;if M then GearExtended=Nav.control.isAnyLandingGearExtended()==1;if GearExtended then Nav.control.extendLandingGears()else Nav.control.retractLandingGears()end end;local bO=AboveGroundLevel()if bO~=-1 or not am and vec3(core.getVelocity()):len()<50 then BrakeIsOn=true;if not M then GearExtended=true end else BrakeIsOn=false end;if bf~=nil then Nav.axisCommandManager:setTargetGroundAltitude(bf)if bf==0 and not M then GearExtended=true;BrakeIsOn=true end else bf=Nav:getTargetGroundAltitude()if GearExtended then Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)else Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)end end;if am and bO~=-1 then b8=core.getMaxKinematicsParametersAlongAxis("ground",core.getConstructOrientationUp())[1]end;userControlScheme=string.lower(userControlScheme)WasInAtmo=am end;function ConvertResolutionX(bC)if ResolutionX==1920 then return bC else return round(ResolutionX*bC/1920,0)end end;function ConvertResolutionY(bC)if ResolutionY==1080 then return bC else return round(ResolutionY*bC/1080,0)end end;function RefreshLastMaxBrake(bP,bQ)if bP==nil then bP=core.g()end;bP=round(bP,5)local bR=j()if bQ~=nil and bQ or(aL==nil or aL~=bP)then local bd=core.getVelocity()local bS=vec3(bd):len()local bT=f(unit.getData()).maxBrake;if bT~=nil and bT>0 and am then bT=bT/utils.clamp(bS/100,0.1,1)bT=bT/bR;if bR>0.10 then if LastMaxBrakeInAtmo then LastMaxBrakeInAtmo=(LastMaxBrakeInAtmo+bT)/2 else LastMaxBrakeInAtmo=bT end end end;if bT~=nil and bT>0 then LastMaxBrake=bT end;aL=bP end end;function MakeButton(bU,bV,bW,bX,bY,bZ,b_,c0,c1)local c2={enableName=bU,disableName=bV,width=bW,height=bX,x=bY,y=bZ,toggleVar=b_,toggleFunction=c0,drawCondition=c1,hovered=false}table.insert(az,c2)return c2 end;function UpdateAtlasLocationsList()AtlasOrdered={}for bB,bC in pairs(b0[0])do table.insert(AtlasOrdered,{name=bC.name,index=bB})end;local function c3(c4,c5)return c4.name=0 and cf or 2*math.pi+cf;cd=math.pi/2-math.acos(cb.z/ac)end;return setmetatable({latitude=math.deg(cd),longitude=math.deg(ce),altitude=cc,bodyId=c8.bodyId,systemId=c8.planetarySystemId},MapPosition)end;function zeroConvertToWorldCoordinates(cg)local q=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local ch='::pos{'..q..','..q..','..q..','..q..','..q..'}'local ci,cj,cd,ce,cc=string.match(cg,ch)if ci=="0"and cj=="0"then return vec3(tonumber(cd),tonumber(ce),tonumber(cc))end;ce=math.rad(ce)cd=math.rad(cd)local planet=b0[tonumber(ci)][tonumber(cj)]local ck=math.cos(cd)local cl=vec3(ck*math.cos(ce),ck*math.sin(ce),math.sin(cd))return planet.center+(planet.radius+cc)*cl end;function AddNewLocationByWaypoint(cm,planet,cg)if dbHud_1 then local cn={}local position=zeroConvertToWorldCoordinates(cg)if planet.name=="Space"then cn={position=position,name=cm,atmosphere=false,planetname=planet.name,gravity=planet.gravity}else local bN=false;if planet.hasAtmosphere then bN=true else bN=false end;cn={position=position,name=cm,atmosphere=bN,planetname=planet.name,gravity=planet.gravity}end;SavedLocations[#SavedLocations+1]=cn;table.insert(b0[0],cn)UpdateAtlasLocationsList()else W="Databank must be installed to save locations"end end;function AddNewLocation()if dbHud_1 then local position=vec3(core.getConstructWorldPos())local co=planet.name..". "..#SavedLocations;if radar_1 then local cp,_=radar_1.getData():match('"constructId":"([0-9]*)","distance":([%d%.]*)')if cp~=nil and cp~=""then co=co.." "..radar_1.getConstructName(cp)end end;local cn={}local bN=false;if planet.hasAtmosphere then bN=true end;cn={position=position,name=co,atmosphere=bN,planetname=planet.name,gravity=planet.gravity,safe=true}SavedLocations[#SavedLocations+1]=cn;table.insert(b0[0],cn)UpdateAtlasLocationsList()W="Location saved as "..co else W="Databank must be installed to save locations"end end;function UpdatePosition(cq)local cr=-1;local cn;for bB,bC in pairs(SavedLocations)do if bC.name and bC.name==CustomTarget.name then cr=bB;break end end;if cr~=-1 then local cs;if cq~=nil then cn={position=SavedLocations[cr].position,name=cq,atmosphere=SavedLocations[cr].atmosphere,planetname=SavedLocations[cr].planetname,gravity=SavedLocations[cr].gravity}else cn={position=vec3(core.getConstructWorldPos()),name=SavedLocations[cr].name,atmosphere=j(),planetname=planet.name,gravity=unit.getClosestPlanetInfluence(),safe=true}end;SavedLocations[cr]=cn;cr=-1;for bB,bC in pairs(b0[0])do if bC.name and bC.name==CustomTarget.name then cr=bB end end;if cr>-1 then b0[0][cr]=cn end;UpdateAtlasLocationsList()W=CustomTarget.name.." position updated"AutopilotTargetIndex=0;UpdateAutopilotTarget()else W="Name Not Found"end end;function ClearCurrentPosition()local cr=-1;for bB,bC in pairs(b0[0])do if bC.name and bC.name==CustomTarget.name then cr=bB end end;if cr>-1 then table.remove(b0[0],cr)end;cr=-1;for bB,bC in pairs(SavedLocations)do if bC.name and bC.name==CustomTarget.name then W=bC.name.." saved location cleared"cr=bB;break end end;if cr~=-1 then table.remove(SavedLocations,cr)end;DecrementAutopilotTargetIndex()UpdateAtlasLocationsList()end;function DrawDeadZone(ct)ct[#ct+1]=e([[]],DeadZone)end;function ToggleRadarPanel()if radarPanelID~=nil and af==0 then system.destroyWidgetPanel(radarPanelID)radarPanelID=nil;if perisPanelID~=nil then system.destroyWidgetPanel(perisPanelID)perisPanelID=nil end else if af==1 then system.destroyWidgetPanel(radarPanelID)radarPanelID=nil;_autoconf.displayCategoryPanel(radar,radar_size,L_TEXT("ui_lua_widget_periscope", "Periscope"),"periscope")perisPanelID=_autoconf.panels[_autoconf.panels_size]end;placeRadar=true;if radarPanelID==nil and placeRadar then _autoconf.displayCategoryPanel(radar,radar_size,L_TEXT("ui_lua_widget_radar", "Radar"),"radar")radarPanelID=_autoconf.panels[_autoconf.panels_size]placeRadar=false end;af=0 end end;function ToggleWidgets()if ay then unit.show()core.show()if atmofueltank_size>0 then _autoconf.displayCategoryPanel(atmofueltank,atmofueltank_size,L_TEXT("ui_lua_widget_atmofuel", "Atmo Fuel"),"fuel_container")fuelPanelID=_autoconf.panels[_autoconf.panels_size]end;if spacefueltank_size>0 then _autoconf.displayCategoryPanel(spacefueltank,spacefueltank_size,L_TEXT("ui_lua_widget_spacefuel", "Space Fuel"),"fuel_container")spacefuelPanelID=_autoconf.panels[_autoconf.panels_size]end;if rocketfueltank_size>0 then _autoconf.displayCategoryPanel(rocketfueltank,rocketfueltank_size,L_TEXT("ui_lua_widget_rocketfuel", "Rocket Fuel"),"fuel_container")rocketfuelPanelID=_autoconf.panels[_autoconf.panels_size]end;ay=false else unit.hide()core.hide()if fuelPanelID~=nil then system.destroyWidgetPanel(fuelPanelID)fuelPanelID=nil end;if spacefuelPanelID~=nil then system.destroyWidgetPanel(spacefuelPanelID)spacefuelPanelID=nil end;if rocketfuelPanelID~=nil then system.destroyWidgetPanel(rocketfuelPanelID)rocketfuelPanelID=nil end;ay=true end end;function SetupInterplanetaryPanel()panelInterplanetary=system.createWidgetPanel("Interplanetary Helper")interplanetaryHeader=system.createWidget(panelInterplanetary,"value")interplanetaryHeaderText=system.createData('{"label": "Target Planet", "value": "N/A", "unit":""}')system.addDataToWidget(interplanetaryHeaderText,interplanetaryHeader)widgetDistance=system.createWidget(panelInterplanetary,"value")widgetDistanceText=system.createData('{"label": "distance", "value": "N/A", "unit":""}')system.addDataToWidget(widgetDistanceText,widgetDistance)widgetTravelTime=system.createWidget(panelInterplanetary,"value")widgetTravelTimeText=system.createData('{"label": "Travel Time", "value": "N/A", "unit":""}')system.addDataToWidget(widgetTravelTimeText,widgetTravelTime)widgetMaxMass=system.createWidget(panelInterplanetary,"value")widgetMaxMassText=system.createData('{"label": "Maximum Mass", "value": "N/A", "unit":""}')system.addDataToWidget(widgetMaxMassText,widgetMaxMass)widgetCurBrakeDistance=system.createWidget(panelInterplanetary,"value")widgetCurBrakeDistanceText=system.createData('{"label": "Cur Brake distance", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;widgetCurBrakeTime=system.createWidget(panelInterplanetary,"value")widgetCurBrakeTimeText=system.createData('{"label": "Cur Brake Time", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;widgetMaxBrakeDistance=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeDistanceText=system.createData('{"label": "Max Brake distance", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;widgetMaxBrakeTime=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeTimeText=system.createData('{"label": "Max Brake Time", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;widgetTrajectoryAltitude=system.createWidget(panelInterplanetary,"value")widgetTrajectoryAltitudeText=system.createData('{"label": "Projected Altitude", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end;widgetTargetOrbit=system.createWidget(panelInterplanetary,"value")widgetTargetOrbitText=system.createData('{"label": "Target Altitude", "value": "N/A", "unit":""}')system.addDataToWidget(widgetTargetOrbitText,widgetTargetOrbit)end;function Contains(cu,cv,bY,bZ,bW,bX)if cu>bY and cubZ and cv0 then IntoOrbit=true;bx=false;CancelIntoOrbit=false;br=false;bp=nil;bq=nil;if bw==nil then bw=planet end else W="Unable to engage orbiting, not near planet"end end end;function ToggleLockPitch()if LockPitch==nil then local cw=vec3(core.getConstructWorldOrientationForward())local cx=vec3(core.getConstructWorldOrientationRight())local cy=vec3(core.getWorldVertical())local cz=getPitch(cy,cw,cx)LockPitch=cz;AutoTakeoff=false;AltitudeHold=false;BrakeLanding=false else LockPitch=nil end end;function ToggleAltitudeHold()local bE=system.getTime()if bE-bl<1.5 then if planet.hasAtmosphere then HoldAltitude=planet.spaceEngineMinAltitude-50;bl=-1;if AltitudeHold then return end end else bl=bE end;AltitudeHold=not AltitudeHold;if AltitudeHold then Autopilot=false;ProgradeIsOn=false;RetrogradeIsOn=false;U=false;BrakeLanding=false;Reentry=false;bc=true;LockPitch=nil;if hoverDetectGround()==-1 or not am then AutoTakeoff=false;if bl>-1 then HoldAltitude=an end;if not ah and Nav.axisCommandManager:getAxisCommandType(0)==0 and not AtmoSpeedAssist then Nav.control.cancelCurrentControlMasterMode()end else AutoTakeoff=true;if bl>-1 then HoldAltitude=an+AutoTakeoffAltitude end;GearExtended=false;Nav.control.retractLandingGears()BrakeIsOn=true;Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)end;if ah then HoldAltitude=100000 end else bc=autoRollPreference;AutoTakeoff=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;VectorToTarget=false end end;function ToggleFollowMode()if o()==1 then U=not U;if U then Autopilot=false;RetrogradeIsOn=false;ProgradeIsOn=false;AltitudeHold=false;Reentry=false;BrakeLanding=false;AutoTakeoff=false;OldGearExtended=GearExtended;GearExtended=false;Nav.control.retractLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)else BrakeIsOn=true;bc=autoRollPreference;GearExtended=OldGearExtended;if GearExtended then Nav.control.extendLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)end end else W="Follow Mode only works with Remote controller"U=false end end;function ToggleAutopilot()TargetSet=false;if AutopilotTargetIndex>0 and not Autopilot and not VectorToTarget and not ah then UpdateAutopilotTarget()local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)if CustomTarget~=nil then LockPitch=nil;SpaceTarget=CustomTarget.planetname=="Space"if SpaceTarget then if j()~=0 then ah=true;ToggleAltitudeHold()else Autopilot=true end elseif planet.name==CustomTarget.planetname then StrongBrakes=true;if j()>0 then bx=false;if not VectorToTarget then ToggleVectorToTarget(SpaceTarget)end else if an>100000 or an==0 then bx=false;Autopilot=true else ag=true;ProgradeIsOn=true;if AltitudeHold then ToggleAltitudeHold()end end end else RetrogradeIsOn=false;ProgradeIsOn=false;if j()~=0 then ah=true;ToggleAltitudeHold()else Autopilot=true end end elseif j()==0 then local cB=unit.getClosestPlanetInfluence()>0;if CustomTarget==nil and(a4.name==planet.name and cB)then ToggleIntoOrbit()else Autopilot=true;RetrogradeIsOn=false;ProgradeIsOn=false;AutopilotRealigned=false;U=false;AltitudeHold=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;G=false;LockPitch=nil;WaypointSet=false end else ah=true;ToggleAltitudeHold()end else ah=false;Autopilot=false;AutopilotRealigned=false;VectorToTarget=false;G=false;AutoTakeoff=false;AltitudeHold=false;VectorToTarget=false;HoldAltitude=an;TargetSet=false end end;function ProgradeToggle()ProgradeIsOn=not ProgradeIsOn;RetrogradeIsOn=false;Autopilot=false;AltitudeHold=false;U=false;BrakeLanding=false;LockPitch=nil;Reentry=false;AutoTakeoff=false end;function RetrogradeToggle()RetrogradeIsOn=not RetrogradeIsOn;ProgradeIsOn=false;Autopilot=false;AltitudeHold=false;U=false;BrakeLanding=false;LockPitch=nil;Reentry=false;AutoTakeoff=false end;function BrakeToggle()BrakeIsOn=not BrakeIsOn;if BrakeLanding then BrakeLanding=false;bc=autoRollPreference end;if BrakeIsOn then AltitudeHold=false;VectorToTarget=false;AutoTakeoff=false;VertTakeOff=false;Reentry=false;ProgradeIsOn=false;BrakeLanding=false;AutoLanding=false;AltitudeHold=false;IntoOrbit=false;LockPitch=nil;bc=autoRollPreference;ag=false;ai=false;a8=0 end end;function CheckDamage(ct)local cC=0;ax=""local cD=aP;local cE=0;local cF=0;local cG=0;local cH=0;local cI=""for bB in pairs(ao)do local bJ=0;local cJ=0;cJ=h(ao[bB])bJ=k(ao[bB])cE=cE+bJ;if bJ0 and au[11]==ao[bB]then for cL in pairs(au)do core.deleteSticker(au[cL])end;au={}end end;cC=d(cE/cD*100)if cC<100 then ct[#ct+1]=[[]]cH=d(cC*2.55)cI=e("rgb(%d,%d,%d)",255-cH,cH,0)if cC<100 then ct[#ct+1]=e([[Elemental Integrity: %i %%]],cI,cC)if cG>0 then ct[#ct+1]=e([[Disabled Modules: %i Damaged Modules: %i]],cI,cG,cF)elseif cF>0 then ct[#ct+1]=e([[Damaged Modules: %i]],cI,cF)end end;ct[#ct+1]=[[<\g>]]end end;function DrawCursorLine(ct)local cM=d(utils.clamp(ac/(aC/4)*255,0,255))ct[#ct+1]=e("",a9,aa,d(t+0.5)+cM,d(v+0.5)-cM,d(u+0.5)-cM)end;function getPitch(cN,cO,c5)local cP=cN:cross(c5):normalize_inplace()local cz=math.acos(utils.clamp(cP:dot(-cO),-1,1))*constants.rad2deg;if cP:cross(-cO):dot(c5)<0 then cz=-cz end;return cz end;local function cQ(cR,cS,cT)cS=cS:project_on_plane(cR)cT=cT:project_on_plane(cR)return p(cS:cross(cT):dot(cR),cS:dot(cT))end;function clearAll()if ak then ak=false;AutopilotAccelerating=false;AutopilotBraking=false;AutopilotCruising=false;Autopilot=false;AutopilotRealigned=false;AutopilotStatus="Aligning"RetrogradeIsOn=false;ProgradeIsOn=false;AltitudeHold=false;Reentry=false;BrakeLanding=false;BrakeIsOn=false;AutoTakeoff=false;VertTakeOff=false;U=false;G=false;ag=false;ah=false;J=false;bc=autoRollPreference;VectorToTarget=false;TurnBurn=false;aq=false;LockPitch=nil else ak=true end end;function wipeSaveVariables()if not dbHud_1 then W="No Databank Found, unable to wipe. \nYou must have a Databank attached to ship prior to running the HUD autoconfigure"ab=5 else if aJ then for bB,bC in pairs(a)do dbHud_1.setStringValue(bC,g(nil))end;for bB,bC in pairs(b)do if bC~="SavedLocations"then dbHud_1.setStringValue(bC,g(nil))end end;W="Databank wiped. New variables will save after re-enter seat and exit"ab=5;aJ=false;aI=false;a7=true else W="Press ALT-7 again to confirm wipe of ALL data"aJ=true end end end;function CheckButtons()for _,bC in pairs(az)do if bC.hovered then if not bC.drawCondition or bC.drawCondition()then bC.toggleFunction()end;bC.hovered=false end end end;function SetButtonContains()local bY=a9+aC/2;local bZ=aa+aD/2;for _,bC in pairs(az)do bC.hovered=Contains(bY,bZ,bC.x,bC.y,bC.width,bC.height)end end;function DrawButton(ct,cU,hover,bY,bZ,cV,cW,cX,cY,cZ,c_)if type(cZ)=="function"then cZ=cZ()end;if type(c_)=="function"then c_=c_()end;ct[#ct+1]=e(""if cU then ct[#ct+1]=e("%s",cZ)else ct[#ct+1]=e("%s",c_)end end;function DrawButtons(ct)local d0="rgb(50,50,50)'"local d1="rgb(210,200,200)"local d2=DrawButton;for _,bC in pairs(az)do local bV=bC.disableName;local bU=bC.enableName;if type(bV)=="function"then bV=bV()end;if type(bU)=="function"then bU=bU()end;if not bC.drawCondition or bC.drawCondition()then d2(ct,bC.toggleVar(),bC.hovered,bC.x,bC.y,bC.width,bC.height,d1,d0,bV,bU)end end end;function DrawTank(ct,aY,bY,d3,d4,d5,d6,d7)local d8=1;local d9=2;local da=3;local db=4;local dc=5;local dd=6;local de=""local df=0;local dg=fuelY;local dh=fuelY+10;if o()==1 and not RemoteHud then dg=dg-50;dh=dh-50 end;ct[#ct+1]=[[]]if d4=="ATMO"then de="atmofueltank"elseif d4=="SPACE"then de="spacefueltank"else de="rocketfueltank"end;df=_G[de.."_size"]if#d5>0 then for i=1,#d5 do local co=string.sub(d5[i][d9],1,12)local di=0;for cL=1,df do if d5[i][d9]==f(unit[de.."_"..cL].getData()).name then di=cL;break end end;if aY or d6[i]==nil or d7[i]==nil then local dj=0;local dk=0;local dl=0;local dm=0;local bL=system.getTime()if di~=0 then d7[i]=f(unit[de.."_"..di].getData()).percentage;d6[i]=f(unit[de.."_"..di].getData()).timeLeft;if d6[i]=="n/a"then d6[i]=0 end else dl=m(d5[i][d8])-d5[i][db]dj=d5[i][da]d7[i]=d(0.5+dl*100/dj)dk=d5[i][dc]dm=d5[i][dd]if dk<=dl then d6[i]=0 else d6[i]=d(0.5+dl/((dk-dl)/(bL-dm)))end;d5[i][dc]=dl;d5[i][dd]=bL end end;if co==d3 then co=e("%s %d",d4,i)end;if di==0 then co=co.." *"end;local dn;if d6[i]==0 then dn="n/a"else dn=FormatTimeString(d6[i])end;if d7[i]~=nil then local cH=d(d7[i]*2.55)local cI=e("rgb(%d,%d,%d)",255-cH,cH,0)local dp=""if dn~="n/a"and d6[i]<120 or d7[i]<5 then if aY then dp=[[class="red"]]end end;ct[#ct+1]=e([[ + Nav=Navigator.new(system,core,unit)script={}BrakeToggleStatus=BrakeToggleDefault;BrakeIsOn=false;RetrogradeIsOn=false;ProgradeIsOn=false;Autopilot=false;TurnBurn=false;AltitudeHold=false;BrakeLanding=false;AutoTakeoff=false;Reentry=false;VertTakeOff=false;HoldAltitude=1000;AutopilotAccelerating=false;AutopilotRealigned=false;AutopilotBraking=false;AutopilotCruising=false;AutopilotEndSpeed=0;AutopilotStatus="Aligning"AutopilotPlanetGravity=0;PrevViewLock=1;AutopilotTargetName="None"AutopilotTargetCoords=nil;AutopilotTargetIndex=0;GearExtended=nil;TotalDistanceTravelled=0.0;TotalFlightTime=0;SavedLocations={}VectorToTarget=false;LocationIndex=0;LastMaxBrake=0;LockPitch=nil;LastMaxBrakeInAtmo=0;AntigravTargetAltitude=core.getAltitude()LastStartTime=0;SpaceTarget=false;LeftAmount=0;IntoOrbit=false;local a={"userControlScheme","TargetOrbitRadius","apTickRate","freeLookToggle","turnAssist","SafeR","SafeG","SafeB","warmup","DeadZone","circleRad","MouseXSensitivity","MouseYSensitivity","MaxGameVelocity","showHud","autoRollPreference","InvertMouse","pitchSpeedFactor","yawSpeedFactor","rollSpeedFactor","brakeSpeedFactor","brakeFlatFactor","autoRollFactor","turnAssistFactor","torqueFactor","AutoTakeoffAltitude","TargetHoverHeight","AutopilotInterplanetaryThrottle","hideHudOnToggleWidgets","DampingMultiplier","fuelTankHandlingAtmo","ExternalAGG","ShouldCheckDamage","fuelTankHandlingSpace","fuelTankHandlingRocket","RemoteFreeze","hudTickRate","speedChangeLarge","speedChangeSmall","brightHud","brakeLandingRate","MaxPitch","ReentrySpeed","AtmoSpeedLimit","ReentryAltitude","centerX","centerY","SpaceSpeedLimit","AtmoSpeedAssist","vSpdMeterX","vSpdMeterY","altMeterX","altMeterY","fuelX","fuelY","LandingGearGroundHeight","TrajectoryAlignmentStrength","RemoteHud","YawStallAngle","PitchStallAngle","ResolutionX","ResolutionY","UseSatNav","FuelTankOptimization","ContainerOptimization","ExtraLongitudeTags","ExtraLateralTags","ExtraVerticalTags","OrbitMapSize","OrbitMapX","OrbitMapY","DisplayOrbit","CalculateBrakeLandingSpeed","ForceAlignment","autoRollRollThreshold","minRollVelocity","VertTakeOffEngine","PvPR","PvPG","PvPB"}local b={"SpaceTarget","BrakeToggleStatus","BrakeIsOn","RetrogradeIsOn","ProgradeIsOn","Autopilot","TurnBurn","AltitudeHold","BrakeLanding","Reentry","AutoTakeoff","HoldAltitude","AutopilotAccelerating","AutopilotBraking","AutopilotCruising","AutopilotRealigned","AutopilotEndSpeed","AutopilotStatus","AutopilotPlanetGravity","PrevViewLock","AutopilotTargetName","AutopilotTargetCoords","AutopilotTargetIndex","TotalDistanceTravelled","TotalFlightTime","SavedLocations","VectorToTarget","LocationIndex","LastMaxBrake","LockPitch","LastMaxBrakeInAtmo","AntigravTargetAltitude","LastStartTime"}local c=system.print;local d=math.floor;local e=string.format;local f=json.decode;local g=json.encode;local h=core.getElementMaxHitPointsById;local j=unit.getAtmosphereDensity;local k=core.getElementHitPointsById;local l=core.getElementTypeById;local m=core.getElementMassById;local n=core.getConstructMass;local o=Nav.control.isRemoteControlled;local p=math.atan;function round(q,r)local s=10^(r or 0)return d(q*s+0.5)/s end;local t=SafeR;local u=SafeB;local v=SafeG;local w=false;local x=0;local y=""local z=0;local A=0;local B=false;local C=0;local D=false;local E=round(ResolutionX/2,0)local F=round(ResolutionY/2,0)local G=false;local H=true;local I=55;local J=false;local K=1;local L=1;local M=false;local N=0;local O=0;local P=0;local Q=0;local R=0;local S=0;local T=0;local U=false;local V=false;local W="empty"local X=5;local Y=5;local Z=false;local a0,a1=0;local a2,a3=0;local a4=nil;local a5=0;local a6=0;local a7=false;local a8=0;local a9=0;local aa=0;local ab=3;local ac=0;local ad=""local ae=""local af=0;local ag=false;local ah=false;local ai=false;local aj=-1;local ak=false;local al=""local am=j()>0;local an=core.getAltitude()local ao=core.getElementIdList()local ap=system.getTime()local aq=nil;local ar=false;local as=[[rgb(]]..d(t+0.5)..","..d(v+0.5)..","..d(u+0.5)..[[)]]local at=[[rgb(]]..d(t*0.9+0.5)..","..d(v*0.9+0.5)..","..d(u*0.9+0.5)..[[)]]local au={}local av=0;local aw=0;local ax=""local ay=true;local az={}local aA=1;local aB=0.001;local aC=ResolutionX;local aD=ResolutionY;local aE=nil;local aF=nil;local aG=nil;local aH=nil;local aI=false;local aJ=false;local aK=0;local aL=nil;local aM={}local aN={}local aO={}local aP=0;local aQ=false;local aR={}local aS={}local aT=d(1/apTickRate)*2;local aU={}local aV={}local aW={}local aX={}local aY=false;local aZ=16;local a_=0;local b0=nil;local b1=""local b2=nil;local b3=nil;local b4=nil;local b5=nil;local b6=nil;local b7=nil;local b8=nil;local b9=nil;local ba=false;local bb=false;local bc=autoRollPreference;local bd=vec3(core.getWorldVelocity())local be=vec3(bd):len()local bf=LandingGearGroundHeight;local bg=system.getMouseDeltaX()local bh=system.getMouseDeltaY()local bi=false;local bj=system.getTime()local bk=0;local bl=0;local bm=AtmoSpeedLimit;local bn=0;local bo=nil;local bp=0;local bq=0;local br=false;local bs=false;local bt=false;local bu=false;local bv=0;local bw=nil;local bx=false;local by=false;local bz=false;function LoadVariables()if dbHud_1 then local bA=dbHud_1.hasKey;if not useTheseSettings then for bB,bC in pairs(a)do if bA(bC)then local bD=f(dbHud_1.getStringValue(bC))if bD~=nil then c(bC.." "..dbHud_1.getStringValue(bC))_G[bC]=bD;aI=true end end end end;coroutine.yield()for bB,bC in pairs(b)do if bA(bC)then local bD=f(dbHud_1.getStringValue(bC))if bD~=nil then c(bC.." "..dbHud_1.getStringValue(bC))_G[bC]=bD;aI=true end end end;if useTheseSettings then W="Updated user preferences used. Will be saved when you exit seat.\nToggle off useTheseSettings to use saved values"ab=5 elseif aI then W="Loaded Saved Variables (see Lua Chat Tab for list)"else W="No Saved Variables Found - Stand up / leave remote to save settings"end else W="No databank found, install one anywhere and rerun the autoconfigure to save variables"end;local bE=system.getTime()if LastStartTime+180bG then bG=bF end;if ContainerOptimization>0 then bG=bG-bG*ContainerOptimization*0.05 end;if FuelTankOptimization>0 then bG=bG-bG*FuelTankOptimization*0.05 end;return bG end;function ProcessElements()local bH=fuelX~=0 and fuelY~=0;for bB in pairs(ao)do local type=l(ao[bB])if string.match(type,'^.*Space Engine$')then if string.match(tostring(core.getElementTagsById(ao[bB])),'^.*vertical.*$')then local bI=core.getElementRotationById(ao[bB])if bI[4]<0 then if utils.round(-bI[4],0.1)==0.5 then by=true;system.print("Space Engine Up detected")end else if utils.round(bI[4],0.1)==0.5 then bz=true;system.print("Space Engine Down detected")end end end end;if type=="Landing Gear"then M=true end;if type=="Dynamic Core Unit"then local bJ=h(ao[bB])if bJ>10000 then aZ=128 elseif bJ>1000 then aZ=64 elseif bJ>150 then aZ=32 end end;aP=aP+h(ao[bB])if bH and(type=="Atmospheric Fuel Tank"or type=="Space Fuel Tank"or type=="Rocket Fuel Tank")then local bJ=h(ao[bB])local bK=m(ao[bB])local bF=0;local bL=system.getTime()if type=="Atmospheric Fuel Tank"then local bG=400;local bM=35.03;if bJ>10000 then bG=51200;bM=5480 elseif bJ>1300 then bG=6400;bM=988.67 elseif bJ>150 then bG=1600;bM=182.67 end;bF=bK-bM;if fuelTankHandlingAtmo>0 then bG=bG+bG*fuelTankHandlingAtmo*0.2 end;bG=CalculateFuelVolume(bF,bG)aM[#aM+1]={ao[bB],core.getElementNameById(ao[bB]),bG,bM,bF,bL}end;if type=="Rocket Fuel Tank"then local bG=320;local bM=173.42;if bJ>65000 then bG=40000;bM=25740 elseif bJ>6000 then bG=5120;bM=4720 elseif bJ>700 then bG=640;bM=886.72 end;bF=bK-bM;if fuelTankHandlingRocket>0 then bG=bG+bG*fuelTankHandlingRocket*0.1 end;bG=CalculateFuelVolume(bF,bG)aO[#aO+1]={ao[bB],core.getElementNameById(ao[bB]),bG,bM,bF,bL}end;if type=="Space Fuel Tank"then local bG=2400;local bM=182.67;if bJ>10000 then bG=76800;bM=5480 elseif bJ>1300 then bG=9600;bM=988.67 end;bF=bK-bM;if fuelTankHandlingSpace>0 then bG=bG+bG*fuelTankHandlingSpace*0.2 end;bG=CalculateFuelVolume(bF,bG)aN[#aN+1]={ao[bB],core.getElementNameById(ao[bB]),bG,bM,bF,bL}end end end end;function SetupChecks()if gyro~=nil then aq=gyro.getState()==1 end;if userControlScheme~="keyboard"then system.lockView(1)else system.lockView(0)end;if radar_1 then if l(radar_1.getId())=="Space Radar"then hasSpaceRadar=true else hasAtmoRadar=true end end;local bN=j()if door and(bN>0 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;if antigrav~=nil and not ExternalAGG then if antigrav.getState()==1 then antigrav.show()end end;if o()==1 and RemoteFreeze then system.freeze(1)else system.freeze(0)end;if M then GearExtended=Nav.control.isAnyLandingGearExtended()==1;if GearExtended then Nav.control.extendLandingGears()else Nav.control.retractLandingGears()end end;local bO=AboveGroundLevel()if bO~=-1 or not am and vec3(core.getVelocity()):len()<50 then BrakeIsOn=true;if not M then GearExtended=true end else BrakeIsOn=false end;if bf~=nil then Nav.axisCommandManager:setTargetGroundAltitude(bf)if bf==0 and not M then GearExtended=true;BrakeIsOn=true end else bf=Nav:getTargetGroundAltitude()if GearExtended then Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)else Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)end end;if am and bO~=-1 then b8=core.getMaxKinematicsParametersAlongAxis("ground",core.getConstructOrientationUp())[1]end;userControlScheme=string.lower(userControlScheme)WasInAtmo=am end;function ConvertResolutionX(bC)if ResolutionX==1920 then return bC else return round(ResolutionX*bC/1920,0)end end;function ConvertResolutionY(bC)if ResolutionY==1080 then return bC else return round(ResolutionY*bC/1080,0)end end;function RefreshLastMaxBrake(bP,bQ)if bP==nil then bP=core.g()end;bP=round(bP,5)local bR=j()if bQ~=nil and bQ or(aL==nil or aL~=bP)then local bd=core.getVelocity()local bS=vec3(bd):len()local bT=f(unit.getData()).maxBrake;if bT~=nil and bT>0 and am then bT=bT/utils.clamp(bS/100,0.1,1)bT=bT/bR;if bR>0.10 then if LastMaxBrakeInAtmo then LastMaxBrakeInAtmo=(LastMaxBrakeInAtmo+bT)/2 else LastMaxBrakeInAtmo=bT end end end;if bT~=nil and bT>0 then LastMaxBrake=bT end;aL=bP end end;function MakeButton(bU,bV,bW,bX,bY,bZ,b_,c0,c1)local c2={enableName=bU,disableName=bV,width=bW,height=bX,x=bY,y=bZ,toggleVar=b_,toggleFunction=c0,drawCondition=c1,hovered=false}table.insert(az,c2)return c2 end;function UpdateAtlasLocationsList()AtlasOrdered={}for bB,bC in pairs(b0[0])do table.insert(AtlasOrdered,{name=bC.name,index=bB})end;local function c3(c4,c5)return c4.name=0 and cf or 2*math.pi+cf;cd=math.pi/2-math.acos(cb.z/ac)end;return setmetatable({latitude=math.deg(cd),longitude=math.deg(ce),altitude=cc,bodyId=c8.bodyId,systemId=c8.planetarySystemId},MapPosition)end;function zeroConvertToWorldCoordinates(cg)local q=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local ch='::pos{'..q..','..q..','..q..','..q..','..q..'}'local ci,cj,cd,ce,cc=string.match(cg,ch)if ci=="0"and cj=="0"then return vec3(tonumber(cd),tonumber(ce),tonumber(cc))end;ce=math.rad(ce)cd=math.rad(cd)local planet=b0[tonumber(ci)][tonumber(cj)]local ck=math.cos(cd)local cl=vec3(ck*math.cos(ce),ck*math.sin(ce),math.sin(cd))return planet.center+(planet.radius+cc)*cl end;function AddNewLocationByWaypoint(cm,planet,cg)if dbHud_1 then local cn={}local position=zeroConvertToWorldCoordinates(cg)if planet.name=="Space"then cn={position=position,name=cm,atmosphere=false,planetname=planet.name,gravity=planet.gravity}else local bN=false;if planet.hasAtmosphere then bN=true else bN=false end;cn={position=position,name=cm,atmosphere=bN,planetname=planet.name,gravity=planet.gravity}end;SavedLocations[#SavedLocations+1]=cn;table.insert(b0[0],cn)UpdateAtlasLocationsList()else W="Databank must be installed to save locations"end end;function AddNewLocation()if dbHud_1 then local position=vec3(core.getConstructWorldPos())local co=planet.name..". "..#SavedLocations;if radar_1 then local cp,_=radar_1.getData():match('"constructId":"([0-9]*)","distance":([%d%.]*)')if cp~=nil and cp~=""then co=co.." "..radar_1.getConstructName(cp)end end;local cn={}local bN=false;if planet.hasAtmosphere then bN=true end;cn={position=position,name=co,atmosphere=bN,planetname=planet.name,gravity=planet.gravity,safe=true}SavedLocations[#SavedLocations+1]=cn;table.insert(b0[0],cn)UpdateAtlasLocationsList()W="Location saved as "..co else W="Databank must be installed to save locations"end end;function UpdatePosition(cq)local cr=-1;local cn;for bB,bC in pairs(SavedLocations)do if bC.name and bC.name==CustomTarget.name then cr=bB;break end end;if cr~=-1 then local cs;if cq~=nil then cn={position=SavedLocations[cr].position,name=cq,atmosphere=SavedLocations[cr].atmosphere,planetname=SavedLocations[cr].planetname,gravity=SavedLocations[cr].gravity}else cn={position=vec3(core.getConstructWorldPos()),name=SavedLocations[cr].name,atmosphere=j(),planetname=planet.name,gravity=unit.getClosestPlanetInfluence(),safe=true}end;SavedLocations[cr]=cn;cr=-1;for bB,bC in pairs(b0[0])do if bC.name and bC.name==CustomTarget.name then cr=bB end end;if cr>-1 then b0[0][cr]=cn end;UpdateAtlasLocationsList()W=CustomTarget.name.." position updated"AutopilotTargetIndex=0;UpdateAutopilotTarget()else W="Name Not Found"end end;function ClearCurrentPosition()local cr=-1;for bB,bC in pairs(b0[0])do if bC.name and bC.name==CustomTarget.name then cr=bB end end;if cr>-1 then table.remove(b0[0],cr)end;cr=-1;for bB,bC in pairs(SavedLocations)do if bC.name and bC.name==CustomTarget.name then W=bC.name.." saved location cleared"cr=bB;break end end;if cr~=-1 then table.remove(SavedLocations,cr)end;DecrementAutopilotTargetIndex()UpdateAtlasLocationsList()end;function DrawDeadZone(ct)ct[#ct+1]=e([[]],DeadZone)end;function ToggleRadarPanel()if radarPanelID~=nil and af==0 then system.destroyWidgetPanel(radarPanelID)radarPanelID=nil;if perisPanelID~=nil then system.destroyWidgetPanel(perisPanelID)perisPanelID=nil end else if af==1 then system.destroyWidgetPanel(radarPanelID)radarPanelID=nil;_autoconf.displayCategoryPanel(radar,radar_size,L_TEXT("ui_lua_widget_periscope", "Periscope"),"periscope")perisPanelID=_autoconf.panels[_autoconf.panels_size]end;placeRadar=true;if radarPanelID==nil and placeRadar then _autoconf.displayCategoryPanel(radar,radar_size,L_TEXT("ui_lua_widget_radar", "Radar"),"radar")radarPanelID=_autoconf.panels[_autoconf.panels_size]placeRadar=false end;af=0 end end;function ToggleWidgets()if ay then unit.show()core.show()if atmofueltank_size>0 then _autoconf.displayCategoryPanel(atmofueltank,atmofueltank_size,L_TEXT("ui_lua_widget_atmofuel", "Atmo Fuel"),"fuel_container")fuelPanelID=_autoconf.panels[_autoconf.panels_size]end;if spacefueltank_size>0 then _autoconf.displayCategoryPanel(spacefueltank,spacefueltank_size,L_TEXT("ui_lua_widget_spacefuel", "Space Fuel"),"fuel_container")spacefuelPanelID=_autoconf.panels[_autoconf.panels_size]end;if rocketfueltank_size>0 then _autoconf.displayCategoryPanel(rocketfueltank,rocketfueltank_size,L_TEXT("ui_lua_widget_rocketfuel", "Rocket Fuel"),"fuel_container")rocketfuelPanelID=_autoconf.panels[_autoconf.panels_size]end;ay=false else unit.hide()core.hide()if fuelPanelID~=nil then system.destroyWidgetPanel(fuelPanelID)fuelPanelID=nil end;if spacefuelPanelID~=nil then system.destroyWidgetPanel(spacefuelPanelID)spacefuelPanelID=nil end;if rocketfuelPanelID~=nil then system.destroyWidgetPanel(rocketfuelPanelID)rocketfuelPanelID=nil end;ay=true end end;function SetupInterplanetaryPanel()panelInterplanetary=system.createWidgetPanel("Interplanetary Helper")interplanetaryHeader=system.createWidget(panelInterplanetary,"value")interplanetaryHeaderText=system.createData('{"label": "Target Planet", "value": "N/A", "unit":""}')system.addDataToWidget(interplanetaryHeaderText,interplanetaryHeader)widgetDistance=system.createWidget(panelInterplanetary,"value")widgetDistanceText=system.createData('{"label": "distance", "value": "N/A", "unit":""}')system.addDataToWidget(widgetDistanceText,widgetDistance)widgetTravelTime=system.createWidget(panelInterplanetary,"value")widgetTravelTimeText=system.createData('{"label": "Travel Time", "value": "N/A", "unit":""}')system.addDataToWidget(widgetTravelTimeText,widgetTravelTime)widgetMaxMass=system.createWidget(panelInterplanetary,"value")widgetMaxMassText=system.createData('{"label": "Maximum Mass", "value": "N/A", "unit":""}')system.addDataToWidget(widgetMaxMassText,widgetMaxMass)widgetCurBrakeDistance=system.createWidget(panelInterplanetary,"value")widgetCurBrakeDistanceText=system.createData('{"label": "Cur Brake distance", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;widgetCurBrakeTime=system.createWidget(panelInterplanetary,"value")widgetCurBrakeTimeText=system.createData('{"label": "Cur Brake Time", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;widgetMaxBrakeDistance=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeDistanceText=system.createData('{"label": "Max Brake distance", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;widgetMaxBrakeTime=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeTimeText=system.createData('{"label": "Max Brake Time", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;widgetTrajectoryAltitude=system.createWidget(panelInterplanetary,"value")widgetTrajectoryAltitudeText=system.createData('{"label": "Projected Altitude", "value": "N/A", "unit":""}')if not am then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end;widgetTargetOrbit=system.createWidget(panelInterplanetary,"value")widgetTargetOrbitText=system.createData('{"label": "Target Altitude", "value": "N/A", "unit":""}')system.addDataToWidget(widgetTargetOrbitText,widgetTargetOrbit)end;function Contains(cu,cv,bY,bZ,bW,bX)if cu>bY and cubZ and cv0 then IntoOrbit=true;bx=false;CancelIntoOrbit=false;br=false;bp=nil;bq=nil;if bw==nil then bw=planet end else W="Unable to engage orbiting, not near planet"end end end;function ToggleLockPitch()if LockPitch==nil then local cw=vec3(core.getConstructWorldOrientationForward())local cx=vec3(core.getConstructWorldOrientationRight())local cy=vec3(core.getWorldVertical())local cz=getPitch(cy,cw,cx)LockPitch=cz;AutoTakeoff=false;AltitudeHold=false;BrakeLanding=false else LockPitch=nil end end;function ToggleAltitudeHold()local bE=system.getTime()if bE-bl<1.5 then if planet.hasAtmosphere then HoldAltitude=planet.spaceEngineMinAltitude-50;bl=-1;if AltitudeHold then return end end else bl=bE end;AltitudeHold=not AltitudeHold;if AltitudeHold then Autopilot=false;ProgradeIsOn=false;RetrogradeIsOn=false;U=false;BrakeLanding=false;Reentry=false;bc=true;LockPitch=nil;if hoverDetectGround()==-1 or not am then AutoTakeoff=false;if bl>-1 then HoldAltitude=an end;if not ah and Nav.axisCommandManager:getAxisCommandType(0)==0 and not AtmoSpeedAssist then Nav.control.cancelCurrentControlMasterMode()end else AutoTakeoff=true;if bl>-1 then HoldAltitude=an+AutoTakeoffAltitude end;GearExtended=false;Nav.control.retractLandingGears()BrakeIsOn=true;Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)end;if ah then HoldAltitude=100000 end else bc=autoRollPreference;AutoTakeoff=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;VectorToTarget=false end end;function ToggleFollowMode()if o()==1 then U=not U;if U then Autopilot=false;RetrogradeIsOn=false;ProgradeIsOn=false;AltitudeHold=false;Reentry=false;BrakeLanding=false;AutoTakeoff=false;OldGearExtended=GearExtended;GearExtended=false;Nav.control.retractLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)else BrakeIsOn=true;bc=autoRollPreference;GearExtended=OldGearExtended;if GearExtended then Nav.control.extendLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)end end else W="Follow Mode only works with Remote controller"U=false end end;function ToggleAutopilot()TargetSet=false;if AutopilotTargetIndex>0 and not Autopilot and not VectorToTarget and not ah then UpdateAutopilotTarget()local cA=zeroConvertToMapPosition(a4,AutopilotTargetCoords)cA="::pos{"..cA.systemId..","..cA.bodyId..","..cA.latitude..","..cA.longitude..","..cA.altitude.."}"system.setWaypoint(cA)if CustomTarget~=nil then LockPitch=nil;SpaceTarget=CustomTarget.planetname=="Space"if SpaceTarget then if j()~=0 then ah=true;ToggleAltitudeHold()else Autopilot=true end elseif planet.name==CustomTarget.planetname then StrongBrakes=true;if j()>0 then bx=false;if not VectorToTarget then ToggleVectorToTarget(SpaceTarget)end else if an>100000 or an==0 then bx=false;Autopilot=true else ag=true;ProgradeIsOn=true;if AltitudeHold then ToggleAltitudeHold()end end end else RetrogradeIsOn=false;ProgradeIsOn=false;if j()~=0 then ah=true;ToggleAltitudeHold()else Autopilot=true end end elseif j()==0 then local cB=unit.getClosestPlanetInfluence()>0;if CustomTarget==nil and(a4.name==planet.name and cB)then ToggleIntoOrbit()else Autopilot=true;RetrogradeIsOn=false;ProgradeIsOn=false;AutopilotRealigned=false;U=false;AltitudeHold=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;G=false;LockPitch=nil;WaypointSet=false end else ah=true;ToggleAltitudeHold()end else ah=false;Autopilot=false;AutopilotRealigned=false;VectorToTarget=false;G=false;AutoTakeoff=false;AltitudeHold=false;VectorToTarget=false;HoldAltitude=an;TargetSet=false end end;function ProgradeToggle()ProgradeIsOn=not ProgradeIsOn;RetrogradeIsOn=false;Autopilot=false;AltitudeHold=false;U=false;BrakeLanding=false;LockPitch=nil;Reentry=false;AutoTakeoff=false end;function RetrogradeToggle()RetrogradeIsOn=not RetrogradeIsOn;ProgradeIsOn=false;Autopilot=false;AltitudeHold=false;U=false;BrakeLanding=false;LockPitch=nil;Reentry=false;AutoTakeoff=false end;function BrakeToggle()BrakeIsOn=not BrakeIsOn;if BrakeLanding then BrakeLanding=false;bc=autoRollPreference end;if BrakeIsOn then AltitudeHold=false;VectorToTarget=false;AutoTakeoff=false;VertTakeOff=false;Reentry=false;ProgradeIsOn=false;BrakeLanding=false;AutoLanding=false;AltitudeHold=false;IntoOrbit=false;LockPitch=nil;bc=autoRollPreference;ag=false;ai=false;a8=0 end end;function CheckDamage(ct)local cC=0;ax=""local cD=aP;local cE=0;local cF=0;local cG=0;local cH=0;local cI=""for bB in pairs(ao)do local bJ=0;local cJ=0;cJ=h(ao[bB])bJ=k(ao[bB])cE=cE+bJ;if bJ0 and au[11]==ao[bB]then for cL in pairs(au)do core.deleteSticker(au[cL])end;au={}end end;cC=d(cE/cD*100)if cC<100 then ct[#ct+1]=[[]]cH=d(cC*2.55)cI=e("rgb(%d,%d,%d)",255-cH,cH,0)if cC<100 then ct[#ct+1]=e([[Elemental Integrity: %i %%]],cI,cC)if cG>0 then ct[#ct+1]=e([[Disabled Modules: %i Damaged Modules: %i]],cI,cG,cF)elseif cF>0 then ct[#ct+1]=e([[Damaged Modules: %i]],cI,cF)end end;ct[#ct+1]=[[<\g>]]end end;function DrawCursorLine(ct)local cM=d(utils.clamp(ac/(aC/4)*255,0,255))ct[#ct+1]=e("",a9,aa,d(t+0.5)+cM,d(v+0.5)-cM,d(u+0.5)-cM)end;function getPitch(cN,cO,c5)local cP=cN:cross(c5):normalize_inplace()local cz=math.acos(utils.clamp(cP:dot(-cO),-1,1))*constants.rad2deg;if cP:cross(-cO):dot(c5)<0 then cz=-cz end;return cz end;local function cQ(cR,cS,cT)cS=cS:project_on_plane(cR)cT=cT:project_on_plane(cR)return p(cS:cross(cT):dot(cR),cS:dot(cT))end;function clearAll()if ak then ak=false;AutopilotAccelerating=false;AutopilotBraking=false;AutopilotCruising=false;Autopilot=false;AutopilotRealigned=false;AutopilotStatus="Aligning"RetrogradeIsOn=false;ProgradeIsOn=false;AltitudeHold=false;Reentry=false;BrakeLanding=false;BrakeIsOn=false;AutoTakeoff=false;VertTakeOff=false;U=false;G=false;ag=false;ah=false;J=false;bc=autoRollPreference;VectorToTarget=false;TurnBurn=false;aq=false;LockPitch=nil else ak=true end end;function wipeSaveVariables()if not dbHud_1 then W="No Databank Found, unable to wipe. \nYou must have a Databank attached to ship prior to running the HUD autoconfigure"ab=5 else if aJ then for bB,bC in pairs(a)do dbHud_1.setStringValue(bC,g(nil))end;for bB,bC in pairs(b)do if bC~="SavedLocations"then dbHud_1.setStringValue(bC,g(nil))end end;W="Databank wiped. New variables will save after re-enter seat and exit"ab=5;aJ=false;aI=false;a7=true else W="Press ALT-7 again to confirm wipe of ALL data"aJ=true end end end;function CheckButtons()for _,bC in pairs(az)do if bC.hovered then if not bC.drawCondition or bC.drawCondition()then bC.toggleFunction()end;bC.hovered=false end end end;function SetButtonContains()local bY=a9+aC/2;local bZ=aa+aD/2;for _,bC in pairs(az)do bC.hovered=Contains(bY,bZ,bC.x,bC.y,bC.width,bC.height)end end;function DrawButton(ct,cU,hover,bY,bZ,cV,cW,cX,cY,cZ,c_)if type(cZ)=="function"then cZ=cZ()end;if type(c_)=="function"then c_=c_()end;ct[#ct+1]=e(""if cU then ct[#ct+1]=e("%s",cZ)else ct[#ct+1]=e("%s",c_)end end;function DrawButtons(ct)local d0="rgb(50,50,50)'"local d1="rgb(210,200,200)"local d2=DrawButton;for _,bC in pairs(az)do local bV=bC.disableName;local bU=bC.enableName;if type(bV)=="function"then bV=bV()end;if type(bU)=="function"then bU=bU()end;if not bC.drawCondition or bC.drawCondition()then d2(ct,bC.toggleVar(),bC.hovered,bC.x,bC.y,bC.width,bC.height,d1,d0,bV,bU)end end end;function DrawTank(ct,aY,bY,d3,d4,d5,d6,d7)local d8=1;local d9=2;local da=3;local db=4;local dc=5;local dd=6;local de=""local df=0;local dg=fuelY;local dh=fuelY+10;if o()==1 and not RemoteHud then dg=dg-50;dh=dh-50 end;ct[#ct+1]=[[]]if d4=="ATMO"then de="atmofueltank"elseif d4=="SPACE"then de="spacefueltank"else de="rocketfueltank"end;df=_G[de.."_size"]if#d5>0 then for i=1,#d5 do local co=string.sub(d5[i][d9],1,12)local di=0;for cL=1,df do if d5[i][d9]==f(unit[de.."_"..cL].getData()).name then di=cL;break end end;if aY or d6[i]==nil or d7[i]==nil then local dj=0;local dk=0;local dl=0;local dm=0;local bL=system.getTime()if di~=0 then d7[i]=f(unit[de.."_"..di].getData()).percentage;d6[i]=f(unit[de.."_"..di].getData()).timeLeft;if d6[i]=="n/a"then d6[i]=0 end else dl=m(d5[i][d8])-d5[i][db]dj=d5[i][da]d7[i]=d(0.5+dl*100/dj)dk=d5[i][dc]dm=d5[i][dd]if dk<=dl then d6[i]=0 else d6[i]=d(0.5+dl/((dk-dl)/(bL-dm)))end;d5[i][dc]=dl;d5[i][dd]=bL end end;if co==d3 then co=e("%s %d",d4,i)end;if di==0 then co=co.." *"end;local dn;if d6[i]==0 then dn="n/a"else dn=FormatTimeString(d6[i])end;if d7[i]~=nil then local cH=d(d7[i]*2.55)local cI=e("rgb(%d,%d,%d)",255-cH,cH,0)local dp=""if dn~="n/a"and d6[i]<120 or d7[i]<5 then if aY then dp=[[class="red"]]end end;ct[#ct+1]=e([[ %s %d%% %s ]],bY,dg,dp,co,bY,dh,cI,d7[i],dn)dg=dg+30;dh=dh+30 end end end;ct[#ct+1]=""end;function HideInterplanetaryPanel()system.destroyWidgetPanel(panelInterplanetary)panelInterplanetary=nil end;function getRelativePitch(bd)bd=vec3(bd)local cz=-math.deg(math.atan(bd.y,bd.z))+180;cz=cz-90;if cz<0 then cz=360+cz end;if cz>180 then cz=-180+cz-180 end;return-cz end;function getRelativeYaw(bd)bd=vec3(bd)local dq=math.deg(math.atan(bd.y,bd.x))-90;if dq<-180 then dq=360+dq end;return dq end;function AlignToWorldVector(dr,ds,dt)if not am or not bi or aj~=-1 or be0 and CustomTarget~=nil end)MakeButton("Clear Position","Clear Position",200,dF.height,dF.x-200-30,dF.y,function()return true end,ClearCurrentPosition,function()return AutopilotTargetIndex>0 and CustomTarget~=nil end)dC=60;dD=300;local bY=10;local bZ=aD/2-300;MakeButton("Enable Turn and Burn","Disable Turn and Burn",dD,dC,bY,bZ,function()return TurnBurn end,ToggleTurnBurn)MakeButton("Engage Altitude Hold","Disable Altitude Hold",dD,dC,bY+dD+20,bZ,function()return AltitudeHold end,ToggleAltitudeHold)bZ=bZ+dC+20;MakeButton("Engage Autoland","Disable Autoland",dD,dC,bY,bZ,function()return AutoLanding end,ToggleAutoLanding)local dG,dH,dI;if VertTakeOffEngine then dG="Engage Vertical Takeoff"dH="Disable Vertical Takeoff"dI=VertTakeOff else dG="Engage Auto Takeoff"dH="Disable Auto Takeoff"dI=AutoTakeoff end;MakeButton(dG,dH,dD,dC,bY+dD+20,bZ,function()return dI end,ToggleAutoTakeoff)bZ=bZ+dC+20;MakeButton("Show Orbit Display","Hide Orbit Display",dD,dC,bY,bZ,function()return DisplayOrbit end,function()DisplayOrbit=not DisplayOrbit;if DisplayOrbit then W="Orbit Display Enabled"else W="Orbit Display Disabled"end end)MakeButton("Engage Orbiting","Cancel Orbiting",dD,dC,bY+dD+20,bZ,function()return IntoOrbit end,ToggleIntoOrbit,function()return j()==0 and unit.getClosestPlanetInfluence()>0 end)bZ=bZ+dC+20;MakeButton("Glide Re-Entry","Cancel Glide Re-Entry",dD,dC,bY,bZ,function()return Reentry end,function()ag=true;ProgradeToggle()end,function()return an>ReentryAltitude end)MakeButton("Parachute Re-Entry","Cancel Parachute Re-Entry",dD,dC,bY+dD+20,bZ,function()return Reentry end,BeginReentry,function()return an>ReentryAltitude end)bZ=bZ+dC+20;MakeButton("Engage Follow Mode","Disable Follow Mode",dD,dC,bY,bZ,function()return U end,ToggleFollowMode,function()return o()==1 end)MakeButton("Enable Repair Arrows","Disable Repair Arrows",dD,dC,bY+dD+20,bZ,function()return aQ end,function()aQ=not aQ;if aQ then W="Repair Arrows Enabled"else W="Repair Arrows Diabled"end end,function()return o()==1 end)bZ=bZ+dC+20;if not ExternalAGG then MakeButton("Enable AGG","Disable AGG",dD,dC,bY,bZ,function()return antigrav.getState()==1 end,ToggleAntigrav,function()return antigrav~=nil end)end;bZ=bZ+dC+20;MakeButton(function()return e("Toggle Control Scheme - Current: %s",userControlScheme)end,function()return e("Control Scheme: %s",userControlScheme)end,dD*2,dC,bY,bZ,function()return false end,function()if userControlScheme=="keyboard"then userControlScheme="mouse"elseif userControlScheme=="mouse"then userControlScheme="virtual joystick"else userControlScheme="keyboard"end end)end;function GetFlightStyle()local dJ=Nav.axisCommandManager:getAxisCommandType(0)local dK="TRAVEL"if dJ==1 then dK="CRUISE"end;if Autopilot then dK="AUTOPILOT"end;return dK end;function UpdateHud(ct)local cc=an;local bd=core.getVelocity()local bS=vec3(bd):len()local cy=vec3(core.getWorldVertical())local cw=vec3(core.getConstructWorldOrientationForward())local cx=vec3(core.getConstructWorldOrientationRight())local dL=vec3(core.getConstructWorldOrientationUp())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*dO+dL*dP)local dQ=dM;local dR=cz;local dS=j()local dT=d(unit.getThrottle())local dU=bS*3.6;local dV=unit.getAxisCommandValue(0)local dW=ConvertResolutionX(1770)local dX=ConvertResolutionY(310)if AtmoSpeedAssist and Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byThrottle then dV=z;dT=z*100 end;local dK=GetFlightStyle()local dY="ROLL"local cB=unit.getClosestPlanetInfluence()>0;if dT==nil then dT=0 end;if not cB then if bS>5 then cz=getRelativePitch(bd)dM=getRelativeYaw(bd)else cz=0;dM=0 end;dY="YAW"end;if x>50000 and not am then local dZ;if x>200000 then dZ=round(x/200000,2).." su"else dZ=round(x/1000,1).." km"end;ct[#ct+1]=e([[PvP Boundary: %s]],dW,dX,dZ)end;ct[#ct+1]=ae;ct[#ct+1]=ax;ct[#ct+1]=ad;if a_%aT==0 then aY=true end;if fuelX~=0 and fuelY~=0 then DrawTank(ct,aY,fuelX,"Atmospheric ","ATMO",aM,aW,aX)DrawTank(ct,aY,fuelX+100,"Space fuel t","SPACE",aN,aU,aV)DrawTank(ct,aY,fuelX+200,"Rocket fuel ","ROCKET",aO,aR,aS)end;if aY then aY=false;a_=0 end;a_=a_+1;DrawVerticalSpeed(ct,cc)if o()==0 or RemoteHud then if not IsInFreeLook()or brightHud then if cB then DrawRollLines(ct,centerX,centerY,dQ,dY,cB)DrawArtificialHorizon(ct,dR,dQ,centerX,centerY,cB,d(getRelativeYaw(bd)),bS)else DrawRollLines(ct,centerX,centerY,dM,dY,cB)DrawArtificialHorizon(ct,cz,dM,centerX,centerY,cB,d(dM),bS)end;DrawAltitudeDisplay(ct,cc,cB)DrawPrograde(ct,bd,bS,centerX,centerY)end end;DrawThrottle(ct,dK,dT,dV)DrawSpeed(ct,dU)DrawWarnings(ct)DisplayOrbitScreen(ct)if screen_2 then local cg=vec3(core.getConstructWorldPos())local bY=960+cg.x/b2;local bZ=450+cg.y/b3;screen_2.moveContent(b4,(bY-80)/19.2,(bZ-80)/10.8)end end;function IsInFreeLook()return system.isViewLocked()==0 and userControlScheme~="keyboard"and o()==0 end;function HUDPrologue(ct)if not w then t=PvPR;v=PvPG;u=PvPB else t=SafeR;v=SafeG;u=SafeB end;as=[[rgb(]]..d(t+0.5)..","..d(v+0.5)..","..d(u+0.5)..[[)]]at=[[rgb(]]..d(t*0.9+0.5)..","..d(v*0.9+0.5)..","..d(u*0.9+0.5)..[[)]]local d_=as;local e0=at;local e1=as;local e2=at;if IsInFreeLook()and not brightHud then d_=[[rgb(]]..d(t*0.4+0.5)..","..d(v*0.4+0.5)..","..d(u*0.3+0.5)..[[)]]e0=[[rgb(]]..d(t*0.3+0.5)..","..d(v*0.3+0.5)..","..d(u*0.2+0.5)..[[)]]end;ct[#ct+1]=e([[ @@ -385,7 +384,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 DrawDeadZone(ct)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 DrawCursorLine(ct)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 rateOfChange=vec3(core.getConstructWorldOrientationForward()):dot(vec3(core.getWorldVelocity()):normalize())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(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;VertTakeOffMode=string.lower(VertTakeOffMode)if VertTakeOffMode=="agg"and not ExternalAGG and antigrav~=nil then antigrav.activate()antigrav.show()if an0 then BrakeIsOn=true;a8=0 elseif eg<-5 then BrakeIsOn=true;a8=15 elseif an>=antigrav.getBaseAltitude()then BrakeIsOn=true;a8=0;VertTakeOff=false;W="Singularity engaged"end elseif VertTakeOffMode=="orbit"then if eg<-30 then W="Unable to take off. Landing."a8=0;bc=autoRollPreference;VertTakeOff=false;BrakeLanding=true elseif 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 else W="Incorrect settings for ship configuration. Takeoff aborted."bc=autoRollPreference;VertTakeOff=false;BrakeLanding=true 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 AutoTakeoff or VectorToTarget then if VectorToTarget then if bw==nil then bw=a4 end;bt=VectorToTarget end;if bw==nil then bw=planet end;AltitudeHold=false;Autopilot=false;VectorToTarget=false;br=true end;local iJ,iK=b9(bw):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-bw.center):len()-bw.radius)local iL=dM;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;if bt or AutoTakeoff then bv=AutoTakeoffAltitude;AutoTakeoff=false end;bu=true end;if HoldAltitude>bv then bv=HoldAltitude end;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 then VectorToTarget=bt end;bt=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>15 then iM(0.5,-80)BrakeIsOn=false elseif eg<-15 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;bx=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 j()==0 and(a4~=nil and a4.name==planet.name)and not VectorToTarget and not Reentry and not BrakeLanding and LockPitch==nil and anplanet.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 LastDistanceToTarget0 and j()==0 and a4.name==planet.name then if not bx then Autopilot=false;ah=false;AltitudeHold=false;IntoOrbit=true;bu=false;bw=a4 else local dv;if CustomTarget~=nil then dv=CustomTarget.position-vec3(core.getConstructWorldPos())else dv=a4.center-iB end;local jq=planet:getAltitude(CustomTarget.position)local jl=math.sqrt(dv:len()^2-(an-jq)^2)local jr=LastMaxBrakeInAtmo;jr=LastMaxBrake;a0,a1=b7.computeDistanceAndTime(be,0,n(),0,0,jr/2)StrongBrakes=true;if not ah 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 if planet.hasAtmosphere then BrakeIsOn=false;ProgradeIsOn=false;J=true;ag=false;ai=true;Autopilot=false;VectorToTarget=false;BeginReentry()end end;LastDistanceToTarget=jl 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=b6:getPlanetarySystem(0):castIntersections(iB,(AutopilotTargetCoords-iB):normalize(),function(fi)return fi.radius+fi.noAtmosphericDensityAltitude 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 DrawDeadZone(ct)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 DrawCursorLine(ct)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 rateOfChange=vec3(core.getConstructWorldOrientationForward()):dot(vec3(core.getWorldVelocity()):normalize())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(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 AutoTakeoff or VectorToTarget then if VectorToTarget then if bw==nil then bw=a4 end;bt=VectorToTarget end;if bw==nil then bw=planet end;AltitudeHold=false;Autopilot=false;VectorToTarget=false;br=true end;local iJ,iK=b9(bw):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-bw.center):len()-bw.radius)local iL=dM;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;if bt or AutoTakeoff then bv=AutoTakeoffAltitude;AutoTakeoff=false end;bu=true end;if HoldAltitude>bv then bv=HoldAltitude end;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 then VectorToTarget=bt end;bt=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;bx=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 j()==0 and(a4~=nil and a4.name==planet.name)and not VectorToTarget and not Reentry and not BrakeLanding and LockPitch==nil and anplanet.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 LastDistanceToTarget0 and j()==0 and a4.name==planet.name then if not bx then Autopilot=false;ah=false;AltitudeHold=false;IntoOrbit=true;bu=false;bw=a4 else local dv;if CustomTarget~=nil then dv=CustomTarget.position-vec3(core.getConstructWorldPos())else dv=a4.center-iB end;local jq=planet:getAltitude(CustomTarget.position)local jl=math.sqrt(dv:len()^2-(an-jq)^2)local jr=LastMaxBrakeInAtmo;jr=LastMaxBrake;a0,a1=b7.computeDistanceAndTime(be,0,n(),0,0,jr/2)StrongBrakes=true;if not ah 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 if planet.hasAtmosphere then BrakeIsOn=false;ProgradeIsOn=false;J=true;ag=false;ai=true;Autopilot=false;VectorToTarget=false;BeginReentry()end end;LastDistanceToTarget=jl 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=b6:getPlanetarySystem(0):castIntersections(iB,(AutopilotTargetCoords-iB):normalize(),function(fi)return fi.radius+fi.noAtmosphericDensityAltitude 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 f9b77fe..2c24996 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,6 +4,9 @@ Fixed script unloading when away from control unit. Note: We are now at our scr 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.43 +- Removed `VertTakeOffMode` user variable. Mode determined by checking to see if AGG is on prior to beginning ascent. +- If AGG is on when doing a AutoTakeOff or Vertical takeoff, ship will go to singularity altitude and stop engines and engage brakes. +- If AGG not present or off and do Vertical Takeoff, ship will vertically thrust to achieve Orbit. - Removed description of user variables from code to Readme.md to free up code space and prevent unloading of script. File size reduced from 192k to 184k minimized. Version 5.42 - VTO to Orbit or AGG Height, ATO to AGG, and Same Planet Orbital Hops. diff --git a/README.md b/README.md index f783c20..7f69b2f 100644 --- a/README.md +++ b/README.md @@ -231,7 +231,6 @@ Right click the seat and go to _Advanced_ -> _Edit Lua Parameters_ to see them a * ForceAlignment = false --export: (Default: false) Whether velocity vector alignment should be forced when in Altitude Hold * minRollVelocity = 150 --export: (Default: 150) Min velocity, in m/s, over which advanced rolling can occur * VertTakeOffEngine = false --export: (Default: false) Set this to true if you have VTOL engines on your construct. Changes Auto Takeoff to Vertical Takeoff. -* VertTakeOffMode = "Orbit" --export: (Default: "Orbit") Set to: "AGG" = turn on AGG when above 1km and near AGG activation height, "Orbit" = go directly to orbit based off of TargetOrbitRadius. Must keep quotes. Any case is fine. [Return to Table of Contents](#table-of-contents) diff --git a/src/ButtonHUD.lua b/src/ButtonHUD.lua index aa421f1..549d157 100644 --- a/src/ButtonHUD.lua +++ b/src/ButtonHUD.lua @@ -92,7 +92,6 @@ AtmoSpeedAssist = true --export: (Default: true) ForceAlignment = false --export: (Default: false) minRollVelocity = 150 --export: (Default: 150) VertTakeOffEngine = false --export: (Default: false) -VertTakeOffMode = "Orbit" --export: (Default: "Orbit") -- Auto Variable declarations that store status of ship. Must be global because they get saved/read to Databank due to using _G assignment BrakeToggleStatus = BrakeToggleDefault @@ -148,7 +147,7 @@ local saveableVariables = {"userControlScheme", "TargetOrbitRadius", "apTickRate "vSpdMeterX", "vSpdMeterY", "altMeterX", "altMeterY", "fuelX","fuelY", "LandingGearGroundHeight", "TrajectoryAlignmentStrength", "RemoteHud", "YawStallAngle", "PitchStallAngle", "ResolutionX", "ResolutionY", "UseSatNav", "FuelTankOptimization", "ContainerOptimization", "ExtraLongitudeTags", "ExtraLateralTags", "ExtraVerticalTags", "OrbitMapSize", "OrbitMapX", "OrbitMapY", "DisplayOrbit", "CalculateBrakeLandingSpeed", - "ForceAlignment", "autoRollRollThreshold", "minRollVelocity", "VertTakeOffEngine","VertTakeOffMode", "PvPR", "PvPG", "PvPB"} + "ForceAlignment", "autoRollRollThreshold", "minRollVelocity", "VertTakeOffEngine", "PvPR", "PvPG", "PvPB"} local autoVariables = {"SpaceTarget","BrakeToggleStatus", "BrakeIsOn", "RetrogradeIsOn", "ProgradeIsOn", "Autopilot", "TurnBurn", "AltitudeHold", "BrakeLanding", @@ -1079,15 +1078,8 @@ function ToggleAutoTakeoff() AltitudeHold = false else if VertTakeOffEngine then - VertTakeOffMode = string.lower(VertTakeOffMode) - if VertTakeOffMode ~= "orbit" and VertTakeOffMode ~= "agg" then - msgText = "Incorrect VertTakeOffMode setting. Takeoff aborted." - VertTakeOff = false - BrakeLanding = true - else VertTakeOff = true AltitudeHold = false - end else if not AltitudeHold then ToggleAltitudeHold() @@ -1095,13 +1087,11 @@ function ToggleAutoTakeoff() AutoTakeoff = true HoldAltitude = coreAltitude + AutoTakeoffAltitude end - if VertTakeOff or AutoTakeoff then - OrbitAchieved = false - GearExtended = false - Nav.control.retractLandingGears() - Nav.axisCommandManager:setTargetGroundAltitude(500) -- Hard set this for takeoff, you wouldn't use takeoff from a hangar - BrakeIsOn = true - end + OrbitAchieved = false + GearExtended = false + Nav.control.retractLandingGears() + Nav.axisCommandManager:setTargetGroundAltitude(500) -- Hard set this for takeoff, you wouldn't use takeoff from a hangar + BrakeIsOn = true end end @@ -6127,10 +6117,13 @@ function script.onTick(timerId) if VertTakeOff then autoRoll = true - VertTakeOffMode = string.lower(VertTakeOffMode) - if VertTakeOffMode == "agg" and not ExternalAGG and antigrav ~= nil then - antigrav.activate() - antigrav.show() + if vSpd < -30 then -- saftey net + msgText = "Unable to achieve lift. Safety Landing." + upAmount = 0 + autoRoll = autoRollPreference + VertTakeOff = false + BrakeLanding = true + elseif antigrav and not ExternalAGG and antigrav.getState() == 1 then if coreAltitude < (antigrav.getBaseAltitude() - 100) then VtPitch = 0 upAmount = 15 @@ -6138,23 +6131,17 @@ function script.onTick(timerId) elseif vSpd > 0 then BrakeIsOn = true upAmount = 0 - elseif vSpd < -5 then + elseif vSpd < -30 then BrakeIsOn = true upAmount = 15 elseif coreAltitude >= antigrav.getBaseAltitude() then BrakeIsOn = true upAmount = 0 VertTakeOff = false - msgText = "Singularity engaged" + msgText = "Takeoff complete. Singularity engaged" end - elseif VertTakeOffMode == "orbit" then - if vSpd < -30 then -- saftey net - msgText = "Unable to take off. Landing." - upAmount = 0 - autoRoll = autoRollPreference - VertTakeOff = false - BrakeLanding = true - elseif atmosphere() > 0.08 then + else + if atmosphere() > 0.08 then VtPitch = 0 BrakeIsOn = false upAmount = 20 @@ -6181,11 +6168,6 @@ function script.onTick(timerId) end VertTakeOff = false end - else -- stops them from doing bad things and check your settings - msgText = "Incorrect settings for ship configuration. Takeoff aborted." - autoRoll = autoRollPreference - VertTakeOff = false - BrakeLanding = true end if VtPitch ~= nil then if (vTpitchPID == nil) then @@ -6242,7 +6224,8 @@ 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 orbit.apoapsis.altitude <= orbit.periapsis.altitude*1.35 then -- conditions for a near perfect orbit + if orbit.periapsis.altitude > OrbitTargetOrbit*0.9 and orbit.periapsis.altitude < OrbitTargetOrbit*1.2 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 cmdThrottle(0) @@ -6274,10 +6257,10 @@ function script.onTick(timerId) if orbit.periapsis.altitude < OrbitTargetOrbit then if orbit.apoapsis.altitude > orbit.periapsis.altitude*1.25 then if velMag+10 > endSpeed then - if vSpd > 15 then + if vSpd > 5 then orbitThrottle(0.5,-80) BrakeIsOn = false - elseif vSpd < -15 then + elseif vSpd < -5 then orbitThrottle(0.5,80) BrakeIsOn = false else @@ -7355,46 +7338,6 @@ function script.onTick(timerId) antigrav.setBaseAltitude(desiredBaseAltitude) end end - - -- if AchieveOrbit then -- Try to achieve an orbit. This should only be on when in space. - -- local orbitAltitude = 1000 - -- if planet.name ~= "Space" then - -- if planet.hasAtmosphere then - -- orbitAltitude = math.floor(planet.radius*(TargetOrbitRadius-1) + planet.noAtmosphericDensityAltitude) - -- else - -- orbitAltitude = math.floor(planet.radius*(TargetOrbitRadius-1) + planet.surfaceMaxAltitude) - -- end - -- else - -- orbitAltitude = 1000 - -- end - - -- local _, endSpeed = Kep(planet):escapeAndOrbitalSpeed((worldPos-planet.center):len()-planet.radius) - - -- autoRoll = true - - -- -- Using the AutopilotTargetOrbit we would calculate for our current nearest planet - -- -- Figure out a target vector that our velocity should be at - that is, perpendicular to gravity, and toward CustomTarget if not nil - -- -- Otherwise ship forward if not orbiting to target - -- local targetVelocityVector - -- if OrbitToTarget and CustomTarget ~= nil then - -- -- So we need a vector pointing from our position to the target - -- -- And project it on a plane defined by worldV, easy - -- -- Not sure if we need the first normalize or not, might as well - -- targetVelocityVector = (target.position-worldPos):normalize():project_on_plane(worldV):normalize() - -- else - -- targetVelocityVector = constrF:project_on_plane(worldV):normalize() - -- end - - -- -- Adjust the vector to account for being above or below target altitude - -- targetVelocityVector = targetVelocityVector * endSpeed -- Scale based on target speed, and we'll use an un-normalized velocity vector to compare - -- targetVelocityVector = (targetVelocityVector + -worldV*(coreAltitude - orbitAltitude)):normalize()*endSpeed -- Make sure velocity stays capped - - -- -- So, this is exactly what we want our velocity vector to look like - - - -- -- Soo... nothing I do with this is going to really get it to stabilize at an altitude, which is the problem - -- -- To do that, we really need to get vspeed to 0 - -- end end end