From 2b68722708304cb084634208e1ddbe919ad91201 Mon Sep 17 00:00:00 2001 From: Archaegeo <30728822+Archaegeo@users.noreply.github.com> Date: Fri, 4 Dec 2020 05:25:48 -0500 Subject: [PATCH] Copied the NoAP version file here to free up fork --- ButtonHUD-NoAP.conf | 310 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 310 insertions(+) create mode 100644 ButtonHUD-NoAP.conf diff --git a/ButtonHUD-NoAP.conf b/ButtonHUD-NoAP.conf new file mode 100644 index 0000000..38909c2 --- /dev/null +++ b/ButtonHUD-NoAP.conf @@ -0,0 +1,310 @@ +name: ButtonsHud - NoAutopilot - Dimencia and Archaegeo v1.03 (Minified) +slots: + core: + class: CoreUnit + radar: + class: RadarPVPUnit + select: manual + antigrav: + class: AntiGravityGeneratorUnit + warpdrive: + class: WarpDriveUnit + gyro: + class: GyroUnit + weapon: + class: WeaponUnit + select: manual + dbHud: + class: databank + vBooster: + class: VerticalBooster + hover: + class: Hovercraft + door: + class: DoorUnit + select: manual + forcefield: + class: ForceFieldUnit + select: manual + atmofueltank: + class: AtmoFuelContainer + select: manual + spacefueltank: + class: SpaceFuelContainer + select: manual + rocketfueltank: + class: RocketFuelContainer + select: manual +handlers: + unit: + start: + lua: | + -- error handling code added by wrap.lua + __wrap_lua__stopped = false + __wrap_lua__stopOnError = false + __wrap_lua__rethrowErrorAlways = false + __wrap_lua__rethrowErrorIfStopped = true + __wrap_lua__printError = true + __wrap_lua__showErrorOnScreens = true + + function __wrap_lua__error (message) + if __wrap_lua__stopped then return end + + -- make the traceback more readable and escape HTML syntax characters + message = tostring(message):gsub('"%-%- |STDERROR%-EVENTHANDLER[^"]*"', 'chunk'):gsub("&", "&"):gsub("<", "<"):gsub(">", ">") + + local unit = unit or self or {} + + if __wrap_lua__showErrorOnScreens then + for _, value in pairs(unit) do + if type(value) == "table" and value.setCenteredText and value.setHTML then -- value is a screen + if message:match("\n") then + value.setHTML([[ +
+        Error: ]] .. message .. [[
+        
]]) + else + value.setCenteredText(message) + end + end + end + end + + if __wrap_lua__printError and system and system.print then + system.print("Error: " .. message:gsub("\n", "
")) + end + + if __wrap_lua__stopOnError then + __wrap_lua__stopped = true + end + + if __wrap_lua__stopped and unit and unit.exit then + unit.exit() + end + + if __wrap_lua__rethrowErrorAlways or (__wrap_lua__stopped and __wrap_lua__rethrowErrorIfStopped) then + error(message) + end + end + + -- in case traceback is removed or renamed + __wrap_lua__traceback = traceback or (debug and debug.traceback) or function (arg1, arg2) return arg2 or arg1 end + + local ok, message = xpcall(function () + + -- script code + + useTheseSettings = false --export: Toggle on to use the below preferences. Toggle off to use saved preferences. Preferences will save regardless when exiting seat. + freeLookToggle = true --export: Set to false for default free look behavior. + BrakeToggleDefault = true --export: Whether your brake toggle is on/off by default. Can be adjusted in the button menu + RemoteFreeze = false --export: Whether or not to freeze you when using a remote controller. Breaks some things, only freeze on surfboards + RemoteHud = false --export: Whether you want full HUD while in remote mode + userControlScheme = "Virtual Joystick" --export: Set to "Virtual Joystick", "Mouse", or "Keyboard" + brightHud = false --export: Enable to prevent hud dimming when in freelook. + PrimaryR = 130 --export: Primary HUD color + PrimaryG = 224 --export: Primary HUD color + PrimaryB = 255 --export: Primary HUD color + centerX = 960 --export: X postion of Artifical Horizon (KSP Navball), also determines placement of throttle. (use 1920x1080, it will scale) Default 960. Use centerX=700 and centerY=980 for lower left placement. + centerY = 540 --export: Y postion of Artifical Horizon (KSP Navball), also determines placement of throttle. (use 1920x1080, it will scale) Default 540. Use centerX=700 and centerY=980 for lower left placement. + throtPosX = 1300 --export: X position of Throttle Indicator, default 1300 to put it to right of default AH centerX parameter. + throtPosY = 540 --export: Y position of Throttle indicator, default is 540 to place it centered on default AH centerY parameter. + vSpdMeterX = 1525 --export: X postion of Vertical Speed Meter. Default 1525 (use 1920x1080, it will scale) + vSpdMeterY = 250 --export: Y postion of Vertical Speed Meter. Default 250 (use 1920x1080, it will scale) + altMeterX = 550 --export: X postion of Altimeter. Default 550 (use 1920x1080, it will scale) + altMeterY = 540 --export: Y postion of Altimeter. Default 500 (use 1920x1080, it will scale) + fuelX = 100 --export: X position of fuel tanks, default is 100 for left side, set both fuelX and fuelY to 0 to hide fuel + fuelY = 350 --export: Y position of fuel tanks, default 350 for left side, set both fuelX and fuelY to 0 to hide fuel + circleRad = 400 --export: The size of the artifical horizon circle, set to 0 to remove. + DeadZone = 50 --export: Number of pixels of deadzone at the center of the screen + StallAngle = 35 --export: Determines how much Autopilot is allowed to make you yaw/pitch in atmosphere. Also gives a stall warning. (default 35, higher = more tolerance for yaw/pitch/roll) + showHud = true --export: Uncheck to hide the HUD and only use autopilot features via ALT+# keys. + hideHudOnToggleWidgets = true --export: Uncheck to keep showing HUD when you toggle on the widgets via ALT+3. + ShiftShowsRemoteButtons = true --export: Whether or not pressing Shift in remote controller mode shows you the buttons (otherwise no access to them) + speedChangeLarge = 5 --export: The speed change that occurs when you tap speed up/down, default is 5 (25% throttle change). + speedChangeSmall = 1 --export: the speed change that occurs while you hold speed up/down, default is 1 (5% throttle change). + TargetHoverHeight = 50 --export: Hover height when retracting landing gear + LandingGearGroundHeight = 0 --export: Set to hover height reported - 1 when you use alt-spacebar to just lift off ground from landed postion. 4 is M size landing gear, + MouseYSensitivity = 0.003 --export:1 For virtual joystick only + MouseXSensitivity = 0.003 --export: For virtual joystick only + pitchSpeedFactor = 0.8 --export: For keyboard control + yawSpeedFactor = 1 --export: For keyboard control + rollSpeedFactor = 1.5 --export: This factor will increase/decrease the player input along the roll axis
(higher value may be unstable)
Valid values: Superior or equal to 0.01 + brakeSpeedFactor = 3 --export: When braking, this factor will increase the brake force by brakeSpeedFactor * velocity
Valid values: Superior or equal to 0.01 + brakeFlatFactor = 1 --export: When braking, this factor will increase the brake force by a flat brakeFlatFactor * velocity direction>
(higher value may be unstable)
Valid values: Superior or equal to 0.01 + fuelTankHandlingAtmo = 0 --export: For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. + fuelTankHandlingSpace = 0 --export: For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. + fuelTankHandlingRocket = 0 --export: For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks. + apTickRate = 0.0166667 --export: Set the Tick Rate for your HUD. 0.016667 is effectively 60 fps and the default value. 0.03333333 is 30 fps. The bigger the number the less often the autopilot and hud updates but may help peformance on slower machings. + script={}function script.onStart()SetupComplete=false;beginSetup=coroutine.create(function()Nav=Navigator.new(system,core,unit)Nav.axisCommandManager:setupCustomTargetSpeedRanges(axisCommandId.longitudinal,{1000,5000,10000,20000,30000})VERSION_NUMBER=1.03;local a=math.floor;local b=string.format;local c=json.decode;local d=json.encode;local e=core.getElementMaxHitPointsById;local f=unit.getAtmosphereDensity;local g=core.getElementHitPointsById;local h=core.getElementTypeById;local j=core.getElementMassById;local k=core.getConstructMass;local l=Nav.control.isRemoteControlled;SaveableVariables={"userControlScheme","apTickRate","freeLookToggle","PrimaryR","PrimaryG","PrimaryB","DeadZone","circleRad","MouseXSensitivity","MouseYSensitivity","MaxGameVelocity","showHud","pitchSpeedFactor","yawSpeedFactor","rollSpeedFactor","brakeSpeedFactor","brakeFlatFactor","torqueFactor","TargetHoverHeight","hideHudOnToggleWidgets","DampingMultiplier","fuelTankHandlingAtmo","fuelTankHandlingSpace","fuelTankHandlingRocket","RemoteFreeze","speedChangeLarge","speedChangeSmall","brightHud","MaxPitch","centerX","centerY","vSpdMeterX","vSpdMeterY","altMeterX","altMeterY","fuelX","fuelY","LandingGearGroundHeight","RemoteHud","StallAngle"}ToggleView=true;LastMaxBrake=0;LastMaxBrakeInAtmo=0;EmergencyWarp=false;ReentryMode=false;MousePitchFactor=1;MouseYawFactor=1;HasGear=false;PitchInput=0;PitchInput2=0;YawInput2=0;RollInput=0;YawInput=0;BrakeInput=0;RollInput2=0;HoldingCtrl=false;PrevViewLock=1;MsgText="empty"LastEccentricity=1;AntiGravButtonModifier=5;IsBoosting=false;HasSpaceRadar=false;HasAtmoRadar=false;TotalDistanceTravelled=0.0;TotalDistanceTrip=0;FlightTime=0;WipedDatabank=false;LocationIndex=0;UpAmount=0;BrakeIsOn=false;SimulatedX=0;SimulatedY=0;MsgTimer=3;TargetGroundAltitude=nil;GearExtended=nil;Distance=0;RadarMessage=""LastOdometerOutput=""Peris=0;CoreAltitude=core.getAltitude()AntigravTargetAltitude=CoreAltitude;ElementsID=core.getElementIdList()LastTravelTime=system.getTime()TotalFlightTime=0;HasGear=false;AutopilotPlanetGravity=0;DisplayOrbit=true;SavedLocations={}LandingGearGroundHeight=0;local m={}local n=""local o=true;local p={}local q=2560;local r=1440;local s=nil;local t=nil;local u=nil;local v=nil;local w=false;local x=false;local y=0;local z=nil;local A={}local B={}local C={}local D=0;local E=false;local F={}local G={}local H=a(1/apTickRate)*2;local I={}local J={}local K={}local L={}local M=false;local N=16;local O=0;AutoVariables={"brakeToggle","BrakeIsOn","DisplayOrbit","PrevViewLock","GearExtended","TargetGroundAltitude","TotalDistanceTravelled","TotalFlightTime","LastMaxBrake","LastMaxBrakeInAtmo","AntigravTargetAltitude"}if dbHud then local P=dbHud.hasKey;if not useTheseSettings then for Q,R in pairs(SaveableVariables)do if P(R)then local S=c(dbHud.getStringValue(R))if S~=nil then system.print(R.." "..dbHud.getStringValue(R))_G[R]=S;w=true end end end end;for Q,R in pairs(AutoVariables)do if P(R)then local S=c(dbHud.getStringValue(R))if S~=nil then system.print(R.." "..dbHud.getStringValue(R))_G[R]=S;w=true end end end;if useTheseSettings then MsgText="Updated user preferences used. Will be saved when you exit seat. Toggle off useTheseSettings to use saved values"elseif w then MsgText="Loaded Saved Variables (see Lua Chat Tab for list)"else MsgText="No Saved Variables Found - Stand up / leave remote to save settings"end else MsgText="No databank found, install one anywhere and rerun the autoconfigure to save variables"end;brakeToggle=BrakeToggleDefault;MinimumRateOfChange=math.cos(StallAngle*constants.deg2rad)if antigrav then if AntigravTargetAltitude==nil then AntigravTargetAltitude=CoreAltitude end;antigrav.setBaseAltitude(AntigravTargetAltitude)end;rgb=[[rgb(]]..a(PrimaryR+0.5)..","..a(PrimaryG+0.5)..","..a(PrimaryB+0.5)..[[)]]local T=[[rgb(]]..a(PrimaryR*0.9+0.5)..","..a(PrimaryG*0.9+0.5)..","..a(PrimaryB*0.9+0.5)..[[)]]coroutine.yield()for Q in pairs(ElementsID)do local U=h(ElementsID[Q])if U=="landing gear"then HasGear=true end;if U=="dynamic core"then local V=e(ElementsID[Q])if V>10000 then N=128 elseif V>1000 then N=64 elseif V>150 then N=32 end end;D=D+e(ElementsID[Q])if fuelX~=0 and fuelY~=0 then if U=="atmospheric fuel-tank"or U=="space fuel-tank"or U=="rocket fuel-tank"then local V=e(ElementsID[Q])local W=j(ElementsID[Q])local X=0;local Y=system.getTime()if U=="atmospheric fuel-tank"then local Z=400;local _=35.03;if V>10000 then Z=51200;_=5480 elseif V>1300 then Z=6400;_=988.67 elseif V>150 then Z=1600;_=182.67 end;X=W-_;if fuelTankHandlingAtmo>0 then Z=Z+Z*fuelTankHandlingAtmo*0.2 end;if X>Z then Z=X end;A[#A+1]={ElementsID[Q],core.getElementNameById(ElementsID[Q]),Z,_,X,Y}end;if U=="rocket fuel-tank"then local Z=320;local _=173.42;if V>65000 then Z=40000;_=25740 elseif V>6000 then Z=5120;_=4720 elseif V>700 then Z=640;_=886.72 end;X=W-_;if fuelTankHandlingRocket>0 then Z=Z+Z*fuelTankHandlingRocket*0.2 end;if X>Z then Z=X end;C[#C+1]={ElementsID[Q],core.getElementNameById(ElementsID[Q]),Z,_,X,Y}end;if U=="space fuel-tank"then local Z=2400;local _=182.67;if V>10000 then Z=76800;_=5480 elseif V>1300 then Z=9600;_=988.67 end;X=W-_;if fuelTankHandlingSpace>0 then Z=Z+Z*fuelTankHandlingSpace*0.2 end;if X>Z then Z=X end;B[#B+1]={ElementsID[Q],core.getElementNameById(ElementsID[Q]),Z,_,X,Y}end end end end;if gyro~=nil then GyroIsOn=gyro.getState()==1 end;if userControlScheme~="Keyboard"then system.lockView(1)else system.lockView(0)end;if f()>0 then BrakeIsOn=true end;if radar_1 then if h(radar_1.getId())=="Space Radar"then HasSpaceRadar=true else HasAtmoRadar=true end end;if door then for a0,R in pairs(door)do R.deactivate()end end;if forcefield then for a0,R in pairs(forcefield)do R.deactivate()end end;if antigrav~=nil then if antigrav.getState()==1 then antigrav.show()end end;if l()==1 and RemoteFreeze then system.freeze(1)else system.freeze(0)end;if HasGear 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 HasGear then GearExtended=true end else if GearExtended or not HasGear then Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)GearExtended=true else Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)end end;if f()>0 and not dbHud and(GearExtended or not HasGear)then BrakeIsOn=true end;WasInAtmo=f()>0;unit.hide()function refreshLastMaxBrake(a1,a2)if a1==nil then a1=core.g()end;a1=round(a1,5)if a2~=nil and a2 or(z==nil or z~=a1)then local a3=c(unit.getData()).maxBrake;if a3~=nil then LastMaxBrake=a3 end;if f()>0 then LastMaxBrakeInAtmo=a3 end;z=a1 end end;function MakeButton(a4,a5,a6,a7,a8,a9,aa,ab,ac)local ad={enableName=a4,disableName=a5,width=a6,height=a7,x=a8,y=a9,toggleVar=aa,toggleFunction=ab,drawCondition=ac,hovered=false}table.insert(p,ad)return ad end;function UpdateAtlasLocationsList()AtlasOrdered={}for Q,R in pairs(atlas[0])do table.insert(AtlasOrdered,{name=R.name,index=Q})end;local function ae(af,ag)return af.name]],DeadZone)end;function updateWeapons()if weapon then if WeaponPanelID==nil and(radarPanelID~=nil or GearExtended)then _autoconf.displayCategoryPanel(weapon,weapon_size,L_TEXT("ui_lua_widget_weapon", "Weapons"),"weapon",true)WeaponPanelID=_autoconf.panels[_autoconf.panels_size]elseif WeaponPanelID~=nil and radarPanelID==nil and not GearExtended then system.destroyWidgetPanel(WeaponPanelID)WeaponPanelID=nil end end end;function ToggleRadarPanel()if radarPanelID~=nil and Peris==0 then system.destroyWidgetPanel(radarPanelID)radarPanelID=nil;if perisPanelID~=nil then system.destroyWidgetPanel(perisPanelID)perisPanelID=nil end else if Peris==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;Peris=0 end end;function ToggleWidgets()if o 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;o=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;o=true end end;function Contains(ai,aj,a8,a9,a6,a7)if ai>a8 and aia9 and aj0 and m[11]==ElementsID[Q]then for at in pairs(m)do core.deleteSticker(m[at])end;m={}end end;ak=a(am/al*100)if ak<100 then ah[#ah+1]=[[]]ap=a(ak*2.55)aq=b("rgb(%d,%d,%d)",255-ap,ap,0)if ak<100 then ah[#ah+1]=b([[Elemental Integrity: %i %%]],aq,ak)if ao>0 then ah[#ah+1]=b([[Disabled Modules: %i Damaged Modules: %i]],aq,ao,an)elseif an>0 then ah[#ah+1]=b([[Damaged Modules: %i]],aq,an)end end;ah[#ah+1]=[[<\g>]]end end;function DrawCursorLine(ah)local au=a(utils.clamp(Distance/(q/4)*255,0,255))ah[#ah+1]=b("",SimulatedX,SimulatedY,a(PrimaryR+0.5)+au,a(PrimaryG+0.5)-au,a(PrimaryB+0.5)-au)end;function getPitch(av,aw,ag)local ax=av:cross(ag):normalize_inplace()local ay=math.acos(utils.clamp(ax:dot(-aw),-1,1))*constants.rad2deg;if ax:cross(-aw):dot(ag)<0 then ay=-ay end;return ay end;function wipeSaveVariables()if not dbHud then MsgText="No Databank Found, unable to wipe. \nYou must have a Databank attached to ship prior to running the HUD autoconfigure"MsgTimer=5 else if x then for Q,R in pairs(SaveableVariables)do dbHud.setStringValue(R,d(nil))end;for Q,R in pairs(AutoVariables)do if R~="SavedLocations"then dbHud.setStringValue(R,d(nil))end end;MsgText="Databank wiped. New variables will save after re-enter seat and exit"MsgTimer=5;x=false;w=false;WipedDatabank=true else MsgText="Press ALT-7 again to confirm wipe of ALL data"x=true end end end;function CheckButtons()for a0,R in pairs(p)do if R.hovered then if not R.drawCondition or R.drawCondition()then R.toggleFunction()end;R.hovered=false end end end;function SetButtonContains()local a8=SimulatedX+q/2;local a9=SimulatedY+r/2;for a0,R in pairs(p)do R.hovered=Contains(a8,a9,R.x,R.y,R.width,R.height)end end;function DrawButton(ah,az,hover,a8,a9,aA,aB,aC,aD,aE,aF)if type(aE)=="function"then aE=aE()end;if type(aF)=="function"then aF=aF()end;ah[#ah+1]=b(""if az then ah[#ah+1]=b("%s",aE)else ah[#ah+1]=b("%s",aF)end end;function DrawButtons(ah)local aG="rgb(50,50,50)'"local aH="rgb(210,200,200)"local aI=DrawButton;for a0,R in pairs(p)do local a5=R.disableName;local a4=R.enableName;if type(a5)=="function"then a5=a5()end;if type(a4)=="function"then a4=a4()end;if not R.drawCondition or R.drawCondition()then aI(ah,R.toggleVar(),R.hovered,R.x,R.y,R.width,R.height,aH,aG,a5,a4)end end end;function DrawTank(ah,M,a8,aJ,aK,aL,aM,aN)local aO=1;local aP=2;local aQ=3;local aR=4;local aS=5;local aT=6;local aU=""local aV=0;local aW=fuelY;local aX=fuelY+10;if l()==1 and not RemoteHud then aW=aW-50;aX=aX-50 end;ah[#ah+1]=[[]]if aK=="ATMO"then aU="atmofueltank"elseif aK=="SPACE"then aU="spacefueltank"else aU="rocketfueltank"end;aV=_G[aU.."_size"]if#aL>0 then for i=1,#aL do local U=string.sub(aL[i][aP],1,12)local aY=0;for at=1,aV do if aL[i][aP]==json.decode(unit[aU.."_"..at].getData()).name then aY=at;break end end;if M or aM[i]==nil or aN[i]==nil then local aZ=0;local a_=0;local b0=0;local b1=0;local Y=system.getTime()if aY~=0 then aN[i]=json.decode(unit[aU.."_"..aY].getData()).percentage;aM[i]=json.decode(unit[aU.."_"..aY].getData()).timeLeft;if aM[i]=="n/a"then aM[i]=0 end else b0=j(aL[i][aO])-aL[i][aR]aZ=aL[i][aQ]aN[i]=a(0.5+b0*100/aZ)a_=aL[i][aS]b1=aL[i][aT]if a_<=b0 then aM[i]=0 else aM[i]=a(0.5+b0/((a_-b0)/(Y-b1)))end;aL[i][aS]=b0;aL[i][aT]=Y end end;if U==aJ then U=b("%s %d",aK,i)end;if aY==0 then U=U.." *"end;local b2;if aM[i]==0 then b2="n/a"else b2=FormatTimeString(aM[i])end;if aN[i]~=nil then local ap=a(aN[i]*2.55)local aq=b("rgb(%d,%d,%d)",255-ap,ap,0)local b3=""if b2~="n/a"and aM[i]<120 or aN[i]<5 then if M then b3=[[class="red"]]end end;ah[#ah+1]=b([[ + %s + %d%% %s + ]],a8,aW,b3,U,a8,aX,aq,aN[i],b2)aW=aW+30;aX=aX+30 end end end;ah[#ah+1]=""end;system.showScreen(1)function getRelativePitch(velocity)velocity=vec3(velocity)local ay=-math.deg(math.atan(velocity.y,velocity.z))+180;ay=ay-90;if ay<0 then ay=360+ay end;if ay>180 then ay=-180+ay-180 end;return-ay end;function getRelativeYaw(velocity)velocity=vec3(velocity)local b4=math.deg(math.atan(velocity.y,velocity.x))-90;if b4<-180 then b4=360+b4 end;return b4 end;function ToggleAntigrav()if antigrav then if antigrav.getState()==1 then antigrav.deactivate()antigrav.hide()else if AntigravTargetAltitude==nil then AntigravTargetAltitude=CoreAltitude end;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;antigrav.activate()antigrav.show()end end end;local b5=50;local b6=260;MakeButton("Enable Brake Toggle","Disable Brake Toggle",b6,b5,q/2-b6/2,r/2+350,function()return brakeToggle end,function()brakeToggle=not brakeToggle;if brakeToggle then MsgText="Brakes in Toggle Mode"else MsgText="Brakes in Default Mode"end end)b5=60;b6=300;local a8=10;local a9=r/2-300;a9=a9+b5+20;MakeButton("Show Orbit Display","Hide Orbit Display",b6,b5,a8,a9,function()return DisplayOrbit end,function()DisplayOrbit=not DisplayOrbit;if DisplayOrbit then MsgText="Orbit Display Enabled"else MsgText="Orbit Display Disabled"end end)a9=a9+b5+20;MakeButton("Enable Repair Arrows","Disable Repair Arrows",b6,b5,a8+b6+20,a9,function()return E end,function()E=not E;if E then MsgText="Repair Arrows Enabled"else MsgText="Repair Arrows Diabled"end end,function()return l()==1 end)a9=a9+b5+20;MakeButton("Enable AGG","Disable AGG",b6,b5,a8,a9,function()return antigrav.getState()==1 end,ToggleAntigrav,function()return antigrav~=nil end)a9=a9+b5+20;MakeButton(function()return string.format("Toggle Control Scheme - Current: %s",userControlScheme)end,function()return string.format("Control Scheme: %s",userControlScheme)end,b6*2,b5,a8,a9,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 updateHud(ah)local b7=CoreAltitude;local velocity=core.getVelocity()local b8=vec3(velocity):len()local b9=vec3(core.getWorldVertical())local ba=vec3(core.getConstructWorldOrientationForward())local bb=vec3(core.getConstructWorldOrientationRight())local ay=getPitch(b9,ba,bb)local bc=getRoll(b9,ba,bb)local bd=bc;local be=ay;local bf=f()local bg=a(unit.getThrottle())local bh=b8*3.6;local bi=unit.getAxisCommandValue(0)local bj=GetFlightStyle()local bk="ROLL"local bl=unit.getClosestPlanetInfluence()>0;if bg==nil then bg=0 end;if not bl then if b8>5 then ay=getRelativePitch(velocity)bc=getRelativeYaw(velocity)else ay=0;bc=0 end;bk="YAW"end;ah[#ah+1]=LastOdometerOutput;ah[#ah+1]=n;ah[#ah+1]=RadarMessage;if O%H==0 then M=true end;if fuelX~=0 and fuelY~=0 then DrawTank(ah,M,fuelX,"Atmospheric ","ATMO",A,K,L)DrawTank(ah,M,fuelX+100,"Space fuel t","SPACE",B,I,J)DrawTank(ah,M,fuelX+200,"Rocket fuel ","ROCKET",C,F,G)end;if M then M=false;O=0 end;O=O+1;DrawVerticalSpeed(ah,b7,bf)if l()==0 or RemoteHud then if not IsInFreeLook()or brightHud then if bl then DrawRollLines(ah,centerX,centerY,bd,bk,bl)DrawArtificialHorizon(ah,be,bd,bf,centerX,centerY,bl)DrawAltitudeDisplay(ah,b7,bf)else DrawRollLines(ah,centerX,centerY,bc,bk,bl)DrawArtificialHorizon(ah,ay,bc,bf,centerX,centerY,bl)end;DrawPrograde(ah,bf,velocity,b8,centerX,centerY)end end;DrawThrottle(ah,bj,bg,bi)DrawSpeed(ah,bh)DrawWarnings(ah)DisplayOrbitScreen(ah)if screen_2 then local bm=vec3(core.getConstructWorldPos())local a8=960+bm.x/MapXRatio;local a9=450+bm.y/MapYRatio;screen_2.moveContent(YouAreHere,(a8-80)/19.2,(a9-80)/10.8)end end;function IsInFreeLook()return system.isViewLocked()==0 and userControlScheme~="Keyboard"and l()==0 end;function HUDPrologue(ah)local bn=rgb;local bo=T;local bp=rgb;local bq=T;if IsInFreeLook()and not brightHud then bn=[[rgb(]]..a(PrimaryR*0.4+0.5)..","..a(PrimaryG*0.4+0.5)..","..a(PrimaryB*0.3+0.5)..[[)]]bo=[[rgb(]]..a(PrimaryR*0.3+0.5)..","..a(PrimaryG*0.3+0.5)..","..a(PrimaryB*0.2+0.5)..[[)]]end;ah[#ah+1]=b([[ + + + + + + ]],bn,bn,bp,bp,bo,bo,bq,bq)end;function HUDEpilogue(ah)ah[#ah+1]=""end;function DrawSpeed(ah,bh)local br=throtPosY-10;local bs=throtPosX+10;ah[#ah+1]=[[]]if l()==1 and not RemoteHud then br=75 end;ah[#ah+1]=b([[ + + %d km/h + + ]],bs,br,a(bh))end;function DrawOdometer(ah,TotalDistanceTrip,TotalDistanceTravelled,bj,bt)local bu=1240;local bv=55;local bw=65;local bf=f()local a1=core.g()local bx=0;local by=0;refreshLastMaxBrake(a1)maxThrust=Nav:maxForceForward()y=k()local bz=vec3(core.getWorldAcceleration()):len()/9.80665;if a1>0.1 then by=y*a1;bx=maxThrust/a1 end;ah[#ah+1]=[[]]if l()==1 and not RemoteHud then bu=1120;bv=55;bw=65 elseif bf>0 then ah[#ah+1]=b([[ + ATMOSPHERE + %.2f + ]],bf)end;ah[#ah+1]=b([[ + + + GRAVITY + %.2f g + ACCEL + %.2f g + ]],bu,bv,bu,bw,a1/9.80665,bu,bv+20,bu,bw+20,bz)ah[#ah+1]=[[ + ]]if l()==0 or RemoteHud then ah[#ah+1]=b([[ + Trip: %.2f km + Lifetime: %.2f Mm + Trip Time: %s + Total Time: %s + Mass: %.2f Tons + Max Brake: %.2f kN + Max Thrust: %.2f kN + %s + ]],TotalDistanceTrip,TotalDistanceTravelled/1000,FormatTimeString(bt),FormatTimeString(TotalFlightTime),y/1000,LastMaxBrake/1000,maxThrust/1000,bj)if a1>0.1 then ah[#ah+1]=b([[ + Max Mass: %.2f Tons + Req Thrust: %.2f kN + ]],bx/1000,by/1000)else ah[#ah+1]=[[ + Max Mass: n/a + Req Thrust: n/a + ]]end else ah[#ah+1]=b([[%s]],bj)end;ah[#ah+1]=""end;function DrawThrottle(ah,bj,bg,bi)local aW=throtPosY+10;local aX=throtPosY+20;if l()==1 and not RemoteHud then aW=55;aX=65 end;local bA="CRUISE"local unit="km/h"local bB=bi;if bj=="TRAVEL"or bj=="AUTOPILOT"then bA="THROT"unit="%"bB=bg;local bC="dim"if bg<0 then bC="red"end;ah[#ah+1]=b([[ + + + + ]],bC,throtPosX-7,throtPosY-50,throtPosX,throtPosY-50,throtPosX,throtPosY+50,throtPosX-7,throtPosY+50,1-math.abs(bg),throtPosX-10,throtPosY+50,throtPosX-15,throtPosY+53,throtPosX-15,throtPosY+47)end;ah[#ah+1]=b([[ + + %s + %d %s + + ]],throtPosX+10,aW,bA,throtPosX+10,aX,bB,unit)end;function DrawVerticalSpeed(ah,b7,bf)if b7<200000 and bf==0 or b7 and bf>0 then local velocity=vec3(core.getWorldVelocity())local bD=vec3(core.getWorldVertical())*-1;local bE=velocity.x*bD.x+velocity.y*bD.y+velocity.z*bD.z;local bF=0;if math.abs(bE)>1 then bF=45*math.log(math.abs(bE),10)if bE<0 then bF=-bF end end;ah[#ah+1]=b([[ + + 1000 + 100 + 10 + O + -10 + -100 + -1000 + %d m/s + + + + + + + ]],vSpdMeterX,vSpdMeterY,a(bE),a(bF))end end;function getHeading(aw)local bD=-vec3(core.getWorldVertical())aw=aw-aw:project_on(bD)local bG=vec3(0,0,1)bG=bG-bG:project_on(bD)local bH=bG:cross(bD)local bF=bG:angle_between(aw)*constants.rad2deg;if aw:dot(bH)<0 then bF=360-bF end;return bF end;function DrawRollLines(ah,centerX,centerY,bd,bk,bl)local bI=circleRad;local bJ=20;bJ=math.floor(bJ)local bK=a(bd)if bl then for i=-45,45,5 do local bL=i;ah[#ah+1]=b([[]],bL,centerX,centerY)len=5;if i%15==0 then len=15 elseif i%10==0 then len=10 end;ah[#ah+1]=b([[]],centerX,centerY+bI+bJ-len,centerX,centerY+bI+bJ)end;ah[#ah+1]=b([[" + + %s + %d deg + + ]],centerX,centerY+bI+bJ-35,bk,centerX,centerY+bI+bJ-25,bK)ah[#ah+1]=b([[]],-bd,centerX,centerY)ah[#ah+1]=b([[<]],centerX-5,centerY+bI+bJ-20,centerX+5,centerY+bI+bJ-20,centerX,centerY+bI+bJ-15)ah[#ah+1]=""end;local b4=bK;if bl then b4=getHeading(vec3(core.getConstructWorldOrientationForward()))end;local bM=20;local bN=a(b4)local bO=0;local bP=centerY+bI+bJ+20;local bQ=centerX;if bk~="YAW"then bP=130;bQ=960 end;local bR=[[%d]],a8+5,bP-12,bS)elseif i%5==0 then bO=5 end;if bO==10 then bR=b([[%s M %f %f v %d]],bR,a8,bP-5,bO)else bR=b([[%s M %f %f v %d]],bR,a8,bP-2.5,bO)end end;ah[#ah+1]=bR..[["/>]]ah[#ah+1]=b([[<]],bQ-5,bP+10,bQ+5,bP+10,bQ,bP+5)if bl then bk="HDG"end;ah[#ah+1]=b([[" + + %d deg + %s + + ]],bQ,bP+25,bN,bQ,bP+35,bk)end;function DrawArtificialHorizon(ah,be,bd,bf,centerX,centerY,bl)local bI=circleRad;local bT=math.floor(bI*3/5)if bI>0 then local bU=a(be)local len=0;local bR=b([[]],bI-1,centerX,centerY)ah[#ah+1]=[[]]for i=a(bU-30-bU%5+0.5),a(bU+30+bU%5+0.5),5 do if i%10==0 then len=30 elseif i%5==0 then len=20 end;local a9=centerY+-i*5+be*5;if len==30 then bR=b([[%s M %d %f h %d]],bR,centerX-bT-len,a9,len)if bf>0 then ah[#ah+1]=b([[%d]],-1*bd,centerX,centerY,centerX-bT+10,a9,i)ah[#ah+1]=b([[%d]],-1*bd,centerX,centerY,centerX+bT-10,a9,i)if i==0 or i==180 or i==-180 then ah[#ah+1]=b([[]],-1*bd,centerX,centerY,centerX-bT+10,a9,bT*2-20)end else ah[#ah+1]=b([[%d]],centerX-bT+10,a9,i)ah[#ah+1]=b([[%d]],centerX+bT-10,a9,i)end;bR=b([[%s M %d %f h %d]],bR,centerX+bT,a9,len)else bR=b([[%s M %d %f h %d]],bR,centerX-bT-len,a9,len)bR=b([[%s M %d %f h %d]],bR,centerX+bT,a9,len)end end;ah[#ah+1]=bR..[["/>]]local bV="PITCH"if not bl then bV="REL PITCH"end;if be>90 and bf==0 then be=90-(be-90)elseif be<-90 and bf==0 then be=-90-(be+90)end;if bI>200 then if bf>0 then ah[#ah+1]=b([[]],-bd,centerX,centerY)else ah[#ah+1]=b([[]],centerX,centerY)end;ah[#ah+1]=b([[< class="pdim txtend">%d]],centerX-bT+25,centerY-5,centerX-bT+20,centerY,centerX-bT+25,centerY+5,centerX-bT+50,centerY+4,bU)ah[#ah+1]=b([[< class="pdim txtend">%d]],centerX+bT-25,centerY-5,centerX+bT-20,centerY,centerX+bT-25,centerY+5,centerX+bT-30,centerY+4,bU)ah[#ah+1]=""end;ah[#ah+1]=b([[]],centerX-50,centerY)if bf==0 and bl then ah[#ah+1]=b([[]],-1*bd,centerX,centerY,centerX-bT+10,centerY,bT*2-20)end;ah[#ah+1]=""if bI<200 then ah[#ah+1]=b([[" + + %s + %d deg + + ]],centerX,centerY-bI,bV,centerX,centerY-bI+10,bU)end end end;function DrawAltitudeDisplay(ah,b7,bf)if b7<200000 and bf==0 or b7 and bf>0 then local bW=altMeterX;local bX=altMeterY;local bY=78;local bZ=19;table.insert(ah,b([[ + + + + ]],bW-1,bX-4,bY+2,bZ+6,bW+1,bX-1,bY-4,bZ))local b_=0;local c0=1;local c1=0;local c2=b7<0;local c3=9;if c2 then c3=0 end;local b7=math.abs(b7)while b_<6 do local c4=11;local c5=16;local c6=9;local c7=14;local b3="altsm"if b_>2 then c5=c5+3;c4=c4+2;c7=c7+2;c6=c6-6;b3="altbig"end;if c2 then b3=b3 .." red"end;local c8=b7/c0%10;local c9=a(c8)local ca=a((c9+1)%10)local cb=c1;if b_==0 then cb=c8-c9;if c2 then cb=1-cb end end;if c2 and(b_==0 or c1~=0)then local cc=ca;ca=c9;c9=cc end;local cd=c5*(cb-1)local ce=cd+c5;local a8=bW+c6+(6-b_)*c4;local a9=bX+c7;table.insert(ah,b([[ + + %d + %d + + ]],b3,a8,a9+cd,ca,a8,a9+ce,c9))b_=b_+1;c0=c0*10;if c9==c3 then c1=cb else c1=0 end end;table.insert(ah,[[]])end end;function DrawPrograde(ah,bf,velocity,b8,centerX,centerY)if b8>5 and bf==0 then local bI=circleRad;local cf=20;local cg=20;local ch=vec3(velocity)local ci=getRelativePitch(ch)local cj=getRelativeYaw(ch)local ck=-cj/cg*bI;local cl=ci/cf*bI;local a8=centerX+ck;local a9=centerY+cl;local cm=math.sqrt(ck^2+cl^2)if cm',a8,a9)else local bF=math.atan(cl,ck)local cn=centerX+bI*math.cos(bF)local co=centerY+bI*math.sin(bF)ah[#ah+1]=b('',cn,co)end;ci=getRelativePitch(-ch)cj=getRelativeYaw(-ch)ck=-cj/cg*bI;cl=ci/cf*bI;a8=centerX+ck;a9=centerY+cl;cm=math.sqrt(ck^2+cl^2)if bf==0 then if cm',a8,a9)else local bF=math.atan(cl,ck)local cn=centerX+bI*math.cos(bF)local co=centerY+bI*math.sin(bF)ah[#ah+1]=b('',cn,co)end end end end;function DrawWarnings(ah)ah[#ah+1]=b([[DU Hud Version: %.3f]],VERSION_NUMBER)ah[#ah+1]=[[]]if unit.isMouseControlActivated()==1 then ah[#ah+1]=[[Warning: Invalid Control Scheme Detected]]ah[#ah+1]=[[Keyboard Scheme must be selected]]ah[#ah+1]=[[Set your preferred scheme in Lua Parameters instead]]end;local cp=960;local cq=860;local cr=880;local cs=900;local ct=960;local cu=200;local cv=960;if l()==1 and not RemoteHud then cq=135;cr=155;cs=175;cu=115;turnBurnY=95 end;if BrakeIsOn then ah[#ah+1]=b([[Brake Engaged]],cp,cq)end;if GyroIsOn then ah[#ah+1]=b([[Gyro Enabled]],cp,cv)end;if f()~=0 and RateOfChange40 then ah[#ah+1]=b([[** STALL WARNING **]],cp,cu+25)end;if GearExtended then if HasGear then ah[#ah+1]=b([[Gear Extended]],cp,cr)else ah[#ah+1]=b([[Landed (G: Takeoff)]],cp,cr)end;ah[#ah+1]=b([[Hover Height: %s]],cp,cs,getDistanceDisplayString(Nav:getTargetGroundAltitude()))end;if IsBoosting then ah[#ah+1]=b([[ROCKET BOOST ENABLED]],cp,ct+20)end;if antigrav and antigrav.getState()==1 and AntigravTargetAltitude~=nil then if math.abs(CoreAltitude-antigrav.getBaseAltitude())<501 then ah[#ah+1]=b([[AGG On - Target Altitude: %d Singluarity Altitude: %d]],cp,cu+20,a(AntigravTargetAltitude),a(antigrav.getBaseAltitude()))else ah[#ah+1]=b([[AGG On - Target Altitude: %d Singluarity Altitude: %d]],cp,cu+20,a(AntigravTargetAltitude),a(antigrav.getBaseAltitude()))end end;ah[#ah+1]=""end;function DisplayOrbitScreen(ah)if orbit~=nil and unit.getAtmosphereDensity()<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 cw=75;local cx=0;local cy=250;local cz=4;cx=cx+cz;local cA=15;local a8=cw+cy+cw/2+cz;local a9=cx+cy/2+5+cz;local cB,cC,cD,cE;cB=cy/4;cE=0;ah[#ah+1]=[[]]ah[#ah+1]=b('',cy+cw*2,cy+cx,cz,cz)if orbit.periapsis~=nil and orbit.apoapsis~=nil then cD=(orbit.apoapsis.altitude+orbit.periapsis.altitude+planet.radius*2)/(cB*2)cC=(planet.radius+orbit.periapsis.altitude+(orbit.apoapsis.altitude-orbit.periapsis.altitude)/2)/cD*(1-orbit.eccentricity)cE=cB-orbit.periapsis.altitude/cD-planet.radius/cD;local cF=""if orbit.periapsis.altitude<=0 then cF='redout'end;ah[#ah+1]=b([[]],cF,cw+cy/2+cE+cz,cx+cy/2+cz,cB,cC)ah[#ah+1]=b('',cw+cy/2+cz,cx+cy/2+cz,planet.radius/cD)end;if orbit.apoapsis~=nil and orbit.apoapsis.speed<8333.33 and orbit.apoapsis.speed>1 then ah[#ah+1]=b([[]],a8-35,a9-5,cw+cy/2+cB+cE,a9-5)ah[#ah+1]=b([[Apoapsis]],a8,a9)a9=a9+cA;ah[#ah+1]=b([[%s]],a8,a9,getDistanceDisplayString(orbit.apoapsis.altitude))a9=a9+cA;ah[#ah+1]=b([[%s]],a8,a9,FormatTimeString(orbit.timeToApoapsis))a9=a9+cA;ah[#ah+1]=b([[%s]],a8,a9,getSpeedDisplayString(orbit.apoapsis.speed))end;a9=cx+cy/2+5+cz;a8=cw-cw/2+10+cz;if orbit.periapsis~=nil and orbit.periapsis.speed<8333.33 and orbit.periapsis.speed>1 then ah[#ah+1]=b([[]],a8+35,a9-5,cw+cy/2-cB+cE,a9-5)ah[#ah+1]=b([[Periapsis]],a8,a9)a9=a9+cA;ah[#ah+1]=b([[%s]],a8,a9,getDistanceDisplayString(orbit.periapsis.altitude))a9=a9+cA;ah[#ah+1]=b([[%s]],a8,a9,FormatTimeString(orbit.timeToPeriapsis))a9=a9+cA;ah[#ah+1]=b([[%s]],a8,a9,getSpeedDisplayString(orbit.periapsis.speed))end;ah[#ah+1]=b([[%s]],cw+cy/2+cz,20+cz,planet.name)if orbit.period~=nil and orbit.periapsis~=nil and orbit.apoapsis~=nil and orbit.apoapsis.speed>1 then local cG=orbit.timeToApoapsis/orbit.period*2*math.pi;local cH=cB*math.cos(cG)local cI=cC*math.sin(cG)ah[#ah+1]=b('',cw+cy/2+cH+cE+cz,cx+cy/2+cI+cz)end;ah[#ah+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 Q,R in pairs(atlas[0])do if s==nil or R.center.xt then t=R.center.x end;if u==nil or R.center.yv then v=R.center.y end end;GalaxyMapHTML=""local cJ=1.1*(t-s)/1920;local cK=1.4*(v-u)/1080;for Q,R in pairs(atlas[0])do local a8=960+R.center.x/cJ;local a9=540+R.center.y/cK;GalaxyMapHTML=GalaxyMapHTML..''if not string.match(R.name,"Moon")and not string.match(R.name,"Sanctuary")then GalaxyMapHTML=GalaxyMapHTML..""..R.name..""end end;local bm=vec3(core.getConstructWorldPos())local a8=960+bm.x/cJ;local a9=540+bm.y/cK;GalaxyMapHTML=GalaxyMapHTML..''GalaxyMapHTML=GalaxyMapHTML.."You Are Here"GalaxyMapHTML=GalaxyMapHTML..[[]]MapXRatio=cJ;MapYRatio=cK;if screen_2 then screen_2.setHTML(''..GalaxyMapHTML)local bm=vec3(core.getConstructWorldPos())local a8=960+bm.x/cJ;local a9=540+bm.y/cK;GalaxyMapHTML=''GalaxyMapHTML=GalaxyMapHTML.."You Are Here"YouAreHere=screen_2.addContent((a8-80)/19.20,(a9-80)/10.80,GalaxyMapHTML)end;function PlanetRef()local function cL(cM)return type(cM)=='number'end;local function cN(cM)return type(tonumber(cM))=='number'end;local function cO(cP)return type(cP)=='table'end;local function cQ(cR)return type(cR)=='string'end;local function cS(R)return cO(R)and cL(R.x and R.y and R.z)end;local function cT(cU)return cO(cU)and cL(cU.latitude and cU.longitude and cU.altitude and cU.bodyId and cU.systemId)end;local cV=math.pi/180;local cW=180/math.pi;local cX=1e-10;local bS=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local cY='::pos{'..bS..','..bS..','..bS..','..bS..','..bS..'}'local utils=require('cpml.utils')local vec3=require('cpml.vec3')local cZ=utils.clamp;local function c_(d0,d1)if d0==0 then return math.abs(d1)<1e-09 end;if d1==0 then return math.abs(d0)<1e-09 end;return math.abs(d0-d1)=0 then local e0=math.sqrt(d_)local e1=dZ+e0;local e2=dZ-e0;if e2>0 then return dQ,e1,e2 elseif e1>0 then return dQ,e1,nil end end end;return nil,nil,nil end;function dp:closestBody(e3)assert(type(e3)=='table','Invalid coordinates.')local e4,dQ;local e5=vec3(e3)for a0,e6 in pairs(self)do local e7=(e6.center-e5):len2()if not dQ or e7=0 and eb or 2*math.pi+eb;dm=math.pi/2-math.acos(ea.z/cm)end;return setmetatable({latitude=dm,longitude=dn,altitude=b7,bodyId=self.bodyId,systemId=self.planetarySystemId},di)end;function d7:convertToWorldCoordinates(dl)local e8=cQ(dl)and dk(dl)or dl;if e8.bodyId==0 then return vec3(e8.latitude,e8.longitude,e8.altitude)end;assert(cT(e8),'Argument 1 (mapPosition) is not an instance of "MapPosition".')assert(e8.systemId==self.planetarySystemId,'Argument 1 (mapPosition) has a different planetary system ID.')assert(e8.bodyId==self.bodyId,'Argument 1 (mapPosition) has a different planetary body ID.')local ec=math.cos(e8.latitude)return self.center+(self.radius+e8.altitude)*vec3(ec*math.cos(e8.longitude),ec*math.sin(e8.longitude),math.sin(e8.latitude))end;function d7:getAltitude(dg)return(vec3(dg)-self.center):len()-self.radius end;function d7:getDistance(dg)return(vec3(dg)-self.center):len()end;function d7:getGravity(dg)local ed=self.center-vec3(dg)local ee=ed:len2()return self.GM/ee*ed/math.sqrt(ee)end;return setmetatable(PlanetaryReference,{__call=function(a0,...)return dz(...)end})end;function Keplers()local vec3=require('cpml.vec3')local PlanetRef=PlanetRef()local function cQ(cR)return type(cR)=='string'end;local function cO(cP)return type(cP)=='table'end;local function c_(d0,d1)if d0==0 then return math.abs(d1)<1e-09 end;if d1==0 then return math.abs(d0)<1e-09 end;return math.abs(d0-d1)0 then ev=eu;ew=ev+ep/2 end;if ew>ep then ew=ew-ep end end;return{periapsis={position=em,speed=eo/ek,circularOrbitSpeed=math.sqrt(eh/ek),altitude=ek-self.body.radius},apoapsis=en and{position=en,speed=eo/el,circularOrbitSpeed=math.sqrt(eh/el),altitude=el-self.body.radius},currentVelocity=R,currentPosition=bm,eccentricity=ej,period=ep,eccentricAnomaly=er,meanAnomaly=et,timeToPeriapsis=ev,timeToApoapsis=ew}end;local function ex(ey)local e6=PlanetRef.BodyParameters(ey.planetarySystemId,ey.bodyId,ey.radius,ey.center,ey.GM)return setmetatable({body=e6},Kepler)end;return setmetatable(Kepler,{__call=function(a0,...)return ex(...)end})end;function Kinematics()local Kinematic={}local ez=30000000/3600;local eA=ez*ez;local eB=100;local function eC(R)return 1/math.sqrt(1-R*R/eA)end;function Kinematic.computeAccelerationTime(eD,eE,eF)local eG=ez*math.asin(eD/ez)return(ez*math.asin(eF/ez)-eG)/eE end;function Kinematic.computeDistanceAndTime(eD,eF,eH,eI,eJ,eK)eJ=eJ or 0;eK=eK or 0;local eL=eD<=eF;local eM=eI*(eL and 1 or-1)/eH;local eN=-eK/eH;local eO=eM+eN;if eL and eO<=0 or not eL and eO>=0 then return-1,-1 end;local eP,eQ=0,0;if eM~=0 and eJ>0 then local eG=math.asin(eD/ez)local eR=math.pi*(eM/2+eN)local eS=eM*eJ;local eT=ez*math.pi;local R=function(cP)local aA=(eR*cP-eS*math.sin(math.pi*cP/2/eJ)+eT*eG)/eT;local eU=math.tan(aA)return ez*eU/math.sqrt(eU*eU+1)end;local eV=eL and function(cR)return cR>=eF end or function(cR)return cR<=eF end;eQ=2*eJ;if eV(R(eQ))then local eW=0;while math.abs(eQ-eW)>0.5 do local cP=(eQ+eW)/2;if eV(R(cP))then eQ=cP else eW=cP end end end;local eX=eD;local eY=eQ/eB;for eZ=1,eB do local b8=R(eZ*eY)eP=eP+(b8+eX)*eY/2;eX=b8 end;if eQ<2*eJ then return eP,eQ end;eD=eX end;local eG=ez*math.asin(eD/ez)local e_=(ez*math.asin(eF/ez)-eG)/eO;local f0=eA*math.cos(eG/ez)/eO;local cm=f0-eA*math.cos((eO*e_+eG)/ez)/eO;return cm+eP,e_+eQ end;function Kinematic.computeTravelTime(eD,eE,cm)if cm==0 then return 0 end;if eE>0 then local eG=ez*math.asin(eD/ez)local f0=eA*math.cos(eG/ez)/eE;return(ez*math.acos(eE*(f0-cm)/eA)-eG)/eE end;assert(eD>0,'Acceleration and initial speed are both zero.')return cm/eD end;function Kinematic.lorentz(R)return eC(R)end;return Kinematic end;PlanetaryReference=PlanetRef()galaxyReference=PlanetaryReference(Atlas())Kinematic=Kinematics()Kep=Keplers()function getDistanceDisplayString(cm)local f1=cm>100000;local S=""if f1 then S=round(cm/1000/200,1).." SU"elseif cm<1000 then S=round(cm,1).." M"else S=round(cm/1000,1).." KM"end;return S end;function getDistanceDisplayString2(cm)local f1=cm>100000;local S=""if f1 then S=round(cm/1000/200,2).." SU"elseif cm<1000 then S=round(cm,2).." M"else S=round(cm/1000,2).." KM"end;return S end;function getSpeedDisplayString(b8)return a(round(b8*3.6,0)+0.5).." km/h"end;function FormatTimeString(f2)local f3=a(f2/86400)local f4=a(f2/3600)local f5=a(f2/60%60)local f2=a(f2%60)if f2<0 or f4<0 or f5<0 then return"0s"end;if f3>0 then return f3 .."d "..f4 .."h "elseif f4>0 then return f4 .."h "..f5 .."m "elseif f5>0 then return f5 .."m "..f2 .."s"else return f2 .."s"end end;function getMagnitudeInDirection(f6,dN)f6=vec3(f6)dN=vec3(dN):normalize()local S=f6*dN;return S.x+S.y+S.z end;function GetFlightStyle()local f7=Nav.axisCommandManager:getAxisCommandType(0)local bj="TRAVEL"if f7==1 then bj="CRUISE"end;return bj end;function hoverDetectGround()local f8=-1;if vBooster then f8=vBooster.distance()elseif hover then f8=hover.distance()end;return f8 end;function round(bS,f9)local fa=10^(f9 or 0)return a(bS*fa+0.5)/fa end;function tablelength(fb)local fc=0;for a0 in pairs(fb)do fc=fc+1 end;return fc end;function BeginProfile(fd)ProfileTimeStart=system.getTime()end;function EndProfile(fd)local fe=system.getTime()-ProfileTimeStart;ProfileTimeSum=ProfileTimeSum+fe;ProfileCount=ProfileCount+1;if fe>ProfileTimeMax then ProfileTimeMax=fe end;if fe0 or fk==0 and CoreAltitude<10000)then for a0,R in pairs(door)do R.activate()end end;if forcefield and(fk>0 or fk==0 and CoreAltitude<10000)then for a0,R in pairs(forcefield)do R.activate()end end;if dbHud then if not WipedDatabank then for Q,R in pairs(AutoVariables)do dbHud.setStringValue(R,json.encode(_G[R]))end;for Q,R in pairs(SaveableVariables)do dbHud.setStringValue(R,json.encode(_G[R]))end;system.print("Saved Variables to Datacore")end end;if button then button.activate()end end;function script.onTick(fl)if fl=="tenthSecond"then if warpdrive~=nil then if json.decode(warpdrive.getData()).destination~="Unknown"and json.decode(warpdrive.getData()).distance>400000 then warpdrive.show()showWarpWidget=true else warpdrive.hide()showWarpWidget=false end end elseif fl=="oneSecond"then refreshLastMaxBrake(nil,true)updateDistance()updateWeapons()if radar_1 and#radar_1.getEntries()>0 then local fm;fm=radar_1.getData():find('identifiedConstructs":%[%]')if fm==nil and perisPanelID==nil then Peris=1;ToggleRadarPanel()end;if fm~=nil and perisPanelID~=nil then ToggleRadarPanel()end;if radarPanelID==nil then ToggleRadarPanel()end;local fn=radar_1.getEntries()RadarMessage=string.format([[Radar: %i contacts]],#fn)local fo={}for Q,R in pairs(fn)do if radar_1.hasMatchingTransponder(R)==1 then fo[#fo+1]=R end end;if#fo>0 then local a9=15;RadarMessage=string.format([[%sFriendlies In Range]],RadarMessage,a9)for Q,R in pairs(fo)do a9=a9+20;RadarMessage=string.format([[%s%s]],RadarMessage,a9,radar_1.getConstructName(R))end end elseif radar_1 then local fp;fp=radar_1.getData():find('worksInEnvironment":false')if fp then RadarMessage=[[Radar: Jammed]]else RadarMessage=[[Radar: No Contacts]]end;if radarPanelID~=nil then Peris=0;ToggleRadarPanel()end end;local ah={}local bj=GetFlightStyle()DrawOdometer(ah,TotalDistanceTrip,TotalDistanceTravelled,bj,FlightTime)checkDamage(ah)LastOdometerOutput=table.concat(ah,"")collectgarbage("collect")elseif fl=="reEmergencyWarp"then if EmergencyWarp then NotTriedEmergencyWarp=true;InEmergencyWarp=true end;unit.stopTimer("reEmergencyWarp")elseif fl=="msgTick"then local ah={}DisplayMessage(ah,"empty")MsgText="empty"unit.stopTimer("msgTick")MsgTimer=3 elseif fl=="emergencyWarpTick"then if EmergencyWarp then MsgText="EMERGENCY WARP ACTIVATED"MsgTimer=5;warpdrive.activateWarp()warpdrive.show()showWarpWidget=true;EmergencyWarp=false end;unit.stopTimer("emergencyWarpTick")elseif fl=="animateTick"then Animated=true;Animating=false;SimulatedX=0;SimulatedY=0;unit.stopTimer("animateTick")elseif fl=="apTick"then local l=Nav.control.isRemoteControlled;RateOfChange=vec3(core.getConstructWorldOrientationForward()):dot(vec3(core.getWorldVelocity()):normalize())YawInput2=0;RollInput2=0;PitchInput2=0;LastApsDiff=-1;velocity=vec3(core.getWorldVelocity())velMag=vec3(velocity):len()sys=galaxyReference[0]planet=sys:closestBody(core.getConstructWorldPos())kepPlanet=Kep(planet)orbit=kepPlanet:orbitalParameters(core.getConstructWorldPos(),velocity)local fq=system.getMouseDeltaX()local fr=system.getMouseDeltaY()TargetGroundAltitude=Nav:getTargetGroundAltitude()local fs=velMag>8334;if not fs and LastIsWarping then if not BrakeIsOn then BrakeToggle()end end;LastIsWarping=fs;if BrakeIsOn then BrakeInput=1 else BrakeInput=0 end;CoreAltitude=core.getAltitude()if CoreAltitude==0 then CoreAltitude=(vec3(core.getConstructWorldPos())-planet.center):len()-planet.radius end;local ah={}HUDPrologue(ah)if showHud then updateHud(ah)else DisplayOrbitScreen(ah)DrawWarnings(ah)end;HUDEpilogue(ah)ah[#ah+1]=[[]]if MsgText~="empty"then DisplayMessage(ah,MsgText)end;if l()==0 and userControlScheme=="Virtual Joystick"then DrawDeadZone(ah)end;if l()==1 and screen_1 and screen_1.getMouseY()~=-1 then SimulatedX=screen_1.getMouseX()*2560;SimulatedY=screen_1.getMouseY()*1440;SetButtonContains()DrawButtons(ah)if screen_1.getMouseState()==1 then CheckButtons()end;ah[#ah+1]=string.format([[]],SimulatedX,SimulatedY)elseif system.isViewLocked()==0 then if l()==1 and HoldingCtrl then if not Animating then SimulatedX=SimulatedX+fq;SimulatedY=SimulatedY+fr end;SetButtonContains()DrawButtons(ah)if not Animating and not Animated then local ft=table.concat(ah,"")ah={}ah[#ah+1]=""ah[#ah+1]=GalaxyMapHTML;ah[#ah+1]=ft;ah[#ah+1]=""Animating=true;ah[#ah+1]=[[]]unit.setTimer("animateTick",0.5)local content=table.concat(ah,"")system.setScreen(content)elseif Animated then local ft=table.concat(ah,"")ah={}ah[#ah+1]=""ah[#ah+1]=GalaxyMapHTML;ah[#ah+1]=ft;ah[#ah+1]=""end;if not Animating then ah[#ah+1]=string.format([[]],SimulatedX,SimulatedY)end else CheckButtons()SimulatedX=0;SimulatedY=0 end else SimulatedX=SimulatedX+fq;SimulatedY=SimulatedY+fr;Distance=math.sqrt(SimulatedX*SimulatedX+SimulatedY*SimulatedY)if not HoldingCtrl and l()==0 then if userControlScheme=="Virtual Joystick"then if SimulatedX>0 and SimulatedX>DeadZone then YawInput2=YawInput2-(SimulatedX-DeadZone)*MouseXSensitivity elseif SimulatedX<0 and SimulatedX0 and SimulatedY>DeadZone then PitchInput2=PitchInput2-(SimulatedY-DeadZone)*MouseYSensitivity elseif SimulatedY<0 and SimulatedYDeadZone then DrawCursorLine(ah)end else SetButtonContains()DrawButtons(ah)end;ah[#ah+1]=string.format([[]],SimulatedX,SimulatedY)end;ah[#ah+1]=[[]]content=table.concat(ah,"")if not DidLogOutput then system.logInfo(LastContent)DidLogOutput=true end;LastEccentricity=orbit.eccentricity;if antigrav and CoreAltitude<200000 then if antigrav.getState()==1 then local velocity=vec3(core.getWorldVelocity())local bD=vec3(core.getWorldVertical())*-1;local bE=velocity.x*bD.x+velocity.y*bD.y+velocity.z*bD.z;local fu=antigrav.getBaseAltitude()if AntigravTargetAltitude==nil then AntigravTargetAltitude=1000 end;local fv=unit.getThrottle()if Nav.axisCommandManager:getAxisCommandType(0)==1 then fv=Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)end;local fw=math.abs(CoreAltitude-fu)if fv>-1 and fv<1 and fw>10 and fw<501 and unit.getAtmosphereDensity()<0.01 then if CoreAltitude>antigrav.getBaseAltitude()and AntigravTargetAltitude>CoreAltitude and bE<0 or CoreAltitude0 then BrakeIsOn=true else BrakeIsOn=false end end;if desiredBaseAltitude~=AntigravTargetAltitude then desiredBaseAltitude=AntigravTargetAltitude;antigrav.setBaseAltitude(desiredBaseAltitude)end else if AntigravTargetAltitude==nil then desiredBaseAltitude=CoreAltitude else desiredBaseAltitude=AntigravTargetAltitude end end end end end;function script.onFlush()local fx=2;pitchSpeedFactor=math.max(pitchSpeedFactor,0.01)yawSpeedFactor=math.max(yawSpeedFactor,0.01)rollSpeedFactor=math.max(rollSpeedFactor,0.01)fx=math.max(fx,0.01)brakeSpeedFactor=math.max(brakeSpeedFactor,0.01)brakeFlatFactor=math.max(brakeFlatFactor,0.01)local fy=utils.clamp(PitchInput+PitchInput2+system.getControlDeviceForwardInput(),-1,1)local fz=utils.clamp(RollInput+RollInput2+system.getControlDeviceYawInput(),-1,1)local fA=utils.clamp(YawInput+YawInput2-system.getControlDeviceLeftRightInput(),-1,1)local fB=BrakeInput;local fC=vec3(core.getConstructWorldOrientationUp())local fD=vec3(core.getConstructWorldOrientationForward())local fE=vec3(core.getConstructWorldOrientationRight())local fF=vec3(core.getWorldVelocity())local fG=vec3(core.getWorldVelocity()):normalize()local f=unit.getAtmosphereDensity()local fH=vec3(core.getWorldAngularVelocity())local fI=fy*pitchSpeedFactor*fE+fz*rollSpeedFactor*fD+fA*yawSpeedFactor*fC;local fJ=1;local fK=0;local fL=1;local fM=fx*(fI-fH)local fN=vec3(core.getWorldAirFrictionAngularAcceleration())fM=fM-fN;Nav:setEngineTorqueCommand('torque',fM,fJ,'airfoil','','',fL)local fO=-fB*(brakeSpeedFactor*fF+brakeFlatFactor*fG)Nav:setEngineForceCommand('brake',fO)local fP=''local fQ=vec3()local fR=false;local fS='thrust analog longitudinal'local fT=Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)if fT==axisCommandType.byThrottle then local fU=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(fS,axisCommandId.longitudinal)Nav:setEngineForceCommand(fS,fU,fJ)elseif fT==axisCommandType.byTargetSpeed then local fU=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.longitudinal)fP=fP..' , '..fS;fQ=fQ+fU;if Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)==0 or Nav.axisCommandManager:getCurrentToTargetDeltaSpeed(axisCommandId.longitudinal)<-Nav.axisCommandManager:getTargetSpeedCurrentStep(axisCommandId.longitudinal)*0.5 then fR=true end end;local fV='thrust analog lateral'local fW=Nav.axisCommandManager:getAxisCommandType(axisCommandId.lateral)if fW==axisCommandType.byThrottle then local fX=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(fV,axisCommandId.lateral)Nav:setEngineForceCommand(fV,fX,fJ)elseif fW==axisCommandType.byTargetSpeed then local fY=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.lateral)fP=fP..' , '..fV;fQ=fQ+fY end;local fZ='thrust analog vertical'local f_=Nav.axisCommandManager:getAxisCommandType(axisCommandId.vertical)if f_==axisCommandType.byThrottle then local g0=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(fZ,axisCommandId.vertical)if UpAmount~=0 or BrakeLanding then Nav:setEngineForceCommand(fZ,g0,fJ,'airfoil','ground','',fL)else Nav:setEngineForceCommand(fZ,vec3(),fJ)Nav:setEngineForceCommand('airfoil vertical',g0,fJ,'airfoil','','',fL)Nav:setEngineForceCommand('ground vertical',g0,fJ,'ground','','',fL)end elseif f_==axisCommandType.byTargetSpeed then local g1=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.vertical)fP=fP..' , '..fZ;fQ=fQ+g1 end;if fQ:len()>constants.epsilon then if BrakeInput~=0 or fR or math.abs(fG:dot(fD))<0.95 then fP=fP..', brake'end;Nav:setEngineForceCommand(fP,fQ,fK,'','','',fL)end;Nav:setBoosterCommand('rocket_engine')if IsBoosting then local b8=vec3(core.getVelocity()):len()local g2=unit.setEngineThrust;local g3=0.15;if Nav.axisCommandManager:getAxisCommandType(0)==1 then local fv=Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)if b8*3.6>fv*(1-g3)then g2('rocket_engine',0)elseif IsBoosting then g2('rocket_engine',1)end else local g4=unit.getThrottle()local g5=g4/100;if f==0 then g5=g5*8333.33;if b8>=g5*(1-g3)then g2('rocket_engine',0)elseif IsBoosting then g2('rocket_engine',1)end else g5=g5*1050/3.6;if b8>=g5*(1-g3)then g2('rocket_engine',0)elseif IsBoosting then g2('rocket_engine',1)end end end end end;function script.onUpdate()if not SetupComplete then local a0,S=coroutine.resume(beginSetup)if S then SetupComplete=true end else Nav:update()if not Animating and content~=LastContent then system.setScreen(content)end;LastContent=content end end;function script.onActionStart(g6)if g6=="gear"then GearExtended=not GearExtended;if GearExtended then BrakeIsOn=true;Nav.control.extendLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)else Nav.control.retractLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)end elseif g6=="light"then if Nav.control.isAnyHeadlightSwitchedOn()==1 then Nav.control.switchOffHeadlights()else Nav.control.switchOnHeadlights()end elseif g6=="forward"then PitchInput=PitchInput-1 elseif g6=="backward"then PitchInput=PitchInput+1 elseif g6=="left"then RollInput=RollInput-1 elseif g6=="right"then RollInput=RollInput+1 elseif g6=="yawright"then YawInput=YawInput-1 elseif g6=="yawleft"then YawInput=YawInput+1 elseif g6=="straferight"then Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.lateral,1.0)elseif g6=="strafeleft"then Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.lateral,-1.0)elseif g6=="up"then UpAmount=UpAmount+1;Nav.axisCommandManager:deactivateGroundEngineAltitudeStabilization()Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.vertical,1.0)elseif g6=="down"then UpAmount=UpAmount-1;Nav.axisCommandManager:deactivateGroundEngineAltitudeStabilization()Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.vertical,-1.0)elseif g6=="groundaltitudeup"then OldAntiMod=AntiGravButtonModifier;if antigrav and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then AntigravTargetAltitude=AntigravTargetAltitude+AntiGravButtonModifier else AntigravTargetAltitude=desiredBaseAltitude+100 end else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(1.0)end elseif g6=="groundaltitudedown"then OldAntiMod=AntiGravButtonModifier;if antigrav and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then AntigravTargetAltitude=AntigravTargetAltitude-AntiGravButtonModifier;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end else AntigravTargetAltitude=desiredBaseAltitude end else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(-1.0)end elseif g6=="option3"then if hideHudOnToggleWidgets then if showHud then showHud=false else showHud=true end end;ToggleView=false;ToggleWidgets()elseif g6=="option7"then wipeSaveVariables()ToggleView=false elseif g6=="option9"then if gyro~=nil then gyro.toggle()GyroIsOn=gyro.getState()==1 end;ToggleView=false elseif g6=="lshift"then if system.isViewLocked()==1 then HoldingCtrl=true;PrevViewLock=system.isViewLocked()system.lockView(1)elseif Nav.control.isRemoteControlled()==1 and ShiftShowsRemoteButtons then HoldingCtrl=true;Animated=false;Animating=false end elseif g6=="brake"then if brakeToggle then BrakeToggle()elseif not BrakeIsOn then BrakeToggle()else BrakeIsOn=true end elseif g6=="lalt"then if Nav.control.isRemoteControlled()==0 and not freeLookToggle and userControlScheme=="Keyboard"then system.lockView(1)end elseif g6=="booster"then IsBoosting=not IsBoosting;if IsBoosting then unit.setEngineThrust('rocket_engine',1)else unit.setEngineThrust('rocket_engine',0)end elseif g6=="stopengines"then Nav.axisCommandManager:resetCommand(axisCommandId.longitudinal)elseif g6=="speedup"then Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal,speedChangeLarge)elseif g6=="speeddown"then Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal,-speedChangeLarge)elseif g6=="antigravity"then if antigrav~=nil then ToggleAntigrav()end elseif g6=="warp"then if warpdrive~=nil then if showWarpWidget then warpdrive.hide()showWarpWidget=false else warpdrive.show()showWarpWidget=true end;if json.decode(warpdrive.getData()).buttonMsg=="CANNOT WARP"then MsgText=json.decode(warpdrive.getData()).errorMsg else warpdrive.activateWarp()warpdrive.show()showWarpWidget=true end end end end;function script.onActionStop(g6)if g6=="forward"then PitchInput=PitchInput+1 elseif g6=="backward"then PitchInput=PitchInput-1 elseif g6=="left"then RollInput=RollInput+1 elseif g6=="right"then RollInput=RollInput-1 elseif g6=="yawright"then YawInput=YawInput+1 elseif g6=="yawleft"then YawInput=YawInput-1 elseif g6=="straferight"then Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral,-1.0)elseif g6=="strafeleft"then Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral,1.0)elseif g6=="up"then UpAmount=UpAmount-1;Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical,-1.0)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization()elseif g6=="down"then UpAmount=UpAmount+1;Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical,1.0)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization()elseif g6=="groundaltitudeup"then if antigrav and antigrav.getState()==1 then AntiGravButtonModifier=OldAntiMod end;ToggleView=false elseif g6=="groundaltitudedown"then if antigrav and antigrav.getState()==1 then AntiGravButtonModifier=OldAntiMod end;ToggleView=false elseif g6=="lshift"then if system.isViewLocked()==1 then HoldingCtrl=false;SimulatedX=0;SimulatedY=0;system.lockView(PrevViewLock)elseif Nav.control.isRemoteControlled()==1 and ShiftShowsRemoteButtons then HoldingCtrl=false;Animated=false;Animating=false end elseif g6=="brake"then if not brakeToggle then if BrakeIsOn then BrakeToggle()else BrakeIsOn=false end end elseif g6=="lalt"then if Nav.control.isRemoteControlled()==0 and freeLookToggle then if ToggleView then if system.isViewLocked()==1 then system.lockView(0)else system.lockView(1)end else ToggleView=true end elseif Nav.control.isRemoteControlled()==0 and not freeLookToggle and userControlScheme=="Keyboard"then system.lockView(0)end end end;function script.onActionLoop(g6)if g6=="groundaltitudeup"then if antigrav and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then AntigravTargetAltitude=AntigravTargetAltitude+AntiGravButtonModifier;AntiGravButtonModifier=AntiGravButtonModifier*1.05;BrakeIsOn=false else AntigravTargetAltitude=desiredBaseAltitude+100;BrakeIsOn=false end else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(1.0)end elseif g6=="groundaltitudedown"then if antigrav and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then AntigravTargetAltitude=AntigravTargetAltitude-AntiGravButtonModifier;AntiGravButtonModifier=AntiGravButtonModifier*1.05;BrakeIsOn=false;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end else AntigravTargetAltitude=desiredBaseAltitude-100;BrakeIsOn=false end else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(-1.0)end elseif g6=="speedup"then if not HoldingCtrl then Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal,speedChangeSmall)end elseif g6=="speeddown"then if not HoldingCtrl then Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal,-speedChangeSmall)end end end;function DisplayMessage(ah,g7)if g7~="empty"then ah[#ah+1]=[[]]for g8 in string.gmatch(g7,"([^\n]+)")do ah[#ah+1]=string.format([[%s]],g8)end;ah[#ah+1]=[[]]end;if MsgTimer~=0 then unit.setTimer("msgTick",MsgTimer)MsgTimer=0 end end;function updateDistance()local Y=system.getTime()local velocity=vec3(core.getWorldVelocity())local bh=vec3(velocity):len()local g9=Y-LastTravelTime;if bh>1.38889 then bh=bh/1000;local ga=bh*(Y-LastTravelTime)TotalDistanceTravelled=TotalDistanceTravelled+ga;TotalDistanceTrip=TotalDistanceTrip+ga end;FlightTime=FlightTime+g9;TotalFlightTime=TotalFlightTime+g9;LastTravelTime=Y end;function updateMass()local gb=0;for Q in pairs(ElementsID)do gb=gb+core.getElementMassById(ElementsID[Q])end;return gb end;script.onStart() + + + -- error handling code added by wrap.lua + end, __wrap_lua__traceback) + if not ok then + __wrap_lua__error(message) + if not script then script = {} end + end + stop: + lua: | + if not __wrap_lua__stopped and script.onStop then + local ok, message = xpcall(script.onStop,__wrap_lua__traceback,unit) + if not ok then __wrap_lua__error(message) end + end + tick(timerId): + lua: | + if not __wrap_lua__stopped and script.onTick then + local ok, message = xpcall(script.onTick,__wrap_lua__traceback,timerId,unit) + if not ok then __wrap_lua__error(message) end + end + system: + actionStart(action): + lua: | + if not __wrap_lua__stopped and script.onActionStart then + local ok, message = xpcall(script.onActionStart,__wrap_lua__traceback,action,system) + if not ok then __wrap_lua__error(message) end + end + actionStop(action): + lua: | + if not __wrap_lua__stopped and script.onActionStop then + local ok, message = xpcall(script.onActionStop,__wrap_lua__traceback,action,system) + if not ok then __wrap_lua__error(message) end + end + actionLoop(action): + lua: | + if not __wrap_lua__stopped and script.onActionLoop then + local ok, message = xpcall(script.onActionLoop,__wrap_lua__traceback,action,system) + if not ok then __wrap_lua__error(message) end + end + update: + lua: | + if not __wrap_lua__stopped and script.onUpdate then + local ok, message = xpcall(script.onUpdate,__wrap_lua__traceback,system) + if not ok then __wrap_lua__error(message) end + end + flush: + lua: | + if not __wrap_lua__stopped and script.onFlush then + local ok, message = xpcall(script.onFlush,__wrap_lua__traceback,system) + if not ok then __wrap_lua__error(message) end + end