From 0f5b38ae9b5103da7125c5d2252ef845c73c2f61 Mon Sep 17 00:00:00 2001
From: archaegeo
Date: Thu, 7 Jan 2021 12:28:02 -0500
Subject: [PATCH] Refactor of functions
---
ButtonHUD.conf | 276 +-
ChangeLog.md | 5 +
src/ButtonHUD.lua | 7241 +++++++++++++++++++++++----------------------
3 files changed, 3776 insertions(+), 3746 deletions(-)
diff --git a/ButtonHUD.conf b/ButtonHUD.conf
index ecff2e9..af45341 100644
--- a/ButtonHUD.conf
+++ b/ButtonHUD.conf
@@ -1,4 +1,4 @@
-name: ButtonsHud - Dimencia and Archaegeo v4.912 (Minified)
+name: ButtonsHud - Dimencia and Archaegeo v4.914 (Minified)
slots:
core:
class: CoreUnit
@@ -109,8 +109,8 @@ handlers:
brightHud = false --export: Enable to prevent hud dimming when in freelook.
VanillaRockets = false --export: If on, rockets behave like vanilla
userControlScheme = "virtual joystick" --export: Set to "virtual joystick", "mouse", or "keyboard"
- ResolutionX = 1920 --export: Default is 1920, automatically scales, variable for use for wierd resolutions (1920x1200, etc)
- ResolutionY = 1080 --export: Default is 1080, automatically scales, variable for use for wierd resolutions (1920x1200, etc)
+ ResolutionX = 1920 --export: Default is 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 is 1080, does not need to be set to same as game resolution. You can set 1080 on a 1440 to get larger resolution
PrimaryR = 130 --export: Primary HUD color
PrimaryG = 224 --export: Primary HUD color
PrimaryB = 255 --export: Primary HUD color
@@ -166,149 +166,149 @@ handlers:
ExternalAGG = false --export: Toggle On if using an external AGG system. If on will prevent this HUD from doing anything with AGG.
UseSatNav = false --export: Toggle on if using Trog SatNav script. This will provide SatNav support.
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.
- 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;DisplayOrbit=true;Reentry=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;TargetGroundAltitude=LandingGearGroundHeight;TotalDistanceTravelled=0.0;TotalFlightTime=0;SavedLocations={}VectorToTarget=false;LocationIndex=0;LastMaxBrake=0;LockPitch=nil;LastMaxBrakeInAtmo=0;AntigravTargetAltitude=core.getAltitude()LastStartTime=0;local a={"userControlScheme","AutopilotTargetOrbit","apTickRate","freeLookToggle","turnAssist","PrimaryR","PrimaryG","PrimaryB","warmup","DeadZone","circleRad","MouseXSensitivity","MouseYSensitivity","MaxGameVelocity","showHud","autoRollPreference","pitchSpeedFactor","yawSpeedFactor","rollSpeedFactor","brakeSpeedFactor","brakeFlatFactor","autoRollFactor","turnAssistFactor","torqueFactor","AutoTakeoffAltitude","TargetHoverHeight","AutopilotInterplanetaryThrottle","hideHudOnToggleWidgets","DampingMultiplier","fuelTankHandlingAtmo","fuelTankHandlingSpace","fuelTankHandlingRocket","RemoteFreeze","speedChangeLarge","speedChangeSmall","brightHud","brakeLandingRate","MaxPitch","ReentrySpeed","AtmoSpeedLimit","ReentryAltitude","centerX","centerY","vSpdMeterX","vSpdMeterY","altMeterX","altMeterY","fuelX","fuelY","LandingGearGroundHeight","TrajectoryAlignmentStrength","RemoteHud","StallAngle","ResolutionX","ResolutionY","UseSatNav","FuelTankOptimization","ContainerOptimization"}local b={"BrakeToggleStatus","BrakeIsOn","RetrogradeIsOn","ProgradeIsOn","Autopilot","TurnBurn","AltitudeHold","DisplayOrbit","BrakeLanding","Reentry","AutoTakeoff","HoldAltitude","AutopilotAccelerating","AutopilotBraking","AutopilotCruising","AutopilotRealigned","AutopilotEndSpeed","AutopilotStatus","AutopilotPlanetGravity","PrevViewLock","AutopilotTargetName","AutopilotTargetCoords","AutopilotTargetIndex","GearExtended","TargetGroundAltitude","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;function round(p,q)local r=10^(q or 0)return d(p*r+0.5)/r end;local s=round(ResolutionX/2,0)local t=round(ResolutionY/2,0)local u=false;local v=true;local w=55;local x=false;local y=1;local z=1;local A=false;local B=0;local C=0;local D=0;local E=0;local F=0;local G=0;local H=0;local I=false;local J=false;local K="empty"local L=1;local M=5;local N=5;local O=false;local P,Q=0;local R,S=0;local T=false;local U=false;local V=nil;local W=0;local X=0;local Y=false;local Z=0;local a0=0;local a1=0;local a2=3;local a3=0;local a4=""local a5=""local a6=0;local a7=false;local a8=false;local a9=false;local aa=-1;local ab=false;local ac=""local ad=j()>0;local ae=core.getAltitude()local af=core.getElementIdList()local ag=system.getTime()local ah=nil;local ai=false;local aj={}local ak=0;local al=0;local am=""local an=true;local ao={}local ap=1;local aq=0.001;local ar=ResolutionX;local as=ResolutionY;local at=nil;local au=nil;local av=nil;local aw=nil;local ax=false;local ay=false;local az=0;local aA=nil;local aB={}local aC={}local aD={}local aE=0;local aF=false;local aG={}local aH={}local aI=d(1/apTickRate)*2;local aJ={}local aK={}local aL={}local aM={}local aN=false;local aO=16;local aP=0;function script.onStart()VERSION_NUMBER=4.912;SetupComplete=false;beginSetup=coroutine.create(function()Nav.axisCommandManager:setupCustomTargetSpeedRanges(axisCommandId.longitudinal,{1000,5000,10000,20000,30000})if dbHud_1 then local aQ=dbHud_1.hasKey;if not useTheseSettings then for aR,aS in pairs(a)do if aQ(aS)then local aT=f(dbHud_1.getStringValue(aS))if aT~=nil then c(aS.." "..dbHud_1.getStringValue(aS))_G[aS]=aT;ax=true end end end end;coroutine.yield()for aR,aS in pairs(b)do if aQ(aS)then local aT=f(dbHud_1.getStringValue(aS))if aT~=nil then c(aS.." "..dbHud_1.getStringValue(aS))_G[aS]=aT;ax=true end end end;if useTheseSettings then K="Updated user preferences used. Will be saved when you exit seat.\nToggle off useTheseSettings to use saved values"a2=5 elseif ax then K="Loaded Saved Variables (see Lua Chat Tab for list)"else K="No Saved Variables Found - Stand up / leave remote to save settings"end else K="No databank found, install one anywhere and rerun the autoconfigure to save variables"end;coroutine.yield()local aU=system.getTime()if LastStartTime+18010000 then aO=128 elseif aX>1000 then aO=64 elseif aX>150 then aO=32 end end;aE=aE+h(af[aR])if fuelX~=0 and fuelY~=0 then if type=="Atmospheric Fuel Tank"or type=="Space Fuel Tank"or type=="Rocket Fuel Tank"then local aX=h(af[aR])local aY=m(af[aR])local aZ=0;local a_=system.getTime()if type=="Atmospheric Fuel Tank"then local b0=400;local b1=35.03;if aX>10000 then b0=51200;b1=5480 elseif aX>1300 then b0=6400;b1=988.67 elseif aX>150 then b0=1600;b1=182.67 end;aZ=aY-b1;if fuelTankHandlingAtmo>0 then b0=b0+b0*fuelTankHandlingAtmo*0.2 end;if aZ>b0 then b0=aZ end;if ContainerOptimization>0 then b0=b0-b0*ContainerOptimization*0.05 end;if FuelTankOptimization>0 then b0=b0-b0*FuelTankOptimization*0.05 end;aB[#aB+1]={af[aR],core.getElementNameById(af[aR]),b0,b1,aZ,a_}end;if type=="Rocket Fuel Tank"then local b0=320;local b1=173.42;if aX>65000 then b0=40000;b1=25740 elseif aX>6000 then b0=5120;b1=4720 elseif aX>700 then b0=640;b1=886.72 end;aZ=aY-b1;if fuelTankHandlingRocket>0 then b0=b0+b0*fuelTankHandlingRocket*0.2 end;if aZ>b0 then b0=aZ end;if ContainerOptimization>0 then b0=b0-b0*ContainerOptimization*0.05 end;if FuelTankOptimization>0 then b0=b0-b0*FuelTankOptimization*0.05 end;aD[#aD+1]={af[aR],core.getElementNameById(af[aR]),b0,b1,aZ,a_}end;if type=="Space Fuel Tank"then local b0=2400;local b1=182.67;if aX>10000 then b0=76800;b1=5480 elseif aX>1300 then b0=9600;b1=988.67 end;aZ=aY-b1;if fuelTankHandlingSpace>0 then b0=b0+b0*fuelTankHandlingSpace*0.2 end;if aZ>b0 then b0=aZ end;if ContainerOptimization>0 then b0=b0-b0*ContainerOptimization*0.05 end;if FuelTankOptimization>0 then b0=b0-b0*FuelTankOptimization*0.05 end;aC[#aC+1]={af[aR],core.getElementNameById(af[aR]),b0,b1,aZ,a_}end end end end;coroutine.yield()if gyro~=nil then ah=gyro.getState()==1 end;if userControlScheme~="keyboard"then system.lockView(1)else system.lockView(0)end;if ad then BrakeIsOn=true end;if radar_1 then if l(radar_1.getId())=="Space Radar"then T=true else U=true end end;if door then for _,aS in pairs(door)do aS.toggle()end end;if switch then for _,aS in pairs(switch)do aS.toggle()end end;if forcefield then for _,aS in pairs(forcefield)do aS.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 A then GearExtended=Nav.control.isAnyLandingGearExtended()==1;if GearExtended then Nav.control.extendLandingGears()else Nav.control.retractLandingGears()end end;if TargetGroundAltitude~=nil then Nav.axisCommandManager:setTargetGroundAltitude(TargetGroundAltitude)if TargetGroundAltitude==0 and not A then GearExtended=true end else if GearExtended or not A then Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)GearExtended=true else Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)end end;if ad and not dbHud_1 and(GearExtended or not A)then BrakeIsOn=true end;WasInAtmo=ad;unit.hide()function ConvertResolutionX(aS)if ResolutionX==1920 then return aS else return round(ResolutionX*aS/1920,0)end end;function ConvertResolutionY(aS)if ResolutionY==1080 then return aS else return round(ResolutionY*aS/1080,0)end end;function RefreshLastMaxBrake(b2,b3)if b2==nil then b2=core.g()end;b2=round(b2,5)local b4=j()if b3~=nil and b3 or(aA==nil or aA~=b2)then local velocity=core.getVelocity()local b5=vec3(velocity):len()local b6=f(unit.getData()).maxBrake;if b6~=nil and b6>0 and ad then b6=b6/utils.clamp(b5/100,0.1,1)b6=b6/b4;if b6>LastMaxBrakeInAtmo and b4>0.10 then LastMaxBrakeInAtmo=b6 end end;if b6~=nil and b6>0 then LastMaxBrake=b6 end;aA=b2 end end;function MakeButton(b7,b8,b9,ba,bb,bc,bd,be,bf)local bg={enableName=b7,disableName=b8,width=b9,height=ba,x=bb,y=bc,toggleVar=bd,toggleFunction=be,drawCondition=bf,hovered=false}table.insert(ao,bg)return bg end;function UpdateAtlasLocationsList()AtlasOrdered={}for aR,aS in pairs(atlas[0])do table.insert(AtlasOrdered,{name=aS.name,index=aR})end;local function bh(bi,bj)return bi.name-1 then atlas[0][bn]=bm end;UpdateAtlasLocationsList()K=CustomTarget.name.." position updated"end end;function ClearCurrentPosition()local bn=-1;for aR,aS in pairs(atlas[0])do if aS.name and aS.name==CustomTarget.name then bn=aR end end;if bn>-1 then table.remove(atlas[0],bn)end;bn=-1;for aR,aS in pairs(SavedLocations)do if aS.name and aS.name==CustomTarget.name then K=aS.name.." saved location cleared"bn=aR;break end end;if bn~=-1 then table.remove(SavedLocations,bn)end;DecrementAutopilotTargetIndex()UpdateAtlasLocationsList()end;function DrawDeadZone(bo)bo[#bo+1]=e([[]],DeadZone)end;function ToggleRadarPanel()if radarPanelID~=nil and a6==0 then system.destroyWidgetPanel(radarPanelID)radarPanelID=nil;if perisPanelID~=nil then system.destroyWidgetPanel(perisPanelID)perisPanelID=nil end else if a6==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;a6=0 end end;function ToggleWidgets()if an 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;an=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;an=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 ad then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;widgetCurBrakeTime=system.createWidget(panelInterplanetary,"value")widgetCurBrakeTimeText=system.createData('{"label": "Cur Brake Time", "value": "N/A", "unit":""}')if not ad then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;widgetMaxBrakeDistance=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeDistanceText=system.createData('{"label": "Max Brake distance", "value": "N/A", "unit":""}')if not ad then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;widgetMaxBrakeTime=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeTimeText=system.createData('{"label": "Max Brake Time", "value": "N/A", "unit":""}')if not ad then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;widgetTrajectoryAltitude=system.createWidget(panelInterplanetary,"value")widgetTrajectoryAltitudeText=system.createData('{"label": "Projected Altitude", "value": "N/A", "unit":""}')if not ad then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end end;function Contains(bp,bq,bb,bc,b9,ba)if bp>bb and bpbc and bqw then K="WARNING: Insufficient Brakes - Attempting coast landing, beware obstacles"end;AltitudeHold=false;AutoTakeoff=false;LockPitch=nil;BrakeLanding=true;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)end end;function ToggleAutoTakeoff()if AutoTakeoff then AutoTakeoff=false;if AltitudeHold then ToggleAltitudeHold()end else if not AltitudeHold then ToggleAltitudeHold()end;AutoTakeoff=true;HoldAltitude=ae+AutoTakeoffAltitude;GearExtended=false;Nav.control.retractLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(500)BrakeIsOn=true end end;function ToggleLockPitch()if LockPitch==nil then local br=vec3(core.getConstructWorldOrientationForward())local bs=vec3(core.getConstructWorldOrientationRight())local bt=vec3(core.getWorldVertical())local bu=getPitch(bt,br,bs)LockPitch=bu;AutoTakeoff=false;AltitudeHold=false;BrakeLanding=false else LockPitch=nil end end;function ToggleAltitudeHold()AltitudeHold=not AltitudeHold;if AltitudeHold then Autopilot=false;ProgradeIsOn=false;RetrogradeIsOn=false;I=false;BrakeLanding=false;Reentry=false;autoRoll=true;LockPitch=nil;if not GearExtended and not BrakeIsOn or not ad then AutoTakeoff=false;HoldAltitude=ae;if not a8 and Nav.axisCommandManager:getAxisCommandType(0)==0 then Nav.control.cancelCurrentControlMasterMode()end else AutoTakeoff=true;HoldAltitude=ae+AutoTakeoffAltitude;GearExtended=false;Nav.control.retractLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(500)BrakeIsOn=true end;if a8 then HoldAltitude=100000 end else autoRoll=autoRollPreference;AutoTakeoff=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;VectorToTarget=false end end;function ToggleFollowMode()if o()==1 then I=not I;if I 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;autoRoll=autoRollPreference;GearExtended=OldGearExtended;if GearExtended then Nav.control.extendLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)end end else K="Follow Mode only works with Remote controller"I=false end end;function ToggleAutopilot()if AutopilotTargetIndex>0 and not Autopilot and not VectorToTarget then if CustomTarget~=nil then LockPitch=nil;if planet.name==CustomTarget.planetname then StrongBrakes=planet.gravity*9.80665*n()w then K="Insufficient Brake Force\nCoast landing will be inaccurate"end;if j()>0 then if not AltitudeHold then if not VectorToTarget then ToggleVectorToTarget()end else if not VectorToTarget then ToggleVectorToTarget()end end else a7=true end else a8=true;RetrogradeIsOn=false;ProgradeIsOn=false;if j()~=0 then ToggleAltitudeHold()else Autopilot=true end end elseif j()==0 then Autopilot=true;RetrogradeIsOn=false;ProgradeIsOn=false;AutopilotRealigned=false;I=false;AltitudeHold=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;u=false;LockPitch=nil else a8=true;ToggleAltitudeHold()end else Autopilot=false;AutopilotRealigned=false;VectorToTarget=false;u=false;AutoTakeoff=false;AltitudeHold=false;VectorToTarget=false end end;function ProgradeToggle()ProgradeIsOn=not ProgradeIsOn;RetrogradeIsOn=false;Autopilot=false;AltitudeHold=false;I=false;BrakeLanding=false;LockPitch=nil;Reentry=false;AutoTakeoff=false end;function RetrogradeToggle()RetrogradeIsOn=not RetrogradeIsOn;ProgradeIsOn=false;Autopilot=false;AltitudeHold=false;I=false;BrakeLanding=false;LockPitch=nil;Reentry=false;AutoTakeoff=false end;function BrakeToggle()BrakeIsOn=not BrakeIsOn;if BrakeLanding then BrakeLanding=false;autoRoll=autoRollPreference end;if BrakeIsOn then AltitudeHold=false;VectorToTarget=false;AutoTakeoff=false;Reentry=false;ProgradeIsOn=false;BrakeLanding=false;AutoLanding=false;AltitudeHold=false;LockPitch=nil;autoRoll=autoRollPreference end end;function CheckDamage(bo)local bv=0;am=""local bw=aE;local bx=0;local by=0;local bz=0;local bA=0;local bB=""for aR in pairs(af)do local aX=0;local bC=0;bC=h(af[aR])aX=k(af[aR])bx=bx+aX;if aX0 and aj[11]==af[aR]then for bE in pairs(aj)do core.deleteSticker(aj[bE])end;aj={}end end;bv=d(bx/bw*100)if bv<100 then bo[#bo+1]=[[]]bA=d(bv*2.55)bB=e("rgb(%d,%d,%d)",255-bA,bA,0)if bv<100 then bo[#bo+1]=e([[Elemental Integrity: %i %%]],bB,bv)if bz>0 then bo[#bo+1]=e([[Disabled Modules: %i Damaged Modules: %i]],bB,bz,by)elseif by>0 then bo[#bo+1]=e([[Damaged Modules: %i]],bB,by)end end;bo[#bo+1]=[[<\g>]]end end;function DrawCursorLine(bo)local bF=d(utils.clamp(a3/(ar/4)*255,0,255))bo[#bo+1]=e("",a0,a1,d(PrimaryR+0.5)+bF,d(PrimaryG+0.5)-bF,d(PrimaryB+0.5)-bF)end;function getPitch(bG,bH,bj)local bI=bG:cross(bj):normalize_inplace()local bu=math.acos(utils.clamp(bI:dot(-bH),-1,1))*constants.rad2deg;if bI:cross(-bH):dot(bj)<0 then bu=-bu end;return bu end;function clearAll()if ab then ab=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;I=false;u=false;a7=false;a8=false;x=false;autoRoll=autoRollPreference;VectorToTarget=false;TurnBurn=false;ah=false;LockPitch=nil else ab=true end end;function wipeSaveVariables()if not dbHud_1 then K="No Databank Found, unable to wipe. \nYou must have a Databank attached to ship prior to running the HUD autoconfigure"a2=5 else if ay then for aR,aS in pairs(a)do dbHud_1.setStringValue(aS,g(nil))end;for aR,aS in pairs(b)do if aS~="SavedLocations"then dbHud_1.setStringValue(aS,g(nil))end end;K="Databank wiped. New variables will save after re-enter seat and exit"a2=5;ay=false;ax=false;Y=true else K="Press ALT-7 again to confirm wipe of ALL data"ay=true end end end;function CheckButtons()for _,aS in pairs(ao)do if aS.hovered then if not aS.drawCondition or aS.drawCondition()then aS.toggleFunction()end;aS.hovered=false end end end;function SetButtonContains()local bb=a0+ar/2;local bc=a1+as/2;for _,aS in pairs(ao)do aS.hovered=Contains(bb,bc,aS.x,aS.y,aS.width,aS.height)end end;function DrawButton(bo,bJ,hover,bb,bc,bK,bL,bM,bN,bO,bP)if type(bO)=="function"then bO=bO()end;if type(bP)=="function"then bP=bP()end;bo[#bo+1]=e(""bo[#bo+1]=e(""if bJ then bo[#bo+1]=e("%s",bO)else bo[#bo+1]=e("%s",bP)end end;function DrawButtons(bo)local bQ="rgb(50,50,50)'"local bR="rgb(210,200,200)"local bS=DrawButton;for _,aS in pairs(ao)do local b8=aS.disableName;local b7=aS.enableName;if type(b8)=="function"then b8=b8()end;if type(b7)=="function"then b7=b7()end;if not aS.drawCondition or aS.drawCondition()then bS(bo,aS.toggleVar(),aS.hovered,aS.x,aS.y,aS.width,aS.height,bR,bQ,b8,b7)end end end;function DrawTank(bo,aN,bb,bT,bU,bV,bW,bX)local bY=1;local bZ=2;local b_=3;local c0=4;local c1=5;local c2=6;local c3=""local c4=0;local c5=fuelY;local c6=fuelY+10;if o()==1 and not RemoteHud then c5=c5-50;c6=c6-50 end;bo[#bo+1]=[[]]if bU=="ATMO"then c3="atmofueltank"elseif bU=="SPACE"then c3="spacefueltank"else c3="rocketfueltank"end;c4=_G[c3 .."_size"]if#bV>0 then for i=1,#bV do local bk=string.sub(bV[i][bZ],1,12)local c7=0;for bE=1,c4 do if bV[i][bZ]==f(unit[c3 .."_"..bE].getData()).name then c7=bE;break end end;if aN or bW[i]==nil or bX[i]==nil then local c8=0;local c9=0;local ca=0;local cb=0;local a_=system.getTime()if c7~=0 then bX[i]=f(unit[c3 .."_"..c7].getData()).percentage;bW[i]=f(unit[c3 .."_"..c7].getData()).timeLeft;if bW[i]=="n/a"then bW[i]=0 end else ca=m(bV[i][bY])-bV[i][c0]c8=bV[i][b_]bX[i]=d(0.5+ca*100/c8)c9=bV[i][c1]cb=bV[i][c2]if c9<=ca then bW[i]=0 else bW[i]=d(0.5+ca/((c9-ca)/(a_-cb)))end;bV[i][c1]=ca;bV[i][c2]=a_ end end;if bk==bT then bk=e("%s %d",bU,i)end;if c7==0 then bk=bk.." *"end;local cc;if bW[i]==0 then cc="n/a"else cc=FormatTimeString(bW[i])end;if bX[i]~=nil then local bA=d(bX[i]*2.55)local bB=e("rgb(%d,%d,%d)",255-bA,bA,0)local cd=""if cc~="n/a"and bW[i]<120 or bX[i]<5 then if aN then cd=[[class="red"]]end end;bo[#bo+1]=e([[
- %s
- %d%% %s
- ]],bb,c5,cd,bk,bb,c6,bB,bX[i],cc)c5=c5+30;c6=c6+30 end end end;bo[#bo+1]=""end;function HideInterplanetaryPanel()system.destroyWidgetPanel(panelInterplanetary)panelInterplanetary=nil end;system.showScreen(1)function getRelativePitch(velocity)velocity=vec3(velocity)local bu=-math.deg(math.atan(velocity.y,velocity.z))+180;bu=bu-90;if bu<0 then bu=360+bu end;if bu>180 then bu=-180+bu-180 end;return-bu end;function getRelativeYaw(velocity)velocity=vec3(velocity)local ce=math.deg(math.atan(velocity.y,velocity.x))-90;if ce<-180 then ce=360+ce end;return ce end;function AlignToWorldVector(cf,cg)if not ad or RateOfChange>MinimumRateOfChange+0.08 or aa~=-1 then if cg==nil then cg=aq end;cf=vec3(cf):normalize()local ch=vec3(core.getConstructWorldOrientationForward())-cf;local ci=-getMagnitudeInDirection(ch,core.getConstructWorldOrientationRight())*ap;local cj=-getMagnitudeInDirection(ch,core.getConstructWorldOrientationUp())*ap;if ak==0 then ak=ci/2 end;if al==0 then al=cj/2 end;D=D-(ci+(ci-ak)*DampingMultiplier)C=C+cj+(cj-al)*DampingMultiplier;ak=ci;al=cj;if math.abs(ci)0 and CustomTarget~=nil end)MakeButton("Clear Position","Clear Position",200,cn.height,cn.x-200-30,cn.y,function()return true end,ClearCurrentPosition,function()return AutopilotTargetIndex>0 and CustomTarget~=nil end)ck=60;cl=300;local bb=10;local bc=as/2-300;MakeButton("Enable Turn and Burn","Disable Turn and Burn",cl,ck,bb,bc,function()return TurnBurn end,ToggleTurnBurn)MakeButton("Engage Altitude Hold","Disable Altitude Hold",cl,ck,bb+cl+20,bc,function()return AltitudeHold end,ToggleAltitudeHold)bc=bc+ck+20;MakeButton("Engage Autoland","Disable Autoland",cl,ck,bb,bc,function()return AutoLanding end,ToggleAutoLanding)MakeButton("Engage Auto Takeoff","Disable Auto Takeoff",cl,ck,bb+cl+20,bc,function()return AutoTakeoff end,ToggleAutoTakeoff)bc=bc+ck+20;MakeButton("Show Orbit Display","Hide Orbit Display",cl,ck,bb,bc,function()return DisplayOrbit end,function()DisplayOrbit=not DisplayOrbit;if DisplayOrbit then K="Orbit Display Enabled"else K="Orbit Display Disabled"end end)bc=bc+ck+20;MakeButton("Glide Re-Entry","Cancel Glide Re-Entry",cl,ck,bb,bc,function()return Reentry end,function()x=true;BeginReentry()end,function()return ae>ReentryAltitude end)MakeButton("Parachute Re-Entry","Cancel Parachute Re-Entry",cl,ck,bb+cl+20,bc,function()return Reentry end,BeginReentry,function()return ae>ReentryAltitude end)bc=bc+ck+20;MakeButton("Engage Follow Mode","Disable Follow Mode",cl,ck,bb,bc,function()return I end,ToggleFollowMode,function()return o()==1 end)MakeButton("Enable Repair Arrows","Disable Repair Arrows",cl,ck,bb+cl+20,bc,function()return aF end,function()aF=not aF;if aF then K="Repair Arrows Enabled"else K="Repair Arrows Diabled"end end,function()return o()==1 end)bc=bc+ck+20;if not ExternalAGG then MakeButton("Enable AGG","Disable AGG",cl,ck,bb,bc,function()return antigrav.getState()==1 end,ToggleAntigrav,function()return antigrav~=nil end)end;bc=bc+ck+20;MakeButton(function()return e("Toggle Control Scheme - Current: %s",userControlScheme)end,function()return e("Control Scheme: %s",userControlScheme)end,cl*2,ck,bb,bc,function()return false end,function()if userControlScheme=="keyboard"then userControlScheme="mouse"elseif userControlScheme=="mouse"then userControlScheme="virtual joystick"else userControlScheme="keyboard"end end)coroutine.yield()function GetFlightStyle()local co=Nav.axisCommandManager:getAxisCommandType(0)local cp="TRAVEL"if co==1 then cp="CRUISE"end;if Autopilot then cp="AUTOPILOT"end;return cp end;function updateHud(bo)local cq=ae;local velocity=core.getVelocity()local b5=vec3(velocity):len()local bt=vec3(core.getWorldVertical())local br=vec3(core.getConstructWorldOrientationForward())local bs=vec3(core.getConstructWorldOrientationRight())local cr=vec3(core.getConstructWorldOrientationUp())local cs=getRoll(bt,br,bs)local ct=cs/180*math.pi;local cu=math.cos(ct)local cv=math.sin(ct)local bu=getPitch(bt,br,bs*cu+cr*cv)local cw=cs;local cx=bu;local cy=j()local cz=d(unit.getThrottle())local cA=b5*3.6;local cB=unit.getAxisCommandValue(0)local cp=GetFlightStyle()local cC="ROLL"local cD=unit.getClosestPlanetInfluence()>0;if cz==nil then cz=0 end;if not cD then if b5>5 then bu=getRelativePitch(velocity)cs=getRelativeYaw(velocity)else bu=0;cs=0 end;cC="YAW"end;bo[#bo+1]=a5;bo[#bo+1]=am;bo[#bo+1]=a4;if aP%aI==0 then aN=true end;if fuelX~=0 and fuelY~=0 then DrawTank(bo,aN,fuelX,"Atmospheric ","ATMO",aB,aL,aM)DrawTank(bo,aN,fuelX+100,"Space fuel t","SPACE",aC,aJ,aK)DrawTank(bo,aN,fuelX+200,"Rocket fuel ","ROCKET",aD,aG,aH)end;if aN then aN=false;aP=0 end;aP=aP+1;DrawVerticalSpeed(bo,cq)if o()==0 or RemoteHud then if not IsInFreeLook()or brightHud then if cD then DrawRollLines(bo,centerX,centerY,cw,cC,cD)DrawArtificialHorizon(bo,cx,cw,centerX,centerY,cD,d(getRelativeYaw(velocity)),b5)else DrawRollLines(bo,centerX,centerY,cs,cC,cD)DrawArtificialHorizon(bo,bu,cs,centerX,centerY,cD,d(cs),b5)end;DrawAltitudeDisplay(bo,cq,cD)DrawPrograde(bo,velocity,b5,centerX,centerY)end end;DrawThrottle(bo,cp,cz,cB)DrawSpeed(bo,cA)DrawWarnings(bo)DisplayOrbitScreen(bo)if screen_2 then local cE=vec3(core.getConstructWorldPos())local bb=960+cE.x/MapXRatio;local bc=450+cE.y/MapYRatio;screen_2.moveContent(YouAreHere,(bb-80)/19.2,(bc-80)/10.8)end end;function IsInFreeLook()return system.isViewLocked()==0 and userControlScheme~="keyboard"and o()==0 end;function HUDPrologue(bo)local cF=aV;local cG=aW;local cH=aV;local cI=aW;if IsInFreeLook()and not brightHud then cF=[[rgb(]]..d(PrimaryR*0.4+0.5)..","..d(PrimaryG*0.4+0.5)..","..d(PrimaryB*0.3+0.5)..[[)]]cG=[[rgb(]]..d(PrimaryR*0.3+0.5)..","..d(PrimaryG*0.3+0.5)..","..d(PrimaryB*0.2+0.5)..[[)]]end;bo[#bo+1]=e([[
-
-
-
-
- "end;function DrawSpeed(bo,cA)local cJ=throtPosY-10;local cK=throtPosX+10;bo[#bo+1]=[[]]if o()==1 and not RemoteHud then cJ=75 end;bo[#bo+1]=e([[
-
- %d km/h
-
- ]],cK,cJ,d(cA))end;function DrawOdometer(bo,W,TotalDistanceTravelled,cp,X,cy)local cL=ConvertResolutionX(1240)local cM=ConvertResolutionY(55)local cN=cM+10;local cy=j()local b2=core.g()local cO=0;local cP=0;local cQ=0;RefreshLastMaxBrake(b2)if ad then cQ=LastMaxBrakeInAtmo else cQ=LastMaxBrake end;maxThrust=Nav:maxForceForward()az=n()if not ShowOdometer then return end;local cR=vec3(core.getWorldAcceleration()):len()/9.80665;if b2>0.1 then cP=az*b2;cO=maxThrust/b2 end;bo[#bo+1]=[[]]if o()==1 and not RemoteHud then cL=ConvertResolutionX(1120)cM=ConvertResolutionY(55)cN=cM+10 elseif ad then local cS=ConvertResolutionX(770)bo[#bo+1]=e([[
- ATMOSPHERE
- %.2f
- ]],cS,cM,cS,cN,cy)end;bo[#bo+1]=e([[
-
-
- GRAVITY
- %.2f g
- ACCEL
- %.2f g
- ]],cL,cM,cL,cN,b2/9.80665,cL,cM+20,cL,cN+20,cR)bo[#bo+1]=e([[
-
- ]],ConvertResolutionX(660),ConvertResolutionX(700),ConvertResolutionY(35),ConvertResolutionX(960),ConvertResolutionY(55),ConvertResolutionX(1240),ConvertResolutionY(35),ConvertResolutionX(1280))if o()==0 or RemoteHud then bo[#bo+1]=e([[
- Trip: %.2f km
- Lifetime: %.2f Mm
- Trip Time: %s
- Total Time: %s
- Mass: %.2f Tons
- Max Brake: %.2f kN
- Max Thrust: %.2f kN
- %s]],ConvertResolutionX(700),ConvertResolutionY(20),W,ConvertResolutionX(700),ConvertResolutionY(30),TotalDistanceTravelled/1000,ConvertResolutionX(830),ConvertResolutionY(20),FormatTimeString(X),ConvertResolutionX(830),ConvertResolutionY(30),FormatTimeString(TotalFlightTime),ConvertResolutionX(970),ConvertResolutionY(20),az/1000,ConvertResolutionX(1240),ConvertResolutionY(10),cQ/1000,ConvertResolutionX(1240),ConvertResolutionY(30),maxThrust/1000,ConvertResolutionX(960),ConvertResolutionY(180),cp)if b2>0.1 then bo[#bo+1]=e([[
- Max Mass: %.2f Tons
- Req Thrust: %.2f kN
- ]],ConvertResolutionX(970),ConvertResolutionY(30),cO/1000,ConvertResolutionX(1240),ConvertResolutionY(20),cP/1000)else bo[#bo+1]=e([[
- Max Mass: n/a
- Req Thrust: n/a
- ]],ConvertResolutionX(970),ConvertResolutionY(30),ConvertResolutionX(1240),ConvertResolutionY(20))end else bo[#bo+1]=e([[%s]],ConvertResolutionX(960),ConvertResolutionY(33),cp)end;bo[#bo+1]=""end;function DrawThrottle(bo,cp,cz,cB)local c5=throtPosY+10;local c6=throtPosY+20;if o()==1 and not RemoteHud then c5=55;c6=65 end;local cT="CRUISE"local unit="km/h"local cU=cB;if cp=="TRAVEL"or cp=="AUTOPILOT"then cT="THROT"unit="%"cU=cz;local cV="dim"if cz<0 then cV="red"end;bo[#bo+1]=e([[
-
-
-
- ]],cV,throtPosX-7,throtPosY-50,throtPosX,throtPosY-50,throtPosX,throtPosY+50,throtPosX-7,throtPosY+50,1-math.abs(cz),throtPosX-10,throtPosY+50,throtPosX-15,throtPosY+53,throtPosX-15,throtPosY+47)end;bo[#bo+1]=e([[
-
- %s
- %d %s
+ 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;DisplayOrbit=true;Reentry=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;TargetGroundAltitude=LandingGearGroundHeight;TotalDistanceTravelled=0.0;TotalFlightTime=0;SavedLocations={}VectorToTarget=false;LocationIndex=0;LastMaxBrake=0;LockPitch=nil;LastMaxBrakeInAtmo=0;AntigravTargetAltitude=core.getAltitude()LastStartTime=0;local a={"userControlScheme","AutopilotTargetOrbit","apTickRate","freeLookToggle","turnAssist","PrimaryR","PrimaryG","PrimaryB","warmup","DeadZone","circleRad","MouseXSensitivity","MouseYSensitivity","MaxGameVelocity","showHud","autoRollPreference","pitchSpeedFactor","yawSpeedFactor","rollSpeedFactor","brakeSpeedFactor","brakeFlatFactor","autoRollFactor","turnAssistFactor","torqueFactor","AutoTakeoffAltitude","TargetHoverHeight","AutopilotInterplanetaryThrottle","hideHudOnToggleWidgets","DampingMultiplier","fuelTankHandlingAtmo","fuelTankHandlingSpace","fuelTankHandlingRocket","RemoteFreeze","speedChangeLarge","speedChangeSmall","brightHud","brakeLandingRate","MaxPitch","ReentrySpeed","AtmoSpeedLimit","ReentryAltitude","centerX","centerY","vSpdMeterX","vSpdMeterY","altMeterX","altMeterY","fuelX","fuelY","LandingGearGroundHeight","TrajectoryAlignmentStrength","RemoteHud","StallAngle","ResolutionX","ResolutionY","UseSatNav","FuelTankOptimization","ContainerOptimization"}local b={"BrakeToggleStatus","BrakeIsOn","RetrogradeIsOn","ProgradeIsOn","Autopilot","TurnBurn","AltitudeHold","DisplayOrbit","BrakeLanding","Reentry","AutoTakeoff","HoldAltitude","AutopilotAccelerating","AutopilotBraking","AutopilotCruising","AutopilotRealigned","AutopilotEndSpeed","AutopilotStatus","AutopilotPlanetGravity","PrevViewLock","AutopilotTargetName","AutopilotTargetCoords","AutopilotTargetIndex","GearExtended","TargetGroundAltitude","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;function round(p,q)local r=10^(q or 0)return d(p*r+0.5)/r end;local s=round(ResolutionX/2,0)local t=round(ResolutionY/2,0)local u=false;local v=true;local w=55;local x=false;local y=1;local z=1;local A=false;local B=0;local C=0;local D=0;local E=0;local F=0;local G=0;local H=0;local I=false;local J=false;local K="empty"local L=1;local M=5;local N=5;local O=false;local P,Q=0;local R,S=0;local T=false;local U=false;local V=nil;local W=0;local X=0;local Y=false;local Z=0;local a0=0;local a1=0;local a2=3;local a3=0;local a4=""local a5=""local a6=0;local a7=false;local a8=false;local a9=false;local aa=-1;local ab=false;local ac=""local ad=j()>0;local ae=core.getAltitude()local af=core.getElementIdList()local ag=system.getTime()local ah=nil;local ai=false;local aj=[[rgb(]]..d(PrimaryR+0.5)..","..d(PrimaryG+0.5)..","..d(PrimaryB+0.5)..[[)]]local ak=[[rgb(]]..d(PrimaryR*0.9+0.5)..","..d(PrimaryG*0.9+0.5)..","..d(PrimaryB*0.9+0.5)..[[)]]local al={}local am=0;local an=0;local ao=""local ap=true;local aq={}local ar=1;local as=0.001;local at=ResolutionX;local au=ResolutionY;local av=nil;local aw=nil;local ax=nil;local ay=nil;local az=false;local aA=false;local aB=0;local aC=nil;local aD={}local aE={}local aF={}local aG=0;local aH=false;local aI={}local aJ={}local aK=d(1/apTickRate)*2;local aL={}local aM={}local aN={}local aO={}local aP=false;local aQ=16;local aR=0;local aS=nil;local aT=""local aU=nil;local aV=nil;local aW=nil;local aX=nil;local aY=nil;local aZ=nil;local a_=nil;local b0=false;local b1=false;function LoadVariables()if dbHud_1 then local b2=dbHud_1.hasKey;if not useTheseSettings then for b3,b4 in pairs(a)do if b2(b4)then local b5=f(dbHud_1.getStringValue(b4))if b5~=nil then c(b4 .." "..dbHud_1.getStringValue(b4))_G[b4]=b5;az=true end end end end;coroutine.yield()for b3,b4 in pairs(b)do if b2(b4)then local b5=f(dbHud_1.getStringValue(b4))if b5~=nil then c(b4 .." "..dbHud_1.getStringValue(b4))_G[b4]=b5;az=true end end end;if useTheseSettings then K="Updated user preferences used. Will be saved when you exit seat.\nToggle off useTheseSettings to use saved values"a2=5 elseif az then K="Loaded Saved Variables (see Lua Chat Tab for list)"else K="No Saved Variables Found - Stand up / leave remote to save settings"end else K="No databank found, install one anywhere and rerun the autoconfigure to save variables"end;local b6=system.getTime()if LastStartTime+180b8 then b8=b7 end;if ContainerOptimization>0 then b8=b8-b8*ContainerOptimization*0.05 end;if FuelTankOptimization>0 then b8=b8-b8*FuelTankOptimization*0.05 end;return b8 end;function ProcessElements()for b3 in pairs(af)do local type=l(af[b3])if type=="landing gear"then A=true end;if type=="dynamic core"then local b9=h(af[b3])if b9>10000 then aQ=128 elseif b9>1000 then aQ=64 elseif b9>150 then aQ=32 end end;aG=aG+h(af[b3])if fuelX~=0 and fuelY~=0 then if type=="Atmospheric Fuel Tank"or type=="Space Fuel Tank"or type=="Rocket Fuel Tank"then local b9=h(af[b3])local ba=m(af[b3])local b7=0;local bb=system.getTime()if type=="Atmospheric Fuel Tank"then local b8=400;local bc=35.03;if b9>10000 then b8=51200;bc=5480 elseif b9>1300 then b8=6400;bc=988.67 elseif b9>150 then b8=1600;bc=182.67 end;b7=ba-bc;if fuelTankHandlingAtmo>0 then b8=b8+b8*fuelTankHandlingAtmo*0.2 end;b8=CalculateFuelVolume(b7,b8)aD[#aD+1]={af[b3],core.getElementNameById(af[b3]),b8,bc,b7,bb}end;if type=="Rocket Fuel Tank"then local b8=320;local bc=173.42;if b9>65000 then b8=40000;bc=25740 elseif b9>6000 then b8=5120;bc=4720 elseif b9>700 then b8=640;bc=886.72 end;b7=ba-bc;if fuelTankHandlingRocket>0 then b8=b8+b8*fuelTankHandlingRocket*0.2 end;b8=CalculateFuelVolume(b7,b8)aF[#aF+1]={af[b3],core.getElementNameById(af[b3]),b8,bc,b7,bb}end;if type=="Space Fuel Tank"then local b8=2400;local bc=182.67;if b9>10000 then b8=76800;bc=5480 elseif b9>1300 then b8=9600;bc=988.67 end;b7=ba-bc;if fuelTankHandlingSpace>0 then b8=b8+b8*fuelTankHandlingSpace*0.2 end;b8=CalculateFuelVolume(b7,b8)aE[#aE+1]={af[b3],core.getElementNameById(af[b3]),b8,bc,b7,bb}end end end end end;function SetupChecks()if gyro~=nil then ah=gyro.getState()==1 end;if userControlScheme~="keyboard"then system.lockView(1)else system.lockView(0)end;if ad then BrakeIsOn=true end;if radar_1 then if l(radar_1.getId())=="Space Radar"then T=true else U=true end end;if door then for _,b4 in pairs(door)do b4.toggle()end end;if switch then for _,b4 in pairs(switch)do b4.toggle()end end;if forcefield then for _,b4 in pairs(forcefield)do b4.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 A then GearExtended=Nav.control.isAnyLandingGearExtended()==1;if GearExtended then Nav.control.extendLandingGears()else Nav.control.retractLandingGears()end end;if TargetGroundAltitude~=nil then Nav.axisCommandManager:setTargetGroundAltitude(TargetGroundAltitude)if TargetGroundAltitude==0 and not A then GearExtended=true end else if GearExtended or not A then Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)GearExtended=true else Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)end end;if ad and not dbHud_1 and(GearExtended or not A)then BrakeIsOn=true end;WasInAtmo=ad end;function ConvertResolutionX(b4)if ResolutionX==1920 then return b4 else return round(ResolutionX*b4/1920,0)end end;function ConvertResolutionY(b4)if ResolutionY==1080 then return b4 else return round(ResolutionY*b4/1080,0)end end;function RefreshLastMaxBrake(bd,be)if bd==nil then bd=core.g()end;bd=round(bd,5)local bf=j()if be~=nil and be or(aC==nil or aC~=bd)then local velocity=core.getVelocity()local bg=vec3(velocity):len()local bh=f(unit.getData()).maxBrake;if bh~=nil and bh>0 and ad then bh=bh/utils.clamp(bg/100,0.1,1)bh=bh/bf;if bh>LastMaxBrakeInAtmo and bf>0.10 then LastMaxBrakeInAtmo=bh end end;if bh~=nil and bh>0 then LastMaxBrake=bh end;aC=bd end end;function MakeButton(bi,bj,bk,bl,bm,bn,bo,bp,bq)local br={enableName=bi,disableName=bj,width=bk,height=bl,x=bm,y=bn,toggleVar=bo,toggleFunction=bp,drawCondition=bq,hovered=false}table.insert(aq,br)return br end;function UpdateAtlasLocationsList()AtlasOrdered={}for b3,b4 in pairs(aS[0])do table.insert(AtlasOrdered,{name=b4.name,index=b3})end;local function bs(bt,bu)return bt.name-1 then aS[0][by]=bx end;UpdateAtlasLocationsList()K=CustomTarget.name.." position updated"end end;function ClearCurrentPosition()local by=-1;for b3,b4 in pairs(aS[0])do if b4.name and b4.name==CustomTarget.name then by=b3 end end;if by>-1 then table.remove(aS[0],by)end;by=-1;for b3,b4 in pairs(SavedLocations)do if b4.name and b4.name==CustomTarget.name then K=b4.name.." saved location cleared"by=b3;break end end;if by~=-1 then table.remove(SavedLocations,by)end;DecrementAutopilotTargetIndex()UpdateAtlasLocationsList()end;function DrawDeadZone(bz)bz[#bz+1]=e([[]],DeadZone)end;function ToggleRadarPanel()if radarPanelID~=nil and a6==0 then system.destroyWidgetPanel(radarPanelID)radarPanelID=nil;if perisPanelID~=nil then system.destroyWidgetPanel(perisPanelID)perisPanelID=nil end else if a6==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;a6=0 end end;function ToggleWidgets()if ap 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;ap=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;ap=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 ad then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;widgetCurBrakeTime=system.createWidget(panelInterplanetary,"value")widgetCurBrakeTimeText=system.createData('{"label": "Cur Brake Time", "value": "N/A", "unit":""}')if not ad then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;widgetMaxBrakeDistance=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeDistanceText=system.createData('{"label": "Max Brake distance", "value": "N/A", "unit":""}')if not ad then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;widgetMaxBrakeTime=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeTimeText=system.createData('{"label": "Max Brake Time", "value": "N/A", "unit":""}')if not ad then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;widgetTrajectoryAltitude=system.createWidget(panelInterplanetary,"value")widgetTrajectoryAltitudeText=system.createData('{"label": "Projected Altitude", "value": "N/A", "unit":""}')if not ad then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end end;function Contains(bA,bB,bm,bn,bk,bl)if bA>bm and bAbn and bBw then K="WARNING: Insufficient Brakes - Attempting coast landing, beware obstacles"end;AltitudeHold=false;AutoTakeoff=false;LockPitch=nil;BrakeLanding=true;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)end end;function ToggleAutoTakeoff()if AutoTakeoff then AutoTakeoff=false;if AltitudeHold then ToggleAltitudeHold()end else if not AltitudeHold then ToggleAltitudeHold()end;AutoTakeoff=true;HoldAltitude=ae+AutoTakeoffAltitude;GearExtended=false;Nav.control.retractLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(500)BrakeIsOn=true end end;function ToggleLockPitch()if LockPitch==nil then local bC=vec3(core.getConstructWorldOrientationForward())local bD=vec3(core.getConstructWorldOrientationRight())local bE=vec3(core.getWorldVertical())local bF=getPitch(bE,bC,bD)LockPitch=bF;AutoTakeoff=false;AltitudeHold=false;BrakeLanding=false else LockPitch=nil end end;function ToggleAltitudeHold()AltitudeHold=not AltitudeHold;if AltitudeHold then Autopilot=false;ProgradeIsOn=false;RetrogradeIsOn=false;I=false;BrakeLanding=false;Reentry=false;autoRoll=true;LockPitch=nil;if not GearExtended and not BrakeIsOn or not ad then AutoTakeoff=false;HoldAltitude=ae;if not a8 and Nav.axisCommandManager:getAxisCommandType(0)==0 then Nav.control.cancelCurrentControlMasterMode()end else AutoTakeoff=true;HoldAltitude=ae+AutoTakeoffAltitude;GearExtended=false;Nav.control.retractLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(500)BrakeIsOn=true end;if a8 then HoldAltitude=100000 end else autoRoll=autoRollPreference;AutoTakeoff=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;VectorToTarget=false end end;function ToggleFollowMode()if o()==1 then I=not I;if I 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;autoRoll=autoRollPreference;GearExtended=OldGearExtended;if GearExtended then Nav.control.extendLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)end end else K="Follow Mode only works with Remote controller"I=false end end;function ToggleAutopilot()if AutopilotTargetIndex>0 and not Autopilot and not VectorToTarget then if CustomTarget~=nil then LockPitch=nil;if planet.name==CustomTarget.planetname then StrongBrakes=planet.gravity*9.80665*n()w then K="Insufficient Brake Force\nCoast landing will be inaccurate"end;if j()>0 then if not AltitudeHold then if not VectorToTarget then ToggleVectorToTarget()end else if not VectorToTarget then ToggleVectorToTarget()end end else a7=true end else a8=true;RetrogradeIsOn=false;ProgradeIsOn=false;if j()~=0 then ToggleAltitudeHold()else Autopilot=true end end elseif j()==0 then Autopilot=true;RetrogradeIsOn=false;ProgradeIsOn=false;AutopilotRealigned=false;I=false;AltitudeHold=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;u=false;LockPitch=nil else a8=true;ToggleAltitudeHold()end else Autopilot=false;AutopilotRealigned=false;VectorToTarget=false;u=false;AutoTakeoff=false;AltitudeHold=false;VectorToTarget=false end end;function ProgradeToggle()ProgradeIsOn=not ProgradeIsOn;RetrogradeIsOn=false;Autopilot=false;AltitudeHold=false;I=false;BrakeLanding=false;LockPitch=nil;Reentry=false;AutoTakeoff=false end;function RetrogradeToggle()RetrogradeIsOn=not RetrogradeIsOn;ProgradeIsOn=false;Autopilot=false;AltitudeHold=false;I=false;BrakeLanding=false;LockPitch=nil;Reentry=false;AutoTakeoff=false end;function BrakeToggle()BrakeIsOn=not BrakeIsOn;if BrakeLanding then BrakeLanding=false;autoRoll=autoRollPreference end;if BrakeIsOn then AltitudeHold=false;VectorToTarget=false;AutoTakeoff=false;Reentry=false;ProgradeIsOn=false;BrakeLanding=false;AutoLanding=false;AltitudeHold=false;LockPitch=nil;autoRoll=autoRollPreference end end;function CheckDamage(bz)local bG=0;ao=""local bH=aG;local bI=0;local bJ=0;local bK=0;local bL=0;local bM=""for b3 in pairs(af)do local b9=0;local bN=0;bN=h(af[b3])b9=k(af[b3])bI=bI+b9;if b90 and al[11]==af[b3]then for bP in pairs(al)do core.deleteSticker(al[bP])end;al={}end end;bG=d(bI/bH*100)if bG<100 then bz[#bz+1]=[[]]bL=d(bG*2.55)bM=e("rgb(%d,%d,%d)",255-bL,bL,0)if bG<100 then bz[#bz+1]=e([[Elemental Integrity: %i %%]],bM,bG)if bK>0 then bz[#bz+1]=e([[Disabled Modules: %i Damaged Modules: %i]],bM,bK,bJ)elseif bJ>0 then bz[#bz+1]=e([[Damaged Modules: %i]],bM,bJ)end end;bz[#bz+1]=[[<\g>]]end end;function DrawCursorLine(bz)local bQ=d(utils.clamp(a3/(at/4)*255,0,255))bz[#bz+1]=e("",a0,a1,d(PrimaryR+0.5)+bQ,d(PrimaryG+0.5)-bQ,d(PrimaryB+0.5)-bQ)end;function getPitch(bR,bS,bu)local bT=bR:cross(bu):normalize_inplace()local bF=math.acos(utils.clamp(bT:dot(-bS),-1,1))*constants.rad2deg;if bT:cross(-bS):dot(bu)<0 then bF=-bF end;return bF end;function clearAll()if ab then ab=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;I=false;u=false;a7=false;a8=false;x=false;autoRoll=autoRollPreference;VectorToTarget=false;TurnBurn=false;ah=false;LockPitch=nil else ab=true end end;function wipeSaveVariables()if not dbHud_1 then K="No Databank Found, unable to wipe. \nYou must have a Databank attached to ship prior to running the HUD autoconfigure"a2=5 else if aA then for b3,b4 in pairs(a)do dbHud_1.setStringValue(b4,g(nil))end;for b3,b4 in pairs(b)do if b4~="SavedLocations"then dbHud_1.setStringValue(b4,g(nil))end end;K="Databank wiped. New variables will save after re-enter seat and exit"a2=5;aA=false;az=false;Y=true else K="Press ALT-7 again to confirm wipe of ALL data"aA=true end end end;function CheckButtons()for _,b4 in pairs(aq)do if b4.hovered then if not b4.drawCondition or b4.drawCondition()then b4.toggleFunction()end;b4.hovered=false end end end;function SetButtonContains()local bm=a0+at/2;local bn=a1+au/2;for _,b4 in pairs(aq)do b4.hovered=Contains(bm,bn,b4.x,b4.y,b4.width,b4.height)end end;function DrawButton(bz,bU,hover,bm,bn,bV,bW,bX,bY,bZ,b_)if type(bZ)=="function"then bZ=bZ()end;if type(b_)=="function"then b_=b_()end;bz[#bz+1]=e(""bz[#bz+1]=e(""if bU then bz[#bz+1]=e("%s",bZ)else bz[#bz+1]=e("%s",b_)end end;function DrawButtons(bz)local c0="rgb(50,50,50)'"local c1="rgb(210,200,200)"local c2=DrawButton;for _,b4 in pairs(aq)do local bj=b4.disableName;local bi=b4.enableName;if type(bj)=="function"then bj=bj()end;if type(bi)=="function"then bi=bi()end;if not b4.drawCondition or b4.drawCondition()then c2(bz,b4.toggleVar(),b4.hovered,b4.x,b4.y,b4.width,b4.height,c1,c0,bj,bi)end end end;function DrawTank(bz,aP,bm,c3,c4,c5,c6,c7)local c8=1;local c9=2;local ca=3;local cb=4;local cc=5;local cd=6;local ce=""local cf=0;local cg=fuelY;local ch=fuelY+10;if o()==1 and not RemoteHud then cg=cg-50;ch=ch-50 end;bz[#bz+1]=[[]]if c4=="ATMO"then ce="atmofueltank"elseif c4=="SPACE"then ce="spacefueltank"else ce="rocketfueltank"end;cf=_G[ce.."_size"]if#c5>0 then for i=1,#c5 do local bv=string.sub(c5[i][c9],1,12)local ci=0;for bP=1,cf do if c5[i][c9]==f(unit[ce.."_"..bP].getData()).name then ci=bP;break end end;if aP or c6[i]==nil or c7[i]==nil then local cj=0;local ck=0;local cl=0;local cm=0;local bb=system.getTime()if ci~=0 then c7[i]=f(unit[ce.."_"..ci].getData()).percentage;c6[i]=f(unit[ce.."_"..ci].getData()).timeLeft;if c6[i]=="n/a"then c6[i]=0 end else cl=m(c5[i][c8])-c5[i][cb]cj=c5[i][ca]c7[i]=d(0.5+cl*100/cj)ck=c5[i][cc]cm=c5[i][cd]if ck<=cl then c6[i]=0 else c6[i]=d(0.5+cl/((ck-cl)/(bb-cm)))end;c5[i][cc]=cl;c5[i][cd]=bb end end;if bv==c3 then bv=e("%s %d",c4,i)end;if ci==0 then bv=bv.." *"end;local cn;if c6[i]==0 then cn="n/a"else cn=FormatTimeString(c6[i])end;if c7[i]~=nil then local bL=d(c7[i]*2.55)local bM=e("rgb(%d,%d,%d)",255-bL,bL,0)local co=""if cn~="n/a"and c6[i]<120 or c7[i]<5 then if aP then co=[[class="red"]]end end;bz[#bz+1]=e([[
+ %s
+ %d%% %s
+ ]],bm,cg,co,bv,bm,ch,bM,c7[i],cn)cg=cg+30;ch=ch+30 end end end;bz[#bz+1]=""end;function HideInterplanetaryPanel()system.destroyWidgetPanel(panelInterplanetary)panelInterplanetary=nil end;function getRelativePitch(velocity)velocity=vec3(velocity)local bF=-math.deg(math.atan(velocity.y,velocity.z))+180;bF=bF-90;if bF<0 then bF=360+bF end;if bF>180 then bF=-180+bF-180 end;return-bF end;function getRelativeYaw(velocity)velocity=vec3(velocity)local cp=math.deg(math.atan(velocity.y,velocity.x))-90;if cp<-180 then cp=360+cp end;return cp end;function AlignToWorldVector(cq,cr)if not ad or RateOfChange>MinimumRateOfChange+0.08 or aa~=-1 then if cr==nil then cr=as end;cq=vec3(cq):normalize()local cs=vec3(core.getConstructWorldOrientationForward())-cq;local ct=-getMagnitudeInDirection(cs,core.getConstructWorldOrientationRight())*ar;local cu=-getMagnitudeInDirection(cs,core.getConstructWorldOrientationUp())*ar;if am==0 then am=ct/2 end;if an==0 then an=cu/2 end;D=D-(ct+(ct-am)*DampingMultiplier)C=C+cu+(cu-an)*DampingMultiplier;am=ct;an=cu;if math.abs(ct)0 and CustomTarget~=nil end)MakeButton("Clear Position","Clear Position",200,cy.height,cy.x-200-30,cy.y,function()return true end,ClearCurrentPosition,function()return AutopilotTargetIndex>0 and CustomTarget~=nil end)cv=60;cw=300;local bm=10;local bn=au/2-300;MakeButton("Enable Turn and Burn","Disable Turn and Burn",cw,cv,bm,bn,function()return TurnBurn end,ToggleTurnBurn)MakeButton("Engage Altitude Hold","Disable Altitude Hold",cw,cv,bm+cw+20,bn,function()return AltitudeHold end,ToggleAltitudeHold)bn=bn+cv+20;MakeButton("Engage Autoland","Disable Autoland",cw,cv,bm,bn,function()return AutoLanding end,ToggleAutoLanding)MakeButton("Engage Auto Takeoff","Disable Auto Takeoff",cw,cv,bm+cw+20,bn,function()return AutoTakeoff end,ToggleAutoTakeoff)bn=bn+cv+20;MakeButton("Show Orbit Display","Hide Orbit Display",cw,cv,bm,bn,function()return DisplayOrbit end,function()DisplayOrbit=not DisplayOrbit;if DisplayOrbit then K="Orbit Display Enabled"else K="Orbit Display Disabled"end end)bn=bn+cv+20;MakeButton("Glide Re-Entry","Cancel Glide Re-Entry",cw,cv,bm,bn,function()return Reentry end,function()x=true;BeginReentry()end,function()return ae>ReentryAltitude end)MakeButton("Parachute Re-Entry","Cancel Parachute Re-Entry",cw,cv,bm+cw+20,bn,function()return Reentry end,BeginReentry,function()return ae>ReentryAltitude end)bn=bn+cv+20;MakeButton("Engage Follow Mode","Disable Follow Mode",cw,cv,bm,bn,function()return I end,ToggleFollowMode,function()return o()==1 end)MakeButton("Enable Repair Arrows","Disable Repair Arrows",cw,cv,bm+cw+20,bn,function()return aH end,function()aH=not aH;if aH then K="Repair Arrows Enabled"else K="Repair Arrows Diabled"end end,function()return o()==1 end)bn=bn+cv+20;if not ExternalAGG then MakeButton("Enable AGG","Disable AGG",cw,cv,bm,bn,function()return antigrav.getState()==1 end,ToggleAntigrav,function()return antigrav~=nil end)end;bn=bn+cv+20;MakeButton(function()return e("Toggle Control Scheme - Current: %s",userControlScheme)end,function()return e("Control Scheme: %s",userControlScheme)end,cw*2,cv,bm,bn,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 cz=Nav.axisCommandManager:getAxisCommandType(0)local cA="TRAVEL"if cz==1 then cA="CRUISE"end;if Autopilot then cA="AUTOPILOT"end;return cA end;function updateHud(bz)local cB=ae;local velocity=core.getVelocity()local bg=vec3(velocity):len()local bE=vec3(core.getWorldVertical())local bC=vec3(core.getConstructWorldOrientationForward())local bD=vec3(core.getConstructWorldOrientationRight())local cC=vec3(core.getConstructWorldOrientationUp())local cD=getRoll(bE,bC,bD)local cE=cD/180*math.pi;local cF=math.cos(cE)local cG=math.sin(cE)local bF=getPitch(bE,bC,bD*cF+cC*cG)local cH=cD;local cI=bF;local cJ=j()local cK=d(unit.getThrottle())local cL=bg*3.6;local cM=unit.getAxisCommandValue(0)local cA=GetFlightStyle()local cN="ROLL"local cO=unit.getClosestPlanetInfluence()>0;if cK==nil then cK=0 end;if not cO then if bg>5 then bF=getRelativePitch(velocity)cD=getRelativeYaw(velocity)else bF=0;cD=0 end;cN="YAW"end;bz[#bz+1]=a5;bz[#bz+1]=ao;bz[#bz+1]=a4;if aR%aK==0 then aP=true end;if fuelX~=0 and fuelY~=0 then DrawTank(bz,aP,fuelX,"Atmospheric ","ATMO",aD,aN,aO)DrawTank(bz,aP,fuelX+100,"Space fuel t","SPACE",aE,aL,aM)DrawTank(bz,aP,fuelX+200,"Rocket fuel ","ROCKET",aF,aI,aJ)end;if aP then aP=false;aR=0 end;aR=aR+1;DrawVerticalSpeed(bz,cB)if o()==0 or RemoteHud then if not IsInFreeLook()or brightHud then if cO then DrawRollLines(bz,centerX,centerY,cH,cN,cO)DrawArtificialHorizon(bz,cI,cH,centerX,centerY,cO,d(getRelativeYaw(velocity)),bg)else DrawRollLines(bz,centerX,centerY,cD,cN,cO)DrawArtificialHorizon(bz,bF,cD,centerX,centerY,cO,d(cD),bg)end;DrawAltitudeDisplay(bz,cB,cO)DrawPrograde(bz,velocity,bg,centerX,centerY)end end;DrawThrottle(bz,cA,cK,cM)DrawSpeed(bz,cL)DrawWarnings(bz)DisplayOrbitScreen(bz)if screen_2 then local cP=vec3(core.getConstructWorldPos())local bm=960+cP.x/aU;local bn=450+cP.y/aV;screen_2.moveContent(aW,(bm-80)/19.2,(bn-80)/10.8)end end;function IsInFreeLook()return system.isViewLocked()==0 and userControlScheme~="keyboard"and o()==0 end;function HUDPrologue(bz)local cQ=aj;local cR=ak;local cS=aj;local cT=ak;if IsInFreeLook()and not brightHud then cQ=[[rgb(]]..d(PrimaryR*0.4+0.5)..","..d(PrimaryG*0.4+0.5)..","..d(PrimaryB*0.3+0.5)..[[)]]cR=[[rgb(]]..d(PrimaryR*0.3+0.5)..","..d(PrimaryG*0.3+0.5)..","..d(PrimaryB*0.2+0.5)..[[)]]end;bz[#bz+1]=e([[
+
+
+
+
+ "end;function DrawSpeed(bz,cL)local cU=throtPosY-10;local cV=throtPosX+10;bz[#bz+1]=[[]]if o()==1 and not RemoteHud then cU=75 end;bz[#bz+1]=e([[
+
+ %d km/h
+
+ ]],cV,cU,d(cL))end;function DrawOdometer(bz,W,TotalDistanceTravelled,cA,X,cJ)local cW=ConvertResolutionX(1240)local cX=ConvertResolutionY(55)local cY=cX+10;local cJ=j()local bd=core.g()local cZ=0;local c_=0;local d0=0;RefreshLastMaxBrake(bd)if ad then d0=LastMaxBrakeInAtmo else d0=LastMaxBrake end;maxThrust=Nav:maxForceForward()aB=n()if not ShowOdometer then return end;local d1=vec3(core.getWorldAcceleration()):len()/9.80665;if bd>0.1 then c_=aB*bd;cZ=maxThrust/bd end;bz[#bz+1]=[[]]if o()==1 and not RemoteHud then cW=ConvertResolutionX(1120)cX=ConvertResolutionY(55)cY=cX+10 elseif ad then local d2=ConvertResolutionX(770)bz[#bz+1]=e([[
+ ATMOSPHERE
+ %.2f
+ ]],d2,cX,d2,cY,cJ)end;bz[#bz+1]=e([[
+
+
+ GRAVITY
+ %.2f g
+ ACCEL
+ %.2f g
+ ]],cW,cX,cW,cY,bd/9.80665,cW,cX+20,cW,cY+20,d1)bz[#bz+1]=e([[
+
+ ]],ConvertResolutionX(660),ConvertResolutionX(700),ConvertResolutionY(35),ConvertResolutionX(960),ConvertResolutionY(55),ConvertResolutionX(1240),ConvertResolutionY(35),ConvertResolutionX(1280))if o()==0 or RemoteHud then bz[#bz+1]=e([[
+ Trip: %.2f km
+ Lifetime: %.2f Mm
+ Trip Time: %s
+ Total Time: %s
+ Mass: %.2f Tons
+ Max Brake: %.2f kN
+ Max Thrust: %.2f kN
+ %s]],ConvertResolutionX(700),ConvertResolutionY(20),W,ConvertResolutionX(700),ConvertResolutionY(30),TotalDistanceTravelled/1000,ConvertResolutionX(830),ConvertResolutionY(20),FormatTimeString(X),ConvertResolutionX(830),ConvertResolutionY(30),FormatTimeString(TotalFlightTime),ConvertResolutionX(970),ConvertResolutionY(20),aB/1000,ConvertResolutionX(1240),ConvertResolutionY(10),d0/1000,ConvertResolutionX(1240),ConvertResolutionY(30),maxThrust/1000,ConvertResolutionX(960),ConvertResolutionY(180),cA)if bd>0.1 then bz[#bz+1]=e([[
+ Max Mass: %.2f Tons
+ Req Thrust: %.2f kN
+ ]],ConvertResolutionX(970),ConvertResolutionY(30),cZ/1000,ConvertResolutionX(1240),ConvertResolutionY(20),c_/1000)else bz[#bz+1]=e([[
+ Max Mass: n/a
+ Req Thrust: n/a
+ ]],ConvertResolutionX(970),ConvertResolutionY(30),ConvertResolutionX(1240),ConvertResolutionY(20))end else bz[#bz+1]=e([[%s]],ConvertResolutionX(960),ConvertResolutionY(33),cA)end;bz[#bz+1]=""end;function DrawThrottle(bz,cA,cK,cM)local cg=throtPosY+10;local ch=throtPosY+20;if o()==1 and not RemoteHud then cg=55;ch=65 end;local d3="CRUISE"local unit="km/h"local d4=cM;if cA=="TRAVEL"or cA=="AUTOPILOT"then d3="THROT"unit="%"d4=cK;local d5="dim"if cK<0 then d5="red"end;bz[#bz+1]=e([[
+
+
+
+ ]],d5,throtPosX-7,throtPosY-50,throtPosX,throtPosY-50,throtPosX,throtPosY+50,throtPosX-7,throtPosY+50,1-math.abs(cK),throtPosX-10,throtPosY+50,throtPosX-15,throtPosY+53,throtPosX-15,throtPosY+47)end;bz[#bz+1]=e([[
+
+ %s
+ %d %s
+
+ ]],throtPosX+10,cg,d3,throtPosX+10,ch,d4,unit)end;function DrawVerticalSpeed(bz,cB)if cB<200000 and not ad or cB and ad then local d6=-vec3(core.getWorldVertical()):dot(vec3(core.getWorldVelocity()))local d7=0;if math.abs(d6)>1 then d7=45*math.log(math.abs(d6),10)if d6<0 then d7=-d7 end end;bz[#bz+1]=e([[
+
+ 1000
+ 100
+ 10
+ O
+ -10
+ -100
+ -1000
+ %d m/s
+
+
+
- ]],throtPosX+10,c5,cT,throtPosX+10,c6,cU,unit)end;function DrawVerticalSpeed(bo,cq)if cq<200000 and not ad or cq and ad then local cW=-vec3(core.getWorldVertical()):dot(vec3(core.getWorldVelocity()))local cX=0;if math.abs(cW)>1 then cX=45*math.log(math.abs(cW),10)if cW<0 then cX=-cX end end;bo[#bo+1]=e([[
-
- 1000
- 100
- 10
- O
- -10
- -100
- -1000
- %d m/s
-
-
-
-
-
-
- ]],vSpdMeterX,vSpdMeterY,d(cW),d(cX))end end;function getHeading(bH)local cY=-vec3(core.getWorldVertical())bH=bH-bH:project_on(cY)local cZ=vec3(0,0,1)cZ=cZ-cZ:project_on(cY)local c_=cZ:cross(cY)local cX=cZ:angle_between(bH)*constants.rad2deg;if bH:dot(c_)<0 then cX=360-cX end;return cX end;function DrawRollLines(bo,centerX,centerY,cw,cC,cD)local d0=circleRad;local d1=20;d1=d(d1)local d2=d(cw)if cD then for i=-45,45,5 do local d3=i;bo[#bo+1]=e([[]],d3,centerX,centerY)len=5;if i%15==0 then len=15 elseif i%10==0 then len=10 end;bo[#bo+1]=e([[]],centerX,centerY+d0+d1-len,centerX,centerY+d0+d1)end;bo[#bo+1]=e([["
+
+
+ ]],vSpdMeterX,vSpdMeterY,d(d6),d(d7))end end;function getHeading(bS)local d8=-vec3(core.getWorldVertical())bS=bS-bS:project_on(d8)local d9=vec3(0,0,1)d9=d9-d9:project_on(d8)local da=d9:cross(d8)local d7=d9:angle_between(bS)*constants.rad2deg;if bS:dot(da)<0 then d7=360-d7 end;return d7 end;function DrawRollLines(bz,centerX,centerY,cH,cN,cO)local db=circleRad;local dc=20;dc=d(dc)local dd=d(cH)if cO then for i=-45,45,5 do local de=i;bz[#bz+1]=e([[]],de,centerX,centerY)len=5;if i%15==0 then len=15 elseif i%10==0 then len=10 end;bz[#bz+1]=e([[]],centerX,centerY+db+dc-len,centerX,centerY+db+dc)end;bz[#bz+1]=e([["
+
+ %s
+ %d deg
+
+ ]],centerX,centerY+db+dc-35,cN,centerX,centerY+db+dc-25,dd)bz[#bz+1]=e([[]],-cH,centerX,centerY)bz[#bz+1]=e([[<]],centerX-5,centerY+db+dc-20,centerX+5,centerY+db+dc-20,centerX,centerY+db+dc-15)bz[#bz+1]=""end;local cp=dd;if cO then cp=getHeading(vec3(core.getConstructWorldOrientationForward()))end;local df=20;local dg=d(cp)local dh=0;local di=centerY+db+dc+20;local dj=centerX;if cN~="YAW"then di=ConvertResolutionY(130)dj=ConvertResolutionX(960)end;local dk=[[%d]],bm+5,di-12,p)elseif i%5==0 then dh=5 end;if dh==10 then dk=e([[%s M %f %f v %d]],dk,bm,di-5,dh)else dk=e([[%s M %f %f v %d]],dk,bm,di-2.5,dh)end end;bz[#bz+1]=dk..[["/>]]bz[#bz+1]=e([[<]],dj-5,di+10,dj+5,di+10,dj,di+5)if cO then cN="HDG"end;bz[#bz+1]=e([["
+
+ %d deg
+ %s
+
+ ]],dj,di+25,dg,dj,di+35,cN)end;function DrawArtificialHorizon(bz,cI,cH,centerX,centerY,cO,dl,bg)local db=circleRad;local dm=d(db*3/5)if db>0 then local dn=d(cI)local len=0;local dk=e([[]],db-1,centerX,centerY)bz[#bz+1]=[[]]for i=d(dn-30-dn%5+0.5),d(dn+30+dn%5+0.5),5 do if i%10==0 then len=30 elseif i%5==0 then len=20 end;local bn=centerY+-i*5+cI*5;if len==30 then dk=e([[%s M %d %f h %d]],dk,centerX-dm-len,bn,len)if ad then bz[#bz+1]=e([[%d]],-1*cH,centerX,centerY,centerX-dm+10,bn,i)bz[#bz+1]=e([[%d]],-1*cH,centerX,centerY,centerX+dm-10,bn,i)if i==0 or i==180 or i==-180 then bz[#bz+1]=e([[]],-1*cH,centerX,centerY,centerX-dm+20,bn,dm*2-40)end else bz[#bz+1]=e([[%d]],centerX-dm+10,bn,i)bz[#bz+1]=e([[%d]],centerX+dm-10,bn,i)end;dk=e([[%s M %d %f h %d]],dk,centerX+dm,bn,len)else dk=e([[%s M %d %f h %d]],dk,centerX-dm-len,bn,len)dk=e([[%s M %d %f h %d]],dk,centerX+dm,bn,len)end end;bz[#bz+1]=dk..[["/>]]local dp="PITCH"if not cO then dp="REL PITCH"end;if cI>90 and not ad then cI=90-(cI-90)elseif cI<-90 and not ad then cI=-90-(cI+90)end;if db>200 then if ad then if bg>w then bz[#bz+1]=e([["
- %s
- %d deg
+ %s
+ %d deg
- ]],centerX,centerY+d0+d1-35,cC,centerX,centerY+d0+d1-25,d2)bo[#bo+1]=e([[]],-cw,centerX,centerY)bo[#bo+1]=e([[<]],centerX-5,centerY+d0+d1-20,centerX+5,centerY+d0+d1-20,centerX,centerY+d0+d1-15)bo[#bo+1]=""end;local ce=d2;if cD then ce=getHeading(vec3(core.getConstructWorldOrientationForward()))end;local d4=20;local d5=d(ce)local d6=0;local d7=centerY+d0+d1+20;local d8=centerX;if cC~="YAW"then d7=ConvertResolutionY(130)d8=ConvertResolutionX(960)end;local d9=[[%d]],bb+5,d7-12,p)elseif i%5==0 then d6=5 end;if d6==10 then d9=e([[%s M %f %f v %d]],d9,bb,d7-5,d6)else d9=e([[%s M %f %f v %d]],d9,bb,d7-2.5,d6)end end;bo[#bo+1]=d9 ..[["/>]]bo[#bo+1]=e([[<]],d8-5,d7+10,d8+5,d7+10,d8,d7+5)if cD then cC="HDG"end;bo[#bo+1]=e([["
+ ]],centerX,centerY-15,"Yaw",centerX,centerY+20,dl)end;bz[#bz+1]=e([[]],-cH,centerX,centerY)else bz[#bz+1]=e([[]],centerX,centerY)end;bz[#bz+1]=e([[< class="pdim txtend">%d]],centerX-dm+25,centerY-5,centerX-dm+20,centerY,centerX-dm+25,centerY+5,centerX-dm+50,centerY+4,dn)bz[#bz+1]=e([[< class="pdim txtend">%d]],centerX+dm-25,centerY-5,centerX+dm-20,centerY,centerX+dm-25,centerY+5,centerX+dm-30,centerY+4,dn)bz[#bz+1]=""end;local dq=d(db/3)bz[#bz+1]=e([[]],centerX-dq,centerY,db-dq)if not ad and cO then bz[#bz+1]=e([[]],-1*cH,centerX,centerY,centerX-dm+10,centerY,dm*2-20)end;bz[#bz+1]=""if db<200 then if ad and bg>w then bz[#bz+1]=e([["
+ %s
+ %d deg
+ %s%d deg
+
+ ]],centerX,centerY-db,dp,centerX,centerY-db+10,dn,centerX,centerY-15,"Yaw",centerX,centerY+20,dl)else bz[#bz+1]=e([["
+ %s
+ %d deg
- ]],d8,d7+25,d5,d8,d7+35,cC)end;function DrawArtificialHorizon(bo,cx,cw,centerX,centerY,cD,da,b5)local d0=circleRad;local db=d(d0*3/5)if d0>0 then local dc=d(cx)local len=0;local d9=e([[]],d0-1,centerX,centerY)bo[#bo+1]=[[]]for i=d(dc-30-dc%5+0.5),d(dc+30+dc%5+0.5),5 do if i%10==0 then len=30 elseif i%5==0 then len=20 end;local bc=centerY+-i*5+cx*5;if len==30 then d9=e([[%s M %d %f h %d]],d9,centerX-db-len,bc,len)if ad then bo[#bo+1]=e([[%d]],-1*cw,centerX,centerY,centerX-db+10,bc,i)bo[#bo+1]=e([[%d]],-1*cw,centerX,centerY,centerX+db-10,bc,i)if i==0 or i==180 or i==-180 then bo[#bo+1]=e([[]],-1*cw,centerX,centerY,centerX-db+20,bc,db*2-40)end else bo[#bo+1]=e([[%d]],centerX-db+10,bc,i)bo[#bo+1]=e([[%d]],centerX+db-10,bc,i)end;d9=e([[%s M %d %f h %d]],d9,centerX+db,bc,len)else d9=e([[%s M %d %f h %d]],d9,centerX-db-len,bc,len)d9=e([[%s M %d %f h %d]],d9,centerX+db,bc,len)end end;bo[#bo+1]=d9 ..[["/>]]local dd="PITCH"if not cD then dd="REL PITCH"end;if cx>90 and not ad then cx=90-(cx-90)elseif cx<-90 and not ad then cx=-90-(cx+90)end;if d0>200 then if ad then if b5>w then bo[#bo+1]=e([["
-
- %s
- %d deg
-
- ]],centerX,centerY-15,"Yaw",centerX,centerY+20,da)end;bo[#bo+1]=e([[]],-cw,centerX,centerY)else bo[#bo+1]=e([[]],centerX,centerY)end;bo[#bo+1]=e([[< class="pdim txtend">%d]],centerX-db+25,centerY-5,centerX-db+20,centerY,centerX-db+25,centerY+5,centerX-db+50,centerY+4,dc)bo[#bo+1]=e([[< class="pdim txtend">%d]],centerX+db-25,centerY-5,centerX+db-20,centerY,centerX+db-25,centerY+5,centerX+db-30,centerY+4,dc)bo[#bo+1]=""end;local de=d(d0/3)bo[#bo+1]=e([[]],centerX-de,centerY,d0-de)if not ad and cD then bo[#bo+1]=e([[]],-1*cw,centerX,centerY,centerX-db+10,centerY,db*2-20)end;bo[#bo+1]=""if d0<200 then if ad and b5>w then bo[#bo+1]=e([["
-
- %s
- %d deg
- %s
- %d deg
-
- ]],centerX,centerY-d0,dd,centerX,centerY-d0+10,dc,centerX,centerY-15,"Yaw",centerX,centerY+20,da)else bo[#bo+1]=e([["
-
- %s
- %d deg
-
- ]],centerX,centerY-d0,dd,centerX,centerY-d0+15,dc)end end end end;function DrawAltitudeDisplay(bo,cq,cD)local df=altMeterX;local dg=altMeterY;local dh=78;local di=19;local dj=AboveGroundLevel()if dj~=-1 then table.insert(bo,e([[
-
- AGL: %.1fm
+ ]],centerX,centerY-db,dp,centerX,centerY-db+15,dn)end end end end;function DrawAltitudeDisplay(bz,cB,cO)local dr=altMeterX;local ds=altMeterY;local dt=78;local du=19;local dv=AboveGroundLevel()if dv~=-1 then table.insert(bz,e([[
+
+ AGL: %.1fm
+
+ ]],dr+dt,ds+du+20,dv))end;if cO and(cB<200000 and not ad or cB and ad)then table.insert(bz,e([[
+
+
+
+ ]],dr-1,ds-4,dt+2,du+6,dr+1,ds-1,dt-4,du))local by=0;local dw=1;local dx=0;local dy=cB<0;local dz=9;if dy then dz=0 end;local cB=math.abs(cB)while by<6 do local dA=11;local dB=16;local dC=9;local dD=14;local co="altsm"if by>2 then dB=dB+3;dA=dA+2;dD=dD+2;dC=dC-6;co="altbig"end;if dy then co=co.." red"end;local dE=cB/dw%10;local dF=d(dE)local dG=d((dF+1)%10)local dH=dx;if by==0 then dH=dE-dF;if dy then dH=1-dH end end;if dy and(by==0 or dx~=0)then local dI=dG;dG=dF;dF=dI end;local dJ=dB*(dH-1)local dK=dJ+dB;local bm=dr+dC+(6-by)*dA;local bn=ds+dD;table.insert(bz,e([[
+
+ %d
+ %d
- ]],df+dh,dg+di+20,dj))end;if cD and(cq<200000 and not ad or cq and ad)then table.insert(bo,e([[
-
-
-
- ]],df-1,dg-4,dh+2,di+6,df+1,dg-1,dh-4,di))local bn=0;local dk=1;local dl=0;local dm=cq<0;local dn=9;if dm then dn=0 end;local cq=math.abs(cq)while bn<6 do local dp=11;local dq=16;local dr=9;local ds=14;local cd="altsm"if bn>2 then dq=dq+3;dp=dp+2;ds=ds+2;dr=dr-6;cd="altbig"end;if dm then cd=cd.." red"end;local dt=cq/dk%10;local du=d(dt)local dv=d((du+1)%10)local dw=dl;if bn==0 then dw=dt-du;if dm then dw=1-dw end end;if dm and(bn==0 or dl~=0)then local dx=dv;dv=du;du=dx end;local dy=dq*(dw-1)local dz=dy+dq;local bb=df+dr+(6-bn)*dp;local bc=dg+ds;table.insert(bo,e([[
-
- %d
- %d
-
- ]],cd,bb,bc+dy,dv,bb,bc+dz,du))bn=bn+1;dk=dk*10;if du==dn then dl=dw else dl=0 end end;table.insert(bo,[[]])end end;function DrawPrograde(bo,velocity,b5,centerX,centerY)if b5>5 and not ad or b5>w then local d0=circleRad;local dA=20;local dB=20;local dC=vec3(velocity)local dD=getRelativePitch(dC)local dE=getRelativeYaw(dC)local dF=-dE/dB*d0;local dG=dD/dA*d0;local bb=centerX+dF;local bc=centerY+dG;local a3=math.sqrt(dF^2+dG^2)if a3',bb,bc)else local cX=math.atan(dG,dF)local dH=centerX+d0*math.cos(cX)local dI=centerY+d0*math.sin(cX)bo[#bo+1]=e('',dH,dI)end;dD=getRelativePitch(-dC)dE=getRelativeYaw(-dC)dF=-dE/dB*d0;dG=dD/dA*d0;bb=centerX+dF;bc=centerY+dG;a3=math.sqrt(dF^2+dG^2)if not ad then if a3',bb,bc)else local cX=math.atan(dG,dF)local dH=centerX+d0*math.cos(cX)local dI=centerY+d0*math.sin(cX)bo[#bo+1]=e('',dH,dI)end end end end;function DrawWarnings(bo)bo[#bo+1]=e([[DU Hud Version: %.3f]],ConvertResolutionX(1900),ConvertResolutionY(1070),VERSION_NUMBER)bo[#bo+1]=[[]]if unit.isMouseControlActivated()==1 then bo[#bo+1]=e([[
- Warning: Invalid Control Scheme Detected]],ConvertResolutionX(960),ConvertResolutionY(550))bo[#bo+1]=e([[
- Keyboard Scheme must be selected]],ConvertResolutionX(960),ConvertResolutionY(600))bo[#bo+1]=e([[
- Set your preferred scheme in Lua Parameters instead]],ConvertResolutionX(960),ConvertResolutionY(650))end;local dJ=ConvertResolutionX(960)local dK=ConvertResolutionY(860)local dL=ConvertResolutionY(880)local dM=ConvertResolutionY(900)local dN=ConvertResolutionY(960)local dO=ConvertResolutionY(200)local dP=ConvertResolutionY(150)local dQ=ConvertResolutionY(960)if o()==1 and not RemoteHud then dK=ConvertResolutionY(135)dL=ConvertResolutionY(155)dM=ConvertResolutionY(175)dO=ConvertResolutionY(115)dP=ConvertResolutionY(95)end;if BrakeIsOn then bo[#bo+1]=e([[Brake Engaged]],dJ,dK)end;if ad and RateOfChangebrakeLandingRate+5 then bo[#bo+1]=e([[** STALL WARNING **]],dJ,dO+50)end;if ah then bo[#bo+1]=e([[Gyro Enabled]],dJ,dQ)end;if GearExtended then if A then bo[#bo+1]=e([[Gear Extended]],dJ,dL)else bo[#bo+1]=e([[Landed (G: Takeoff)]],dJ,dL)end;bo[#bo+1]=e([[Hover Height: %s]],dJ,dM,getDistanceDisplayString(Nav:getTargetGroundAltitude()))end;if O then bo[#bo+1]=e([[ROCKET BOOST ENABLED]],dJ,dN+20)end;if antigrav and not ExternalAGG and antigrav.getState()==1 and AntigravTargetAltitude~=nil then if math.abs(ae-antigrav.getBaseAltitude())<501 then bo[#bo+1]=e([[AGG On - Target Altitude: %d Singluarity Altitude: %d]],dJ,dO+20,d(AntigravTargetAltitude),d(antigrav.getBaseAltitude()))else bo[#bo+1]=e([[AGG On - Target Altitude: %d Singluarity Altitude: %d]],dJ,dO+20,d(AntigravTargetAltitude),d(antigrav.getBaseAltitude()))end elseif Autopilot and AutopilotTargetName~="None"then bo[#bo+1]=e([[Autopilot %s]],dJ,dO+20,AutopilotStatus)elseif LockPitch~=nil then bo[#bo+1]=e([[LockedPitch: %d]],dJ,dO+20,d(LockPitch))elseif I then bo[#bo+1]=e([[Follow Mode Engaged]],dJ,dO+20)elseif Reentry then bo[#bo+1]=e([[Parachute Re-entry in Progress]],dJ,dO+20)end;if AltitudeHold then if AutoTakeoff then bo[#bo+1]=e([[Ascent to %s]],dJ,dO,getDistanceDisplayString(HoldAltitude))if BrakeIsOn then bo[#bo+1]=e([[Throttle Up and Disengage Brake For Takeoff]],dJ,dO+50)end else bo[#bo+1]=e([[Altitude Hold: %s]],dJ,dO,getDistanceDisplayString2(HoldAltitude))end end;if BrakeLanding then if StrongBrakes then bo[#bo+1]=e([[Brake-Landing]],dJ,dO)else bo[#bo+1]=e([[Coast-Landing]],dJ,dO)end end;if ProgradeIsOn then bo[#bo+1]=e([[Prograde Alignment]],dJ,dO)end;if RetrogradeIsOn then bo[#bo+1]=e([[Retrograde Alignment]],dJ,dO)end;if TurnBurn then bo[#bo+1]=e([[Turn & Burn Braking]],dJ,dP)end;if VectorToTarget then bo[#bo+1]=e([[%s]],dJ,dO+30,VectorStatus)end;bo[#bo+1]=""end;function DisplayOrbitScreen(bo)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 dR=75;local dS=0;local dT=250;local dU=4;dS=dS+dU;local dV=15;local bb=dR+dT+dR/2+dU;local bc=dS+dT/2+5+dU;local dW,dX,dY,dZ;dW=dT/4;dZ=0;bo[#bo+1]=[[]]bo[#bo+1]=e('',dT+dR*2,dT+dS,dU,dU)if orbit.periapsis~=nil and orbit.apoapsis~=nil then dY=(orbit.apoapsis.altitude+orbit.periapsis.altitude+planet.radius*2)/(dW*2)dX=(planet.radius+orbit.periapsis.altitude+(orbit.apoapsis.altitude-orbit.periapsis.altitude)/2)/dY*(1-orbit.eccentricity)dZ=dW-orbit.periapsis.altitude/dY-planet.radius/dY;local d_=""if orbit.periapsis.altitude<=0 then d_='redout'end;bo[#bo+1]=e([[]],d_,dR+dT/2+dZ+dU,dS+dT/2+dU,dW,dX)bo[#bo+1]=e('',dR+dT/2+dU,dS+dT/2+dU,planet.radius/dY)end;if orbit.apoapsis~=nil and orbit.apoapsis.speed1 then bo[#bo+1]=e([[]],bb-35,bc-5,dR+dT/2+dW+dZ,bc-5)bo[#bo+1]=e([[Apoapsis]],bb,bc)bc=bc+dV;bo[#bo+1]=e([[%s]],bb,bc,getDistanceDisplayString(orbit.apoapsis.altitude))bc=bc+dV;bo[#bo+1]=e([[%s]],bb,bc,FormatTimeString(orbit.timeToApoapsis))bc=bc+dV;bo[#bo+1]=e([[%s]],bb,bc,getSpeedDisplayString(orbit.apoapsis.speed))end;bc=dS+dT/2+5+dU;bb=dR-dR/2+10+dU;if orbit.periapsis~=nil and orbit.periapsis.speed1 then bo[#bo+1]=e([[]],bb+35,bc-5,dR+dT/2-dW+dZ,bc-5)bo[#bo+1]=e([[Periapsis]],bb,bc)bc=bc+dV;bo[#bo+1]=e([[%s]],bb,bc,getDistanceDisplayString(orbit.periapsis.altitude))bc=bc+dV;bo[#bo+1]=e([[%s]],bb,bc,FormatTimeString(orbit.timeToPeriapsis))bc=bc+dV;bo[#bo+1]=e([[%s]],bb,bc,getSpeedDisplayString(orbit.periapsis.speed))end;bo[#bo+1]=e([[%s]],dR+dT/2+dU,20+dU,planet.name)if orbit.period~=nil and orbit.periapsis~=nil and orbit.apoapsis~=nil and orbit.apoapsis.speed>1 then local e0=orbit.timeToApoapsis/orbit.period*2*math.pi;local e1=dW*math.cos(e0)local e2=dX*math.sin(e0)bo[#bo+1]=e('',dR+dT/2+e1+dZ+dU,dS+dT/2+e2+dU)end;bo[#bo+1]=[[]]end end;function Atlas()return{[0]={[1]={GM=6930729684,bodyId=1,center={x=17465536.000,y=22665536.000,z=-34464.000},name='Madis',planetarySystemId=0,radius=44300,atmos=true,gravity=0.36},[2]={GM=157470826617,bodyId=2,center={x=-8.000,y=-8.000,z=-126303.000},name='Alioth',planetarySystemId=0,radius=126068,atmos=true,gravity=1.01},[3]={GM=11776905000,bodyId=3,center={x=29165536.000,y=10865536.000,z=65536.000},name='Thades',planetarySystemId=0,radius=49000,atmos=true,gravity=0.50},[4]={GM=14893847582,bodyId=4,center={x=-13234464.000,y=55765536.000,z=465536.000},name='Talemai',planetarySystemId=0,radius=57450,atmos=true,gravity=0.46},[5]={GM=16951680000,bodyId=5,center={x=-43534464.000,y=22565536.000,z=-48934464.000},name='Feli',planetarySystemId=0,radius=60000,atmos=true,gravity=0.48},[6]={GM=10502547741,bodyId=6,center={x=52765536.000,y=27165538.000,z=52065535.000},name='Sicari',planetarySystemId=0,radius=51100,atmos=true,gravity=0.41},[7]={GM=13033380591,bodyId=7,center={x=58665538.000,y=29665535.000,z=58165535.000},name='Sinnen',planetarySystemId=0,radius=54950,atmos=true,gravity=0.44},[8]={GM=18477723600,bodyId=8,center={x=80865538.000,y=54665536.000,z=-934463.940},name='Teoma',planetarySystemId=0,radius=62000,atmos=true,gravity=0.49},[9]={GM=18606274330,bodyId=9,center={x=-94134462.000,y=12765534.000,z=-3634464.000},name='Jago',planetarySystemId=0,radius=61590,atmos=true,gravity=0.50},[10]={GM=78480000,bodyId=10,center={x=17448118.224,y=22966846.286,z=143078.820},name='Madis Moon 1',planetarySystemId=0,radius=10000,atmos=false,gravity=0.08},[11]={GM=237402000,bodyId=11,center={x=17194626.000,y=22243633.880,z=-214962.810},name='Madis Moon 2',planetarySystemId=0,radius=11000,atmos=false,gravity=0.10},[12]={GM=265046609,bodyId=12,center={x=17520614.000,y=22184730.000,z=-309989.990},name='Madis Moon 3',planetarySystemId=0,radius=15005,atmos=false,gravity=0.12},[21]={GM=2118960000,bodyId=21,center={x=457933.000,y=-1509011.000,z=115524.000},name='Alioth Moon 1',planetarySystemId=0,radius=30000,atmos=false,gravity=0.24},[22]={GM=2165833514,bodyId=22,center={x=-1692694.000,y=729681.000,z=-411464.000},name='Alioth Moon 4',planetarySystemId=0,radius=30330,atmos=false,gravity=0.24},[26]={GM=68234043600,bodyId=26,center={x=-1404835.000,y=562655.000,z=-285074.000},name='Sanctuary',planetarySystemId=0,radius=83400,atmos=true,gravity=1.00},[30]={GM=211564034,bodyId=30,center={x=29214402.000,y=10907080.695,z=433858.200},name='Thades Moon 1',planetarySystemId=0,radius=14002,atmos=false,gravity=0.11},[31]={GM=264870000,bodyId=31,center={x=29404193.000,y=10432768.000,z=19554.131},name='Thades Moon 2',planetarySystemId=0,radius=15000,atmos=false,gravity=0.12},[40]={GM=141264000,bodyId=40,center={x=-13503090.000,y=55594325.000,z=769838.640},name='Talemai Moon 2',planetarySystemId=0,radius=12000,atmos=false,gravity=0.10},[41]={GM=106830900,bodyId=41,center={x=-12800515.000,y=55700259.000,z=325207.840},name='Talemai Moon 3',planetarySystemId=0,radius=11000,atmos=false,gravity=0.09},[42]={GM=264870000,bodyId=42,center={x=-13058408.000,y=55781856.000,z=740177.760},name='Talemai Moon 1',planetarySystemId=0,radius=15000,atmos=false,gravity=0.12},[50]={GM=499917600,bodyId=50,center={x=-43902841.780,y=22261034.700,z=-48862386.000},name='Feli Moon 1',planetarySystemId=0,radius=14000,atmos=false,gravity=0.11},[70]={GM=396912600,bodyId=70,center={x=58969616.000,y=29797945.000,z=57969449.000},name='Sinnen Moon 1',planetarySystemId=0,radius=17000,atmos=false,gravity=0.14},[100]={GM=13975172474,bodyId=100,center={x=98865536.000,y=-13534464.000,z=-934461.990},name='Lacobus',planetarySystemId=0,radius=55650,atmos=true,gravity=0.46},[101]={GM=264870000,bodyId=101,center={x=98905288.170,y=-13950921.100,z=-647589.530},name='Lacobus Moon 3',planetarySystemId=0,radius=15000,atmos=false,gravity=0.12},[102]={GM=444981600,bodyId=102,center={x=99180968.000,y=-13783862.000,z=-926156.400},name='Lacobus Moon 1',planetarySystemId=0,radius=18000,atmos=false,gravity=0.14},[103]={GM=211503600,bodyId=103,center={x=99250052.000,y=-13629215.000,z=-1059341.400},name='Lacobus Moon 2',planetarySystemId=0,radius=14000,atmos=false,gravity=0.11},[110]={GM=9204742375,bodyId=110,center={x=14165536.000,y=-85634465.000,z=-934464.300},name='Symeon',planetarySystemId=0,radius=49050,atmos=true,gravity=0.39},[120]={GM=7135606629,bodyId=120,center={x=2865536.700,y=-99034464.000,z=-934462.020},name='Ion',planetarySystemId=0,radius=44950,atmos=true,gravity=0.36},[121]={GM=106830900,bodyId=121,center={x=2472916.800,y=-99133747.000,z=-1133582.800},name='Ion Moon 1',planetarySystemId=0,radius=11000,atmos=false,gravity=0.09},[122]={GM=176580000,bodyId=122,center={x=2995424.500,y=-99275010.000,z=-1378480.700},name='Ion Moon 2',planetarySystemId=0,radius=15000,atmos=false,gravity=0.12}}}end;atlas=Atlas()for aR,aS in pairs(atlas[0])do if at==nil or aS.center.xau then au=aS.center.x end;if av==nil or aS.center.yaw then aw=aS.center.y end end;GalaxyMapHTML=""local e3=1.1*(au-at)/1920;local e4=1.4*(aw-av)/1080;for aR,aS in pairs(atlas[0])do local bb=960+aS.center.x/e3;local bc=540+aS.center.y/e4;GalaxyMapHTML=GalaxyMapHTML..''if not string.match(aS.name,"Moon")and not string.match(aS.name,"Sanctuary")then GalaxyMapHTML=GalaxyMapHTML..""..aS.name..""end end;local cE=vec3(core.getConstructWorldPos())local bb=960+cE.x/e3;local bc=540+cE.y/e4;GalaxyMapHTML=GalaxyMapHTML..''GalaxyMapHTML=GalaxyMapHTML.."You Are Here"GalaxyMapHTML=GalaxyMapHTML..[[]]MapXRatio=e3;MapYRatio=e4;if screen_2 then screen_2.setHTML(']])end end;function DrawPrograde(bz,velocity,bg,centerX,centerY)if bg>5 and not ad or bg>w then local db=circleRad;local dL=20;local dM=20;local dN=vec3(velocity)local dO=getRelativePitch(dN)local dP=getRelativeYaw(dN)local dQ=-dP/dM*db;local dR=dO/dL*db;local bm=centerX+dQ;local bn=centerY+dR;local a3=math.sqrt(dQ^2+dR^2)if a3',bm,bn)else local d7=math.atan(dR,dQ)local dS=centerX+db*math.cos(d7)local dT=centerY+db*math.sin(d7)bz[#bz+1]=e('',dS,dT)end;dO=getRelativePitch(-dN)dP=getRelativeYaw(-dN)dQ=-dP/dM*db;dR=dO/dL*db;bm=centerX+dQ;bn=centerY+dR;a3=math.sqrt(dQ^2+dR^2)if not ad then if a3',bm,bn)else local d7=math.atan(dR,dQ)local dS=centerX+db*math.cos(d7)local dT=centerY+db*math.sin(d7)bz[#bz+1]=e('',dS,dT)end end end end;function DrawWarnings(bz)bz[#bz+1]=e([[DU Hud Version: %.3f]],ConvertResolutionX(1900),ConvertResolutionY(1070),VERSION_NUMBER)bz[#bz+1]=[[]]if unit.isMouseControlActivated()==1 then bz[#bz+1]=e([[
+ Warning: Invalid Control Scheme Detected]],ConvertResolutionX(960),ConvertResolutionY(550))bz[#bz+1]=e([[
+ Keyboard Scheme must be selected]],ConvertResolutionX(960),ConvertResolutionY(600))bz[#bz+1]=e([[
+ Set your preferred scheme in Lua Parameters instead]],ConvertResolutionX(960),ConvertResolutionY(650))end;local dU=ConvertResolutionX(960)local dV=ConvertResolutionY(860)local dW=ConvertResolutionY(880)local dX=ConvertResolutionY(900)local dY=ConvertResolutionY(960)local dZ=ConvertResolutionY(200)local d_=ConvertResolutionY(150)local e0=ConvertResolutionY(960)if o()==1 and not RemoteHud then dV=ConvertResolutionY(135)dW=ConvertResolutionY(155)dX=ConvertResolutionY(175)dZ=ConvertResolutionY(115)d_=ConvertResolutionY(95)end;if BrakeIsOn then bz[#bz+1]=e([[Brake Engaged]],dU,dV)end;if ad and RateOfChangebrakeLandingRate+5 then bz[#bz+1]=e([[** STALL WARNING **]],dU,dZ+50)end;if ah then bz[#bz+1]=e([[Gyro Enabled]],dU,e0)end;if GearExtended then if A then bz[#bz+1]=e([[Gear Extended]],dU,dW)else bz[#bz+1]=e([[Landed (G: Takeoff)]],dU,dW)end;bz[#bz+1]=e([[Hover Height: %s]],dU,dX,getDistanceDisplayString(Nav:getTargetGroundAltitude()))end;if O then bz[#bz+1]=e([[ROCKET BOOST ENABLED]],dU,dY+20)end;if antigrav and not ExternalAGG and antigrav.getState()==1 and AntigravTargetAltitude~=nil then if math.abs(ae-antigrav.getBaseAltitude())<501 then bz[#bz+1]=e([[AGG On - Target Altitude: %d Singluarity Altitude: %d]],dU,dZ+20,d(AntigravTargetAltitude),d(antigrav.getBaseAltitude()))else bz[#bz+1]=e([[AGG On - Target Altitude: %d Singluarity Altitude: %d]],dU,dZ+20,d(AntigravTargetAltitude),d(antigrav.getBaseAltitude()))end elseif Autopilot and AutopilotTargetName~="None"then bz[#bz+1]=e([[Autopilot %s]],dU,dZ+20,AutopilotStatus)elseif LockPitch~=nil then bz[#bz+1]=e([[LockedPitch: %d]],dU,dZ+20,d(LockPitch))elseif I then bz[#bz+1]=e([[Follow Mode Engaged]],dU,dZ+20)elseif Reentry then bz[#bz+1]=e([[Parachute Re-entry in Progress]],dU,dZ+20)end;if AltitudeHold then if AutoTakeoff then bz[#bz+1]=e([[Ascent to %s]],dU,dZ,getDistanceDisplayString(HoldAltitude))if BrakeIsOn then bz[#bz+1]=e([[Throttle Up and Disengage Brake For Takeoff]],dU,dZ+50)end else bz[#bz+1]=e([[Altitude Hold: %s]],dU,dZ,getDistanceDisplayString2(HoldAltitude))end end;if BrakeLanding then if StrongBrakes then bz[#bz+1]=e([[Brake-Landing]],dU,dZ)else bz[#bz+1]=e([[Coast-Landing]],dU,dZ)end end;if ProgradeIsOn then bz[#bz+1]=e([[Prograde Alignment]],dU,dZ)end;if RetrogradeIsOn then bz[#bz+1]=e([[Retrograde Alignment]],dU,dZ)end;if TurnBurn then bz[#bz+1]=e([[Turn & Burn Braking]],dU,d_)end;if VectorToTarget then bz[#bz+1]=e([[%s]],dU,dZ+30,VectorStatus)end;bz[#bz+1]=""end;function DisplayOrbitScreen(bz)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 e1=75;local e2=0;local e3=250;local e4=4;e2=e2+e4;local e5=15;local bm=e1+e3+e1/2+e4;local bn=e2+e3/2+5+e4;local e6,e7,e8,e9;e6=e3/4;e9=0;bz[#bz+1]=[[]]bz[#bz+1]=e('',e3+e1*2,e3+e2,e4,e4)if orbit.periapsis~=nil and orbit.apoapsis~=nil then e8=(orbit.apoapsis.altitude+orbit.periapsis.altitude+planet.radius*2)/(e6*2)e7=(planet.radius+orbit.periapsis.altitude+(orbit.apoapsis.altitude-orbit.periapsis.altitude)/2)/e8*(1-orbit.eccentricity)e9=e6-orbit.periapsis.altitude/e8-planet.radius/e8;local ea=""if orbit.periapsis.altitude<=0 then ea='redout'end;bz[#bz+1]=e([[]],ea,e1+e3/2+e9+e4,e2+e3/2+e4,e6,e7)bz[#bz+1]=e('',e1+e3/2+e4,e2+e3/2+e4,planet.radius/e8)end;if orbit.apoapsis~=nil and orbit.apoapsis.speed1 then bz[#bz+1]=e([[]],bm-35,bn-5,e1+e3/2+e6+e9,bn-5)bz[#bz+1]=e([[Apoapsis]],bm,bn)bn=bn+e5;bz[#bz+1]=e([[%s]],bm,bn,getDistanceDisplayString(orbit.apoapsis.altitude))bn=bn+e5;bz[#bz+1]=e([[%s]],bm,bn,FormatTimeString(orbit.timeToApoapsis))bn=bn+e5;bz[#bz+1]=e([[%s]],bm,bn,getSpeedDisplayString(orbit.apoapsis.speed))end;bn=e2+e3/2+5+e4;bm=e1-e1/2+10+e4;if orbit.periapsis~=nil and orbit.periapsis.speed1 then bz[#bz+1]=e([[]],bm+35,bn-5,e1+e3/2-e6+e9,bn-5)bz[#bz+1]=e([[Periapsis]],bm,bn)bn=bn+e5;bz[#bz+1]=e([[%s]],bm,bn,getDistanceDisplayString(orbit.periapsis.altitude))bn=bn+e5;bz[#bz+1]=e([[%s]],bm,bn,FormatTimeString(orbit.timeToPeriapsis))bn=bn+e5;bz[#bz+1]=e([[%s]],bm,bn,getSpeedDisplayString(orbit.periapsis.speed))end;bz[#bz+1]=e([[%s]],e1+e3/2+e4,20+e4,planet.name)if orbit.period~=nil and orbit.periapsis~=nil and orbit.apoapsis~=nil and orbit.apoapsis.speed>1 then local eb=orbit.timeToApoapsis/orbit.period*2*math.pi;local ec=e6*math.cos(eb)local ed=e7*math.sin(eb)bz[#bz+1]=e('',e1+e3/2+ec+e9+e4,e2+e3/2+ed+e4)end;bz[#bz+1]=[[]]end end;function getDistanceDisplayString(a3)local ee=a3>100000;local b5=""if ee then b5=round(a3/1000/200,1).." SU"elseif a3<1000 then b5=round(a3,1).." M"else b5=round(a3/1000,1).." KM"end;return b5 end;function getDistanceDisplayString2(a3)local ee=a3>100000;local b5=""if ee then b5=round(a3/1000/200,2).." SU"elseif a3<1000 then b5=round(a3,2).." M"else b5=round(a3/1000,2).." KM"end;return b5 end;function getSpeedDisplayString(bg)return d(round(bg*3.6,0)+0.5).." km/h"end;function FormatTimeString(ef)local eg=0;local eh=0;local ei=0;if ef<60 then ef=d(ef)elseif ef<3600 then eg=d(ef/60)ef=d(ef%60)elseif ef<86400 then eh=d(ef/3600)eg=d(ef%3600/60)else ei=d(ef/86400)eh=d(ef%86400/60)end;if ei>0 then return ei.."d "..eh.."h "elseif eh>0 then return eh.."h "..eg.."m "elseif eg>0 then return eg.."m "..ef.."s"elseif ef>0 then return ef.."s"else return"0s"end end;function getMagnitudeInDirection(cq,ej)cq=vec3(cq)ej=vec3(ej):normalize()local b5=cq*ej;return b5.x+b5.y+b5.z end;function UpdateAutopilotTarget()if AutopilotTargetIndex==0 then AutopilotTargetName="None"V=nil;return true end;local ek=AtlasOrdered[AutopilotTargetIndex].index;local el=aS[0][ek]if el.center then AutopilotTargetName=el.name;V=aY[0][ek]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 end;CustomTarget=nil else CustomTarget=el;for _,b4 in pairs(aY[0])do if b4.name==CustomTarget.planetname then V=b4;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;AutopilotTargetCoords=vec3(V.center)_,AutopilotEndSpeed=a_(V):escapeAndOrbitalSpeed(AutopilotTargetOrbit)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;UpdateAutopilotTarget()end;function DecrementAutopilotTargetIndex()AutopilotTargetIndex=AutopilotTargetIndex-1;if AutopilotTargetIndex<0 then AutopilotTargetIndex=#AtlasOrdered end;UpdateAutopilotTarget()end;function GetAutopilotMaxMass()local em=LastMaxBrakeInAtmo/V:getGravity(V.center+vec3(0,0,1)*V.radius):len()return em end;function GetAutopilotTravelTime()if not Autopilot then if CustomTarget==nil or CustomTarget.planetname~=planet.name then AutopilotDistance=(V.center-vec3(core.getConstructWorldPos())):len()else AutopilotDistance=(CustomTarget.position-vec3(core.getConstructWorldPos())):len()end end;local velocity=core.getWorldVelocity()local bg=vec3(velocity):len()local en,eo=aZ.computeDistanceAndTime(vec3(velocity):len(),MaxGameVelocity,n(),Nav:maxForceForward(),warmup,0)local P,Q;if not TurnBurn then P,Q=GetAutopilotBrakeDistanceAndTime(MaxGameVelocity)else P,Q=GetAutopilotTBBrakeDistanceAndTime(MaxGameVelocity)end;local _,ep;if not TurnBurn then _,ep=GetAutopilotBrakeDistanceAndTime(bg)else _,ep=GetAutopilotTBBrakeDistanceAndTime(bg)end;local eq=0;local er=0;if AutopilotCruising or not Autopilot and bg>5 then er=aZ.computeTravelTime(bg,0,AutopilotDistance)elseif P+en0 then return aZ.computeDistanceAndTime(bg,AutopilotEndSpeed,n(),0,0,LastMaxBrakeInAtmo-AutopilotPlanetGravity*n())else return 0,0 end end end;function GetAutopilotTBBrakeDistanceAndTime(bg)RefreshLastMaxBrake()return aZ.computeDistanceAndTime(bg,AutopilotEndSpeed,n(),Nav:maxForceForward(),warmup,LastMaxBrake-AutopilotPlanetGravity*n())end;function hoverDetectGround()local et=-1;local eu=-1;if vBooster then et=vBooster.distance()end;if hover then eu=hover.distance()end;if et~=-1 and eu~=-1 then if etProfileTimeMax then ProfileTimeMax=eA end;if eA0 then local eK=eH:find('identifiedConstructs":%[%]')if eK==nil and perisPanelID==nil then a6=1;ToggleRadarPanel()end;if eK~=nil and perisPanelID~=nil then ToggleRadarPanel()end;if radarPanelID==nil then ToggleRadarPanel()end;a4=e([[Radar: %i contacts]],eI,eJ,#eG)local eL={}for b3,b4 in pairs(eG)do if radar_1.hasMatchingTransponder(b4)==1 then eL[#eL+1]=b4 end end;if#eL>0 then local bn=ConvertResolutionY(15)local bm=ConvertResolutionX(1370)a4=e([[%sFriendlies In Range]],a4,bm,bn)for b3,b4 in pairs(eL)do bn=bn+20;a4=e([[%s%s]],a4,bm,bn,radar_1.getConstructName(b4))end end else local eM;eM=eH:find('worksInEnvironment":false')if eM then a4=e([[
+ Radar: Jammed]],eI,eJ)else a4=e([[
+ Radar: No Contacts]],eI,eJ)end;if radarPanelID~=nil then a6=0;ToggleRadarPanel()end end end end;function DisplayMessage(bz,eN)if eN~="empty"then bz[#bz+1]=[[]]for eO in string.gmatch(eN,"([^\n]+)")do bz[#bz+1]=e([[%s]],eO)end;bz[#bz+1]=[[]]end;if a2~=0 then unit.setTimer("msgTick",a2)a2=0 end end;function updateDistance()local bb=system.getTime()local velocity=vec3(core.getWorldVelocity())local cL=vec3(velocity):len()local eP=bb-ag;if cL>1.38889 then cL=cL/1000;local eQ=cL*(bb-ag)TotalDistanceTravelled=TotalDistanceTravelled+eQ;W=W+eQ end;X=X+eP;TotalFlightTime=TotalFlightTime+eP;ag=bb end;function Atlas()return{[0]={[1]={GM=6930729684,bodyId=1,center={x=17465536.000,y=22665536.000,z=-34464.000},name='Madis',planetarySystemId=0,radius=44300,atmos=true,gravity=0.36},[2]={GM=157470826617,bodyId=2,center={x=-8.000,y=-8.000,z=-126303.000},name='Alioth',planetarySystemId=0,radius=126068,atmos=true,gravity=1.01},[3]={GM=11776905000,bodyId=3,center={x=29165536.000,y=10865536.000,z=65536.000},name='Thades',planetarySystemId=0,radius=49000,atmos=true,gravity=0.50},[4]={GM=14893847582,bodyId=4,center={x=-13234464.000,y=55765536.000,z=465536.000},name='Talemai',planetarySystemId=0,radius=57450,atmos=true,gravity=0.46},[5]={GM=16951680000,bodyId=5,center={x=-43534464.000,y=22565536.000,z=-48934464.000},name='Feli',planetarySystemId=0,radius=60000,atmos=true,gravity=0.48},[6]={GM=10502547741,bodyId=6,center={x=52765536.000,y=27165538.000,z=52065535.000},name='Sicari',planetarySystemId=0,radius=51100,atmos=true,gravity=0.41},[7]={GM=13033380591,bodyId=7,center={x=58665538.000,y=29665535.000,z=58165535.000},name='Sinnen',planetarySystemId=0,radius=54950,atmos=true,gravity=0.44},[8]={GM=18477723600,bodyId=8,center={x=80865538.000,y=54665536.000,z=-934463.940},name='Teoma',planetarySystemId=0,radius=62000,atmos=true,gravity=0.49},[9]={GM=18606274330,bodyId=9,center={x=-94134462.000,y=12765534.000,z=-3634464.000},name='Jago',planetarySystemId=0,radius=61590,atmos=true,gravity=0.50},[10]={GM=78480000,bodyId=10,center={x=17448118.224,y=22966846.286,z=143078.820},name='Madis Moon 1',planetarySystemId=0,radius=10000,atmos=false,gravity=0.08},[11]={GM=237402000,bodyId=11,center={x=17194626.000,y=22243633.880,z=-214962.810},name='Madis Moon 2',planetarySystemId=0,radius=11000,atmos=false,gravity=0.10},[12]={GM=265046609,bodyId=12,center={x=17520614.000,y=22184730.000,z=-309989.990},name='Madis Moon 3',planetarySystemId=0,radius=15005,atmos=false,gravity=0.12},[21]={GM=2118960000,bodyId=21,center={x=457933.000,y=-1509011.000,z=115524.000},name='Alioth Moon 1',planetarySystemId=0,radius=30000,atmos=false,gravity=0.24},[22]={GM=2165833514,bodyId=22,center={x=-1692694.000,y=729681.000,z=-411464.000},name='Alioth Moon 4',planetarySystemId=0,radius=30330,atmos=false,gravity=0.24},[26]={GM=68234043600,bodyId=26,center={x=-1404835.000,y=562655.000,z=-285074.000},name='Sanctuary',planetarySystemId=0,radius=83400,atmos=true,gravity=1.00},[30]={GM=211564034,bodyId=30,center={x=29214402.000,y=10907080.695,z=433858.200},name='Thades Moon 1',planetarySystemId=0,radius=14002,atmos=false,gravity=0.11},[31]={GM=264870000,bodyId=31,center={x=29404193.000,y=10432768.000,z=19554.131},name='Thades Moon 2',planetarySystemId=0,radius=15000,atmos=false,gravity=0.12},[40]={GM=141264000,bodyId=40,center={x=-13503090.000,y=55594325.000,z=769838.640},name='Talemai Moon 2',planetarySystemId=0,radius=12000,atmos=false,gravity=0.10},[41]={GM=106830900,bodyId=41,center={x=-12800515.000,y=55700259.000,z=325207.840},name='Talemai Moon 3',planetarySystemId=0,radius=11000,atmos=false,gravity=0.09},[42]={GM=264870000,bodyId=42,center={x=-13058408.000,y=55781856.000,z=740177.760},name='Talemai Moon 1',planetarySystemId=0,radius=15000,atmos=false,gravity=0.12},[50]={GM=499917600,bodyId=50,center={x=-43902841.780,y=22261034.700,z=-48862386.000},name='Feli Moon 1',planetarySystemId=0,radius=14000,atmos=false,gravity=0.11},[70]={GM=396912600,bodyId=70,center={x=58969616.000,y=29797945.000,z=57969449.000},name='Sinnen Moon 1',planetarySystemId=0,radius=17000,atmos=false,gravity=0.14},[100]={GM=13975172474,bodyId=100,center={x=98865536.000,y=-13534464.000,z=-934461.990},name='Lacobus',planetarySystemId=0,radius=55650,atmos=true,gravity=0.46},[101]={GM=264870000,bodyId=101,center={x=98905288.170,y=-13950921.100,z=-647589.530},name='Lacobus Moon 3',planetarySystemId=0,radius=15000,atmos=false,gravity=0.12},[102]={GM=444981600,bodyId=102,center={x=99180968.000,y=-13783862.000,z=-926156.400},name='Lacobus Moon 1',planetarySystemId=0,radius=18000,atmos=false,gravity=0.14},[103]={GM=211503600,bodyId=103,center={x=99250052.000,y=-13629215.000,z=-1059341.400},name='Lacobus Moon 2',planetarySystemId=0,radius=14000,atmos=false,gravity=0.11},[110]={GM=9204742375,bodyId=110,center={x=14165536.000,y=-85634465.000,z=-934464.300},name='Symeon',planetarySystemId=0,radius=49050,atmos=true,gravity=0.39},[120]={GM=7135606629,bodyId=120,center={x=2865536.700,y=-99034464.000,z=-934462.020},name='Ion',planetarySystemId=0,radius=44950,atmos=true,gravity=0.36},[121]={GM=106830900,bodyId=121,center={x=2472916.800,y=-99133747.000,z=-1133582.800},name='Ion Moon 1',planetarySystemId=0,radius=11000,atmos=false,gravity=0.09},[122]={GM=176580000,bodyId=122,center={x=2995424.500,y=-99275010.000,z=-1378480.700},name='Ion Moon 2',planetarySystemId=0,radius=15000,atmos=false,gravity=0.12}}}end;function SetupAtlas()aS=Atlas()for b3,b4 in pairs(aS[0])do if av==nil or b4.center.xaw then aw=b4.center.x end;if ax==nil or b4.center.yay then ay=b4.center.y end end;aT=""local eR=1.1*(aw-av)/1920;local eS=1.4*(ay-ax)/1080;for b3,b4 in pairs(aS[0])do local bm=960+b4.center.x/eR;local bn=540+b4.center.y/eS;aT=aT..''if not string.match(b4.name,"Moon")and not string.match(b4.name,"Sanctuary")then aT=aT..""..b4.name..""end end;local cP=vec3(core.getConstructWorldPos())local bm=960+cP.x/eR;local bn=540+cP.y/eS;aT=aT..''aT=aT.."You Are Here"aT=aT..[[]]aU=eR;aV=eS;if screen_2 then screen_2.setHTML(''..aT)local cP=vec3(core.getConstructWorldPos())local bm=960+cP.x/eR;local bn=540+cP.y/eS;aT=''aT=aT.."You Are Here"aW=screen_2.addContent((bm-80)/19.20,(bn-80)/10.80,aT)end end;function PlanetRef()local function eT(eU)return type(eU)=='number'end;local function eV(eU)return type(tonumber(eU))=='number'end;local function eW(eX)return type(eX)=='table'end;local function eY(eZ)return type(eZ)=='string'end;local function e_(b4)return eW(b4)and eT(b4.x and b4.y and b4.z)end;local function f0(f1)return eW(f1)and eT(f1.latitude and f1.longitude and f1.altitude and f1.bodyId and f1.systemId)end;local f2=math.pi/180;local f3=180/math.pi;local f4=1e-10;local p=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local f5='::pos{'..p..','..p..','..p..','..p..','..p..'}'local utils=require('cpml.utils')local vec3=require('cpml.vec3')local f6=utils.clamp;local function f7(f8,f9)if f8==0 then return math.abs(f9)<1e-09 end;if f9==0 then return math.abs(f8)<1e-09 end;return math.abs(f8-f9)=0 then local g4=math.sqrt(g3)local g5=g2+g4;local g6=g2-g4;if g6>0 then return fU,g5,g6 elseif g5>0 then return fU,g5,nil end end end;return nil,nil,nil end;function fw:closestBody(g7)assert(type(g7)=='table','Invalid coordinates.')local g8,fU;local g9=vec3(g7)for _,ga in pairs(self)do local gb=(ga.center-g9):len2()if not fU or gb=0 and gf or 2*math.pi+gf;fu=math.pi/2-math.acos(ge.z/a3)end;return setmetatable({latitude=fu,longitude=fv,altitude=cB,bodyId=self.bodyId,systemId=self.planetarySystemId},fq)end;function ff:convertToWorldCoordinates(ft)local gc=eY(ft)and fs(ft)or ft;if gc.bodyId==0 then return vec3(gc.latitude,gc.longitude,gc.altitude)end;assert(f0(gc),'Argument 1 (mapPosition) is not an instance of "MapPosition".')assert(gc.systemId==self.planetarySystemId,'Argument 1 (mapPosition) has a different planetary system ID.')assert(gc.bodyId==self.bodyId,'Argument 1 (mapPosition) has a different planetary body ID.')local gg=math.cos(gc.latitude)return self.center+(self.radius+gc.altitude)*vec3(gg*math.cos(gc.longitude),gg*math.sin(gc.longitude),math.sin(gc.latitude))end;function ff:getAltitude(fo)return(vec3(fo)-self.center):len()-self.radius end;function ff:getDistance(fo)return(vec3(fo)-self.center):len()end;function ff:getGravity(fo)local gh=self.center-vec3(fo)local gi=gh:len2()return self.GM/gi*gh/math.sqrt(gi)end;return setmetatable(aX,{__call=function(_,...)return fE(...)end})end;function Keplers()local vec3=require('cpml.vec3')local PlanetRef=PlanetRef()local function eY(eZ)return type(eZ)=='string'end;local function eW(eX)return type(eX)=='table'end;local function f7(f8,f9)if f8==0 then return math.abs(f9)<1e-09 end;if f9==0 then return math.abs(f8)<1e-09 end;return math.abs(f8-f9)0 then gz=gy;gA=gz+gt/2 end;if gA>gt then gA=gA-gt end end;return{periapsis={position=gq,speed=gs/go,circularOrbitSpeed=math.sqrt(gl/go),altitude=go-self.body.radius},apoapsis=gr and{position=gr,speed=gs/gp,circularOrbitSpeed=math.sqrt(gl/gp),altitude=gp-self.body.radius},currentVelocity=b4,currentPosition=cP,eccentricity=gn,period=gt,eccentricAnomaly=gv,meanAnomaly=gx,timeToPeriapsis=gz,timeToApoapsis=gA}end;local function gB(gC)local ga=PlanetRef.BodyParameters(gC.planetarySystemId,gC.bodyId,gC.radius,gC.center,gC.GM)return setmetatable({body=ga},Kepler)end;return setmetatable(Kepler,{__call=function(_,...)return gB(...)end})end;function Kinematics()local aZ={}local gD=30000000/3600;local gE=gD*gD;local gF=100;local function gG(b4)return 1/math.sqrt(1-b4*b4/gE)end;function aZ.computeAccelerationTime(gH,gI,gJ)local gK=gD*math.asin(gH/gD)return(gD*math.asin(gJ/gD)-gK)/gI end;function aZ.computeDistanceAndTime(gH,gJ,gL,gM,gN,gO)gN=gN or 0;gO=gO or 0;local gP=gH<=gJ;local gQ=gM*(gP and 1 or-1)/gL;local gR=-gO/gL;local gS=gQ+gR;if gP and gS<=0 or not gP and gS>=0 then return-1,-1 end;local gT,gU=0,0;if gQ~=0 and gN>0 then local gK=math.asin(gH/gD)local gV=math.pi*(gQ/2+gR)local gW=gQ*gN;local gX=gD*math.pi;local b4=function(eX)local bV=(gV*eX-gW*math.sin(math.pi*eX/2/gN)+gX*gK)/gX;local gY=math.tan(bV)return gD*gY/math.sqrt(gY*gY+1)end;local gZ=gP and function(eZ)return eZ>=gJ end or function(eZ)return eZ<=gJ end;gU=2*gN;if gZ(b4(gU))then local g_=0;while math.abs(gU-g_)>0.5 do local eX=(gU+g_)/2;if gZ(b4(eX))then gU=eX else g_=eX end end end;local h0=gH;local h1=gU/gF;for h2=1,gF do local bg=b4(h2*h1)gT=gT+(bg+h0)*h1/2;h0=bg end;if gU<2*gN then return gT,gU end;gH=h0 end;local gK=gD*math.asin(gH/gD)local b6=(gD*math.asin(gJ/gD)-gK)/gS;local h3=gE*math.cos(gK/gD)/gS;local a3=h3-gE*math.cos((gS*b6+gK)/gD)/gS;return a3+gT,b6+gU end;function aZ.computeTravelTime(gH,gI,a3)if a3==0 then return 0 end;if gI>0 then local gK=gD*math.asin(gH/gD)local h3=gE*math.cos(gK/gD)/gI;return(gD*math.acos(gI*(h3-a3)/gE)-gK)/gI end;assert(gH>0,'Acceleration and initial speed are both zero.')return a3/gH end;function aZ.lorentz(b4)return gG(b4)end;return aZ end;function script.onStart()VERSION_NUMBER=4.914;SetupComplete=false;beginSetup=coroutine.create(function()Nav.axisCommandManager:setupCustomTargetSpeedRanges(axisCommandId.longitudinal,{1000,5000,10000,20000,30000})LoadVariables()coroutine.yield()ProcessElements()coroutine.yield()SetupChecks()SetupButtons()coroutine.yield()SetupAtlas()aX=PlanetRef()aY=aX(Atlas())aZ=Kinematics()a_=Keplers()AddLocationsToAtlas()UpdateAutopilotTarget()coroutine.yield()unit.hide()system.showScreen(1)collectgarbage("collect")unit.setTimer("apTick",apTickRate)unit.setTimer("oneSecond",1)unit.setTimer("tenthSecond",1/10)if UseSatNav then unit.setTimer("fiveSecond",5)end end)end;function script.onStop()_autoconf.hideCategoryPanels()if antigrav~=nil and not ExternalAGG then antigrav.hide()end;if warpdrive~=nil then warpdrive.hide()end;core.hide()Nav.control.switchOffHeadlights()local h4=j()if door and(h4>0 or h4==0 and ae<10000)then for _,b4 in pairs(door)do b4.toggle()end end;if switch then for _,b4 in pairs(switch)do b4.toggle()end end;if forcefield and(h4>0 or h4==0 and ae<10000)then for _,b4 in pairs(forcefield)do b4.toggle()end end;if dbHud_1 then if not Y then for b3,b4 in pairs(b)do dbHud_1.setStringValue(b4,g(_G[b4]))end;for b3,b4 in pairs(a)do dbHud_1.setStringValue(b4,g(_G[b4]))end;c("Saved Variables to Datacore")end end;if button then button.activate()end end;function script.onTick(h5)if h5=="tenthSecond"then if AutopilotTargetName~="None"then if panelInterplanetary==nil then SetupInterplanetaryPanel()end;if AutopilotTargetName~=nil then local h6=CustomTarget~=nil;planetMaxMass=GetAutopilotMaxMass()system.updateData(interplanetaryHeaderText,'{"label": "Target", "value": "'..AutopilotTargetName..'", "unit":""}')travelTime=GetAutopilotTravelTime()if h6 then a3=(vec3(core.getConstructWorldPos())-CustomTarget.position):len()else a3=(AutopilotTargetCoords-vec3(core.getConstructWorldPos())):len()end;if not TurnBurn then P,Q=GetAutopilotBrakeDistanceAndTime(velMag)R,S=GetAutopilotBrakeDistanceAndTime(MaxGameVelocity)else P,Q=GetAutopilotTBBrakeDistanceAndTime(velMag)R,S=GetAutopilotTBBrakeDistanceAndTime(MaxGameVelocity)end;system.updateData(widgetDistanceText,'{"label": "distance", "value": "'..getDistanceDisplayString(a3)..'", "unit":""}')system.updateData(widgetTravelTimeText,'{"label": "Travel Time", "value": "'..FormatTimeString(travelTime)..'", "unit":""}')system.updateData(widgetCurBrakeDistanceText,'{"label": "Cur Brake distance", "value": "'..getDistanceDisplayString(P)..'", "unit":""}')system.updateData(widgetCurBrakeTimeText,'{"label": "Cur Brake Time", "value": "'..FormatTimeString(Q)..'", "unit":""}')system.updateData(widgetMaxBrakeDistanceText,'{"label": "Max Brake distance", "value": "'..getDistanceDisplayString(R)..'", "unit":""}')system.updateData(widgetMaxBrakeTimeText,'{"label": "Max Brake Time", "value": "'..FormatTimeString(S)..'", "unit":""}')system.updateData(widgetMaxMassText,'{"label": "Maximum Mass", "value": "'..e("%.2f tons",planetMaxMass/1000)..'", "unit":""}')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 h5=="oneSecond"then ab=false;RefreshLastMaxBrake(nil,true)updateDistance()updateRadar()updateWeapons()local bz={}local cA=GetFlightStyle()DrawOdometer(bz,W,TotalDistanceTravelled,cA,X)CheckDamage(bz)a5=table.concat(bz,"")collectgarbage("collect")elseif h5=="fiveSecond"then ac=dbHud_1.getStringValue("SPBAutopilotTargetName")if ac~=nil and ac~=""and ac~="SatNavNotChanged"then local b5=json.decode(dbHud_1.getStringValue("SavedLocations"))if b5~=nil then _G["SavedLocations"]=b5;local by=-1;local bx;for b3,b4 in pairs(SavedLocations)do if b4.name and b4.name=="SatNav Location"then by=b3;break end end;if by~=-1 then bx=SavedLocations[by]by=-1;for b3,b4 in pairs(aS[0])do if b4.name and b4.name=="SatNav Location"then by=b3;break end end;if by>-1 then aS[0][by]=bx end;UpdateAtlasLocationsList()K=bx.name.." position updated"end end;for i=1,#AtlasOrdered do if AtlasOrdered[i].name==ac then AutopilotTargetIndex=i;system.print("Index = "..AutopilotTargetIndex.." "..AtlasOrdered[i].name)UpdateAutopilotTarget()dbHud_1.setStringValue("SPBAutopilotTargetName","SatNavNotChanged")break end end end elseif h5=="msgTick"then local bz={}DisplayMessage(bz,"empty")K="empty"unit.stopTimer("msgTick")a2=3 elseif h5=="animateTick"then b1=true;b0=false;a0=0;a1=0;unit.stopTimer("animateTick")elseif h5=="apTick"then local o=o;RateOfChange=vec3(core.getConstructWorldOrientationForward()):dot(vec3(core.getWorldVelocity()):normalize())ad=j()>0;D=0;H=0;C=0;LastApsDiff=-1;velocity=vec3(core.getWorldVelocity())velMag=vec3(velocity):len()sys=aY[0]planet=sys:closestBody(core.getConstructWorldPos())kepPlanet=a_(planet)orbit=kepPlanet:orbitalParameters(core.getConstructWorldPos(),velocity)aa=hoverDetectGround()local h7=system.getMouseDeltaX()local h8=system.getMouseDeltaY()TargetGroundAltitude=Nav:getTargetGroundAltitude()local h9=velMag>8334;if not h9 and LastIsWarping then if not BrakeIsOn then BrakeToggle()end;if Autopilot then ToggleAutopilot()end end;LastIsWarping=h9;if ad and j()>0.09 then if not ai then if velMag>AtmoSpeedLimit/3.6 then BrakeIsOn=true;ai=true end else if velMag]],ResolutionX,ResolutionY)if K~="empty"then DisplayMessage(bz,K)end;if o()==0 and userControlScheme=="virtual joystick"then DrawDeadZone(bz)end;if o()==1 and screen_1 and screen_1.getMouseY()~=-1 then a0=screen_1.getMouseX()*ResolutionX;a1=screen_1.getMouseY()*ResolutionY;SetButtonContains()DrawButtons(bz)if screen_1.getMouseState()==1 then CheckButtons()end;bz[#bz+1]=e([[]],s,t,a0,a1)elseif system.isViewLocked()==0 then if o()==1 and J then if not b0 then a0=a0+h7;a1=a1+h8 end;SetButtonContains()DrawButtons(bz)if not b0 and not b1 then local ha=table.concat(bz,"")bz={}bz[#bz+1]=e("",ResolutionX,ResolutionY)bz[#bz+1]=aT;bz[#bz+1]=ha;bz[#bz+1]=""b0=true;bz[#bz+1]=[[