diff --git a/ButtonHUD.conf b/ButtonHUD.conf index 0b362b3..309c1d7 100644 --- a/ButtonHUD.conf +++ b/ButtonHUD.conf @@ -1,4 +1,4 @@ -name: ButtonsHud - Dimencia and Archaegeo v4.832 (Minified) +name: ButtonsHud - Dimencia and Archaegeo v4.833 (Minified) slots: core: class: CoreUnit @@ -153,7 +153,7 @@ handlers: 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=4.832;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;APThrottleSet=false;ToggleView=true;MinAutopilotSpeed=55;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;RetrogradeIsOn=false;ProgradeIsOn=false;Reentry=false;FollowMode=false;TurnBurn=false;AutopilotAccelerating=false;AutopilotRealigned=false;HoldingCtrl=false;PrevViewLock=1;MsgText="empty"LastEccentricity=1;HoldAltitudeButtonModifier=5;AntiGravButtonModifier=5;IsBoosting=false;BrakeDistance,BrakeTime=0;MaxBrakeDistance,MaxBrakeTime=0;HasSpaceRadar=false;HasAtmoRadar=false;AutopilotTargetIndex=0;AutopilotTargetName="None"AutopilotTargetPlanet=nil;TotalDistanceTravelled=0.0;TotalDistanceTrip=0;InEmergencyWarp=false;NotTriedEmergencyWarp=true;FlightTime=0;WipedDatabank=false;LocationIndex=0;UpAmount=0;BrakeIsOn=false;Autopilot=false;AltitudeHold=false;BrakeLanding=false;AutoTakeoff=false;HoldAltitude=1000;AutopilotBraking=false;AutopilotCruising=false;VectorToTarget=false;SimulatedX=0;SimulatedY=0;AutopilotStatus="Aligning"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;AutopilotEndSpeed=0;SavedLocations={}LandingGearGroundHeight=0;SpaceLand=false;SpaceLaunch=false;FinalLand=false;HovGndDet=-1;local m={}local n=0;local o=0;local p=""local q=true;local r={}local s=1;local t=0.001;local u=2560;local v=1440;local w=nil;local x=nil;local y=nil;local z=nil;local A=false;local B=false;local C=0;local D=nil;local E={}local F={}local G={}local H=0;local I=false;local J={}local K={}local L=a(1/apTickRate)*2;local M={}local N={}local O={}local P={}local Q=false;local R=16;local S=0;SaveableVariables={"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","ReentryAltitude","EmergencyWarpDistance","centerX","centerY","vSpdMeterX","vSpdMeterY","altMeterX","altMeterY","fuelX","fuelY","LandingGearGroundHeight","TrajectoryAlignmentStrength","RemoteHud","RequireLock","StallAngle"}AutoVariables={"EmergencyWarp","brakeToggle","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","LastMaxBrakeInAtmo","AntigravTargetAltitude"}if dbHud then local T=dbHud.hasKey;if not useTheseSettings then for U,V in pairs(SaveableVariables)do if T(V)then local W=c(dbHud.getStringValue(V))if W~=nil then system.print(V.." "..dbHud.getStringValue(V))_G[V]=W;A=true end end end end;for U,V in pairs(AutoVariables)do if T(V)then local W=c(dbHud.getStringValue(V))if W~=nil then system.print(V.." "..dbHud.getStringValue(V))_G[V]=W;A=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 A 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;userControlScheme=string.lower(userControlScheme)if string.find("keyboard virtual joystick mouse",userControlScheme)==nil then MsgText="Invalid User Control Scheme selected. Change userControlScheme in Lua Parameters to keyboard, mouse, or virtual joystick"end;MinimumRateOfChange=math.cos(StallAngle*constants.deg2rad)autoRoll=autoRollPreference;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 X=[[rgb(]]..a(PrimaryR*0.9+0.5)..","..a(PrimaryG*0.9+0.5)..","..a(PrimaryB*0.9+0.5)..[[)]]coroutine.yield()for U in pairs(ElementsID)do local type=h(ElementsID[U])if type=="landing gear"then HasGear=true end;if type=="dynamic core"then local Y=e(ElementsID[U])if Y>10000 then R=128 elseif Y>1000 then R=64 elseif Y>150 then R=32 end end;H=H+e(ElementsID[U])if fuelX~=0 and fuelY~=0 then if type=="atmospheric fuel-tank"or type=="space fuel-tank"or type=="rocket fuel-tank"then local Y=e(ElementsID[U])local Z=j(ElementsID[U])local a0=0;local a1=system.getTime()if type=="atmospheric fuel-tank"then local a2=400;local a3=35.03;if Y>10000 then a2=51200;a3=5480 elseif Y>1300 then a2=6400;a3=988.67 elseif Y>150 then a2=1600;a3=182.67 end;a0=Z-a3;if fuelTankHandlingAtmo>0 then a2=a2+a2*fuelTankHandlingAtmo*0.2 end;if a0>a2 then a2=a0 end;E[#E+1]={ElementsID[U],core.getElementNameById(ElementsID[U]),a2,a3,a0,a1}end;if type=="rocket fuel-tank"then local a2=320;local a3=173.42;if Y>65000 then a2=40000;a3=25740 elseif Y>6000 then a2=5120;a3=4720 elseif Y>700 then a2=640;a3=886.72 end;a0=Z-a3;if fuelTankHandlingRocket>0 then a2=a2+a2*fuelTankHandlingRocket*0.2 end;if a0>a2 then a2=a0 end;G[#G+1]={ElementsID[U],core.getElementNameById(ElementsID[U]),a2,a3,a0,a1}end;if type=="space fuel-tank"then local a2=2400;local a3=182.67;if Y>10000 then a2=76800;a3=5480 elseif Y>1300 then a2=9600;a3=988.67 end;a0=Z-a3;if fuelTankHandlingSpace>0 then a2=a2+a2*fuelTankHandlingSpace*0.2 end;if a0>a2 then a2=a0 end;F[#F+1]={ElementsID[U],core.getElementNameById(ElementsID[U]),a2,a3,a0,a1}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 _,V in pairs(door)do V.deactivate()end end;if forcefield then for _,V in pairs(forcefield)do V.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(a4,a5)if a4==nil then a4=core.g()end;a4=round(a4,5)if a5~=nil and a5 or(D==nil or D~=a4)then local a6=c(unit.getData()).maxBrake;if a6~=nil then LastMaxBrake=a6 end;if f()>0 then LastMaxBrakeInAtmo=a6 end;D=a4 end end;function MakeButton(a7,a8,a9,aa,ab,ac,ad,ae,af)local ag={enableName=a7,disableName=a8,width=a9,height=aa,x=ab,y=ac,toggleVar=ad,toggleFunction=ae,drawCondition=af,hovered=false}table.insert(r,ag)return ag end;function UpdateAtlasLocationsList()AtlasOrdered={}for U,V in pairs(atlas[0])do table.insert(AtlasOrdered,{name=V.name,index=U})end;local function ah(ai,aj)return ai.name-1 then atlas[0][an]=am end;UpdateAtlasLocationsList()MsgText=CustomTarget.name.." position updated"end end;function ClearCurrentPosition()local an=-1;for U,V in pairs(atlas[0])do if V.name and V.name==CustomTarget.name then an=U end end;if an>-1 then table.remove(atlas[0],an)end;an=-1;for U,V in pairs(SavedLocations)do if V.name and V.name==CustomTarget.name then MsgText=V.name.." saved location cleared"an=U;break end end;if an~=-1 then table.remove(SavedLocations,an)end;DecrementAutopilotTargetIndex()UpdateAtlasLocationsList()end;function DrawDeadZone(ao)ao[#ao+1]=b([[]],DeadZone)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 q 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;q=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;q=true end end;function SetupInterplanetaryPanel()InAtmo=f()>0;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 InAtmo then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;widgetCurBrakeTime=system.createWidget(panelInterplanetary,"value")widgetCurBrakeTimeText=system.createData('{"label": "Cur Brake Time", "value": "N/A", "unit":""}')if not InAtmo then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;widgetMaxBrakeDistance=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeDistanceText=system.createData('{"label": "Max Brake Distance", "value": "N/A", "unit":""}')if not InAtmo then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;widgetMaxBrakeTime=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeTimeText=system.createData('{"label": "Max Brake Time", "value": "N/A", "unit":""}')if not InAtmo then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;widgetTrajectoryAltitude=system.createWidget(panelInterplanetary,"value")widgetTrajectoryAltitudeText=system.createData('{"label": "Projected Altitude", "value": "N/A", "unit":""}')if not InAtmo then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end end;function Contains(ap,aq,ab,ac,a9,aa)if ap>ab and apac and aqMinAutopilotSpeed then MsgText="WARNING: Insufficient Brakes - Attempting coast landing, beware obstacles"end;if not AltitudeHold then ToggleAltitudeHold()end;AutoTakeoff=false;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=CoreAltitude+AutoTakeoffAltitude;GearExtended=false;Nav.control.retractLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(500)BrakeIsOn=true end end;function ToggleAltitudeHold()AltitudeHold=not AltitudeHold;if AltitudeHold then Autopilot=false;ProgradeIsOn=false;RetrogradeIsOn=false;FollowMode=false;BrakeLanding=false;Reentry=false;autoRoll=true;if not GearExtended and not BrakeIsOn or f()==0 then AutoTakeoff=false;HoldAltitude=CoreAltitude;if not SpaceLaunch and Nav.axisCommandManager:getAxisCommandType(0)==0 then Nav.control.cancelCurrentControlMasterMode()end else AutoTakeoff=true;HoldAltitude=CoreAltitude+AutoTakeoffAltitude;GearExtended=false;Nav.control.retractLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(500)BrakeIsOn=true end;if SpaceLaunch then HoldAltitude=100000 end else autoRoll=autoRollPreference;AutoTakeoff=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;VectorToTarget=false end end;function ToggleFollowMode()if l()==1 then FollowMode=not FollowMode;if FollowMode 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 MsgText="Follow Mode only works with Remote controller"FollowMode=false end end;function ToggleAutopilot()if AutopilotTargetIndex>0 and not Autopilot then if CustomTarget~=nil then if planet.name==CustomTarget.planetname then StrongBrakes=planet.gravity*9.80665*core.getConstructMass()MinAutopilotSpeed then MsgText="Insufficient Brake Force\nCoast landing will be inaccurate"end;if unit.getAtmosphereDensity()>0 then if not AltitudeHold then if not VectorToTarget then ToggleVectorToTarget()end else if not VectorToTarget then ToggleVectorToTarget()end end else SpaceLand=true end else SpaceLaunch=true;if unit.getAtmosphereDensity()~=0 then ToggleAltitudeHold()else Autopilot=true end end elseif unit.getAtmosphereDensity()==0 then Autopilot=true;RetrogradeIsOn=false;ProgradeIsOn=false;AutopilotRealigned=false;FollowMode=false;AltitudeHold=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;APThrottleSet=false else SpaceLaunch=true;ToggleAltitudeHold()end else Autopilot=false;AutopilotRealigned=false;VectorToTarget=false;APThrottleSet=false end end;function ProgradeToggle()ProgradeIsOn=not ProgradeIsOn;RetrogradeIsOn=false;Autopilot=false;AltitudeHold=false;FollowMode=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false end;function RetrogradeToggle()RetrogradeIsOn=not RetrogradeIsOn;ProgradeIsOn=false;Autopilot=false;AltitudeHold=false;FollowMode=false;BrakeLanding=false;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;autoRoll=autoRollPreference end end;function checkDamage(ao)local ar=0;p=""local as=H;local at=0;local au=0;local av=0;local aw=0;local ax=""for U in pairs(ElementsID)do local Y=0;local ay=0;ay=e(ElementsID[U])Y=g(ElementsID[U])at=at+Y;if Y0 and m[11]==ElementsID[U]then for aA in pairs(m)do core.deleteSticker(m[aA])end;m={}end end;ar=a(at/as*100)if ar<100 then ao[#ao+1]=[[]]aw=a(ar*2.55)ax=b("rgb(%d,%d,%d)",255-aw,aw,0)if ar<100 then ao[#ao+1]=b([[Elemental Integrity: %i %%]],ax,ar)if av>0 then ao[#ao+1]=b([[Disabled Modules: %i Damaged Modules: %i]],ax,av,au)elseif au>0 then ao[#ao+1]=b([[Damaged Modules: %i]],ax,au)end end;ao[#ao+1]=[[<\g>]]end end;function DrawCursorLine(ao)local aB=a(utils.clamp(Distance/(u/4)*255,0,255))ao[#ao+1]=b("",SimulatedX,SimulatedY,a(PrimaryR+0.5)+aB,a(PrimaryG+0.5)-aB,a(PrimaryB+0.5)-aB)end;function getPitch(aC,aD,aj)local aE=aC:cross(aj):normalize_inplace()local aF=math.acos(utils.clamp(aE:dot(-aD),-1,1))*constants.rad2deg;if aE:cross(-aD):dot(aj)<0 then aF=-aF end;return aF 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 B then for U,V in pairs(SaveableVariables)do dbHud.setStringValue(V,d(nil))end;for U,V in pairs(AutoVariables)do if V~="SavedLocations"then dbHud.setStringValue(V,d(nil))end end;MsgText="Databank wiped. New variables will save after re-enter seat and exit"MsgTimer=5;B=false;A=false;WipedDatabank=true else MsgText="Press ALT-7 again to confirm wipe of ALL data"B=true end end end;function CheckButtons()for _,V in pairs(r)do if V.hovered then if not V.drawCondition or V.drawCondition()then V.toggleFunction()end;V.hovered=false end end end;function SetButtonContains()local ab=SimulatedX+u/2;local ac=SimulatedY+v/2;for _,V in pairs(r)do V.hovered=Contains(ab,ac,V.x,V.y,V.width,V.height)end end;function DrawButton(ao,aG,hover,ab,ac,aH,aI,aJ,aK,aL,aM)if type(aL)=="function"then aL=aL()end;if type(aM)=="function"then aM=aM()end;ao[#ao+1]=b(""if aG then ao[#ao+1]=b("%s",aL)else ao[#ao+1]=b("%s",aM)end end;function DrawButtons(ao)local aN="rgb(50,50,50)'"local aO="rgb(210,200,200)"local aP=DrawButton;for _,V in pairs(r)do local a8=V.disableName;local a7=V.enableName;if type(a8)=="function"then a8=a8()end;if type(a7)=="function"then a7=a7()end;if not V.drawCondition or V.drawCondition()then aP(ao,V.toggleVar(),V.hovered,V.x,V.y,V.width,V.height,aO,aN,a8,a7)end end end;function DrawTank(ao,Q,ab,aQ,aR,aS,aT,aU)local aV=1;local aW=2;local aX=3;local aY=4;local aZ=5;local a_=6;local b0=""local b1=0;local b2=fuelY;local b3=fuelY+10;if l()==1 and not RemoteHud then b2=b2-50;b3=b3-50 end;ao[#ao+1]=[[]]if aR=="ATMO"then b0="atmofueltank"elseif aR=="SPACE"then b0="spacefueltank"else b0="rocketfueltank"end;b1=_G[b0 .."_size"]if#aS>0 then for i=1,#aS do local ak=string.sub(aS[i][aW],1,12)local b4=0;for aA=1,b1 do if aS[i][aW]==json.decode(unit[b0 .."_"..aA].getData()).name then b4=aA;break end end;if Q or aT[i]==nil or aU[i]==nil then local b5=0;local b6=0;local b7=0;local b8=0;local a1=system.getTime()if b4~=0 then aU[i]=json.decode(unit[b0 .."_"..b4].getData()).percentage;aT[i]=json.decode(unit[b0 .."_"..b4].getData()).timeLeft;if aT[i]=="n/a"then aT[i]=0 end else b7=j(aS[i][aV])-aS[i][aY]b5=aS[i][aX]aU[i]=a(0.5+b7*100/b5)b6=aS[i][aZ]b8=aS[i][a_]if b6<=b7 then aT[i]=0 else aT[i]=a(0.5+b7/((b6-b7)/(a1-b8)))end;aS[i][aZ]=b7;aS[i][a_]=a1 end end;if ak==aQ then ak=b("%s %d",aR,i)end;if b4==0 then ak=ak.." *"end;local b9;if aT[i]==0 then b9="n/a"else b9=FormatTimeString(aT[i])end;if aU[i]~=nil then local aw=a(aU[i]*2.55)local ax=b("rgb(%d,%d,%d)",255-aw,aw,0)local ba=""if b9~="n/a"and aT[i]<120 or aU[i]<5 then if Q then ba=[[class="red"]]end end;ao[#ao+1]=b([[ + 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=4.833;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;APThrottleSet=false;ToggleView=true;MinAutopilotSpeed=55;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;RetrogradeIsOn=false;ProgradeIsOn=false;Reentry=false;FollowMode=false;TurnBurn=false;AutopilotAccelerating=false;AutopilotRealigned=false;HoldingCtrl=false;PrevViewLock=1;MsgText="empty"LastEccentricity=1;HoldAltitudeButtonModifier=5;AntiGravButtonModifier=5;IsBoosting=false;BrakeDistance,BrakeTime=0;MaxBrakeDistance,MaxBrakeTime=0;HasSpaceRadar=false;HasAtmoRadar=false;AutopilotTargetIndex=0;AutopilotTargetName="None"AutopilotTargetPlanet=nil;TotalDistanceTravelled=0.0;TotalDistanceTrip=0;InEmergencyWarp=false;NotTriedEmergencyWarp=true;FlightTime=0;WipedDatabank=false;LocationIndex=0;UpAmount=0;BrakeIsOn=false;Autopilot=false;AltitudeHold=false;BrakeLanding=false;AutoTakeoff=false;HoldAltitude=1000;AutopilotBraking=false;AutopilotCruising=false;VectorToTarget=false;SimulatedX=0;SimulatedY=0;AutopilotStatus="Aligning"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;AutopilotEndSpeed=0;SavedLocations={}LandingGearGroundHeight=0;SpaceLand=false;SpaceLaunch=false;FinalLand=false;HovGndDet=-1;local m={}local n=0;local o=0;local p=""local q=true;local r={}local s=1;local t=0.001;local u=2560;local v=1440;local w=nil;local x=nil;local y=nil;local z=nil;local A=false;local B=false;local C=0;local D=nil;local E={}local F={}local G={}local H=0;local I=false;local J={}local K={}local L=a(1/apTickRate)*2;local M={}local N={}local O={}local P={}local Q=false;local R=16;local S=0;SaveableVariables={"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","ReentryAltitude","EmergencyWarpDistance","centerX","centerY","vSpdMeterX","vSpdMeterY","altMeterX","altMeterY","fuelX","fuelY","LandingGearGroundHeight","TrajectoryAlignmentStrength","RemoteHud","RequireLock","StallAngle"}AutoVariables={"EmergencyWarp","brakeToggle","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","LastMaxBrakeInAtmo","AntigravTargetAltitude"}if dbHud then local T=dbHud.hasKey;if not useTheseSettings then for U,V in pairs(SaveableVariables)do if T(V)then local W=c(dbHud.getStringValue(V))if W~=nil then system.print(V.." "..dbHud.getStringValue(V))_G[V]=W;A=true end end end end;for U,V in pairs(AutoVariables)do if T(V)then local W=c(dbHud.getStringValue(V))if W~=nil then system.print(V.." "..dbHud.getStringValue(V))_G[V]=W;A=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 A 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;userControlScheme=string.lower(userControlScheme)if string.find("keyboard virtual joystick mouse",userControlScheme)==nil then MsgText="Invalid User Control Scheme selected. Change userControlScheme in Lua Parameters to keyboard, mouse, or virtual joystick"end;MinimumRateOfChange=math.cos(StallAngle*constants.deg2rad)autoRoll=autoRollPreference;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 X=[[rgb(]]..a(PrimaryR*0.9+0.5)..","..a(PrimaryG*0.9+0.5)..","..a(PrimaryB*0.9+0.5)..[[)]]coroutine.yield()for U in pairs(ElementsID)do local type=h(ElementsID[U])if type=="landing gear"then HasGear=true end;if type=="dynamic core"then local Y=e(ElementsID[U])if Y>10000 then R=128 elseif Y>1000 then R=64 elseif Y>150 then R=32 end end;H=H+e(ElementsID[U])if fuelX~=0 and fuelY~=0 then if type=="atmospheric fuel-tank"or type=="space fuel-tank"or type=="rocket fuel-tank"then local Y=e(ElementsID[U])local Z=j(ElementsID[U])local a0=0;local a1=system.getTime()if type=="atmospheric fuel-tank"then local a2=400;local a3=35.03;if Y>10000 then a2=51200;a3=5480 elseif Y>1300 then a2=6400;a3=988.67 elseif Y>150 then a2=1600;a3=182.67 end;a0=Z-a3;if fuelTankHandlingAtmo>0 then a2=a2+a2*fuelTankHandlingAtmo*0.2 end;if a0>a2 then a2=a0 end;E[#E+1]={ElementsID[U],core.getElementNameById(ElementsID[U]),a2,a3,a0,a1}end;if type=="rocket fuel-tank"then local a2=320;local a3=173.42;if Y>65000 then a2=40000;a3=25740 elseif Y>6000 then a2=5120;a3=4720 elseif Y>700 then a2=640;a3=886.72 end;a0=Z-a3;if fuelTankHandlingRocket>0 then a2=a2+a2*fuelTankHandlingRocket*0.2 end;if a0>a2 then a2=a0 end;G[#G+1]={ElementsID[U],core.getElementNameById(ElementsID[U]),a2,a3,a0,a1}end;if type=="space fuel-tank"then local a2=2400;local a3=182.67;if Y>10000 then a2=76800;a3=5480 elseif Y>1300 then a2=9600;a3=988.67 end;a0=Z-a3;if fuelTankHandlingSpace>0 then a2=a2+a2*fuelTankHandlingSpace*0.2 end;if a0>a2 then a2=a0 end;F[#F+1]={ElementsID[U],core.getElementNameById(ElementsID[U]),a2,a3,a0,a1}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 _,V in pairs(door)do V.deactivate()end end;if forcefield then for _,V in pairs(forcefield)do V.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(a4,a5)if a4==nil then a4=core.g()end;a4=round(a4,5)if a5~=nil and a5 or(D==nil or D~=a4)then local a6=c(unit.getData()).maxBrake;if a6~=nil then LastMaxBrake=a6 end;if f()>0 then LastMaxBrakeInAtmo=a6 end;D=a4 end end;function MakeButton(a7,a8,a9,aa,ab,ac,ad,ae,af)local ag={enableName=a7,disableName=a8,width=a9,height=aa,x=ab,y=ac,toggleVar=ad,toggleFunction=ae,drawCondition=af,hovered=false}table.insert(r,ag)return ag end;function UpdateAtlasLocationsList()AtlasOrdered={}for U,V in pairs(atlas[0])do table.insert(AtlasOrdered,{name=V.name,index=U})end;local function ah(ai,aj)return ai.name-1 then atlas[0][an]=am end;UpdateAtlasLocationsList()MsgText=CustomTarget.name.." position updated"end end;function ClearCurrentPosition()local an=-1;for U,V in pairs(atlas[0])do if V.name and V.name==CustomTarget.name then an=U end end;if an>-1 then table.remove(atlas[0],an)end;an=-1;for U,V in pairs(SavedLocations)do if V.name and V.name==CustomTarget.name then MsgText=V.name.." saved location cleared"an=U;break end end;if an~=-1 then table.remove(SavedLocations,an)end;DecrementAutopilotTargetIndex()UpdateAtlasLocationsList()end;function DrawDeadZone(ao)ao[#ao+1]=b([[]],DeadZone)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 q 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;q=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;q=true end end;function SetupInterplanetaryPanel()InAtmo=f()>0;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 InAtmo then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;widgetCurBrakeTime=system.createWidget(panelInterplanetary,"value")widgetCurBrakeTimeText=system.createData('{"label": "Cur Brake Time", "value": "N/A", "unit":""}')if not InAtmo then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;widgetMaxBrakeDistance=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeDistanceText=system.createData('{"label": "Max Brake Distance", "value": "N/A", "unit":""}')if not InAtmo then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;widgetMaxBrakeTime=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeTimeText=system.createData('{"label": "Max Brake Time", "value": "N/A", "unit":""}')if not InAtmo then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;widgetTrajectoryAltitude=system.createWidget(panelInterplanetary,"value")widgetTrajectoryAltitudeText=system.createData('{"label": "Projected Altitude", "value": "N/A", "unit":""}')if not InAtmo then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end end;function Contains(ap,aq,ab,ac,a9,aa)if ap>ab and apac and aqMinAutopilotSpeed then MsgText="WARNING: Insufficient Brakes - Attempting coast landing, beware obstacles"end;if not AltitudeHold then ToggleAltitudeHold()end;AutoTakeoff=false;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=CoreAltitude+AutoTakeoffAltitude;GearExtended=false;Nav.control.retractLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(500)BrakeIsOn=true end end;function ToggleAltitudeHold()AltitudeHold=not AltitudeHold;if AltitudeHold then Autopilot=false;ProgradeIsOn=false;RetrogradeIsOn=false;FollowMode=false;BrakeLanding=false;Reentry=false;autoRoll=true;if not GearExtended and not BrakeIsOn or f()==0 then AutoTakeoff=false;HoldAltitude=CoreAltitude;if not SpaceLaunch and Nav.axisCommandManager:getAxisCommandType(0)==0 then Nav.control.cancelCurrentControlMasterMode()end else AutoTakeoff=true;HoldAltitude=CoreAltitude+AutoTakeoffAltitude;GearExtended=false;Nav.control.retractLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(500)BrakeIsOn=true end;if SpaceLaunch then HoldAltitude=100000 end else autoRoll=autoRollPreference;AutoTakeoff=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;VectorToTarget=false end end;function ToggleFollowMode()if l()==1 then FollowMode=not FollowMode;if FollowMode 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 MsgText="Follow Mode only works with Remote controller"FollowMode=false end end;function ToggleAutopilot()if AutopilotTargetIndex>0 and not Autopilot then if CustomTarget~=nil then if planet.name==CustomTarget.planetname then StrongBrakes=planet.gravity*9.80665*core.getConstructMass()MinAutopilotSpeed then MsgText="Insufficient Brake Force\nCoast landing will be inaccurate"end;if unit.getAtmosphereDensity()>0 then if not AltitudeHold then if not VectorToTarget then ToggleVectorToTarget()end else if not VectorToTarget then ToggleVectorToTarget()end end else SpaceLand=true end else SpaceLaunch=true;if unit.getAtmosphereDensity()~=0 then ToggleAltitudeHold()else Autopilot=true end end elseif unit.getAtmosphereDensity()==0 then Autopilot=true;RetrogradeIsOn=false;ProgradeIsOn=false;AutopilotRealigned=false;FollowMode=false;AltitudeHold=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;APThrottleSet=false else SpaceLaunch=true;ToggleAltitudeHold()end else Autopilot=false;AutopilotRealigned=false;VectorToTarget=false;APThrottleSet=false end end;function ProgradeToggle()ProgradeIsOn=not ProgradeIsOn;RetrogradeIsOn=false;Autopilot=false;AltitudeHold=false;FollowMode=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false end;function RetrogradeToggle()RetrogradeIsOn=not RetrogradeIsOn;ProgradeIsOn=false;Autopilot=false;AltitudeHold=false;FollowMode=false;BrakeLanding=false;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;autoRoll=autoRollPreference end end;function checkDamage(ao)local ar=0;p=""local as=H;local at=0;local au=0;local av=0;local aw=0;local ax=""for U in pairs(ElementsID)do local Y=0;local ay=0;ay=e(ElementsID[U])Y=g(ElementsID[U])at=at+Y;if Y0 and m[11]==ElementsID[U]then for aA in pairs(m)do core.deleteSticker(m[aA])end;m={}end end;ar=a(at/as*100)if ar<100 then ao[#ao+1]=[[]]aw=a(ar*2.55)ax=b("rgb(%d,%d,%d)",255-aw,aw,0)if ar<100 then ao[#ao+1]=b([[Elemental Integrity: %i %%]],ax,ar)if av>0 then ao[#ao+1]=b([[Disabled Modules: %i Damaged Modules: %i]],ax,av,au)elseif au>0 then ao[#ao+1]=b([[Damaged Modules: %i]],ax,au)end end;ao[#ao+1]=[[<\g>]]end end;function DrawCursorLine(ao)local aB=a(utils.clamp(Distance/(u/4)*255,0,255))ao[#ao+1]=b("",SimulatedX,SimulatedY,a(PrimaryR+0.5)+aB,a(PrimaryG+0.5)-aB,a(PrimaryB+0.5)-aB)end;function getPitch(aC,aD,aj)local aE=aC:cross(aj):normalize_inplace()local aF=math.acos(utils.clamp(aE:dot(-aD),-1,1))*constants.rad2deg;if aE:cross(-aD):dot(aj)<0 then aF=-aF end;return aF 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 B then for U,V in pairs(SaveableVariables)do dbHud.setStringValue(V,d(nil))end;for U,V in pairs(AutoVariables)do if V~="SavedLocations"then dbHud.setStringValue(V,d(nil))end end;MsgText="Databank wiped. New variables will save after re-enter seat and exit"MsgTimer=5;B=false;A=false;WipedDatabank=true else MsgText="Press ALT-7 again to confirm wipe of ALL data"B=true end end end;function CheckButtons()for _,V in pairs(r)do if V.hovered then if not V.drawCondition or V.drawCondition()then V.toggleFunction()end;V.hovered=false end end end;function SetButtonContains()local ab=SimulatedX+u/2;local ac=SimulatedY+v/2;for _,V in pairs(r)do V.hovered=Contains(ab,ac,V.x,V.y,V.width,V.height)end end;function DrawButton(ao,aG,hover,ab,ac,aH,aI,aJ,aK,aL,aM)if type(aL)=="function"then aL=aL()end;if type(aM)=="function"then aM=aM()end;ao[#ao+1]=b(""if aG then ao[#ao+1]=b("%s",aL)else ao[#ao+1]=b("%s",aM)end end;function DrawButtons(ao)local aN="rgb(50,50,50)'"local aO="rgb(210,200,200)"local aP=DrawButton;for _,V in pairs(r)do local a8=V.disableName;local a7=V.enableName;if type(a8)=="function"then a8=a8()end;if type(a7)=="function"then a7=a7()end;if not V.drawCondition or V.drawCondition()then aP(ao,V.toggleVar(),V.hovered,V.x,V.y,V.width,V.height,aO,aN,a8,a7)end end end;function DrawTank(ao,Q,ab,aQ,aR,aS,aT,aU)local aV=1;local aW=2;local aX=3;local aY=4;local aZ=5;local a_=6;local b0=""local b1=0;local b2=fuelY;local b3=fuelY+10;if l()==1 and not RemoteHud then b2=b2-50;b3=b3-50 end;ao[#ao+1]=[[]]if aR=="ATMO"then b0="atmofueltank"elseif aR=="SPACE"then b0="spacefueltank"else b0="rocketfueltank"end;b1=_G[b0 .."_size"]if#aS>0 then for i=1,#aS do local ak=string.sub(aS[i][aW],1,12)local b4=0;for aA=1,b1 do if aS[i][aW]==json.decode(unit[b0 .."_"..aA].getData()).name then b4=aA;break end end;if Q or aT[i]==nil or aU[i]==nil then local b5=0;local b6=0;local b7=0;local b8=0;local a1=system.getTime()if b4~=0 then aU[i]=json.decode(unit[b0 .."_"..b4].getData()).percentage;aT[i]=json.decode(unit[b0 .."_"..b4].getData()).timeLeft;if aT[i]=="n/a"then aT[i]=0 end else b7=j(aS[i][aV])-aS[i][aY]b5=aS[i][aX]aU[i]=a(0.5+b7*100/b5)b6=aS[i][aZ]b8=aS[i][a_]if b6<=b7 then aT[i]=0 else aT[i]=a(0.5+b7/((b6-b7)/(a1-b8)))end;aS[i][aZ]=b7;aS[i][a_]=a1 end end;if ak==aQ then ak=b("%s %d",aR,i)end;if b4==0 then ak=ak.." *"end;local b9;if aT[i]==0 then b9="n/a"else b9=FormatTimeString(aT[i])end;if aU[i]~=nil then local aw=a(aU[i]*2.55)local ax=b("rgb(%d,%d,%d)",255-aw,aw,0)local ba=""if b9~="n/a"and aT[i]<120 or aU[i]<5 then if Q then ba=[[class="red"]]end end;ao[#ao+1]=b([[ %s %d%% %s ]],ab,b2,ba,ak,ab,b3,ax,aU[i],b9)b2=b2+30;b3=b3+30 end end end;ao[#ao+1]=""end;function HideInterplanetaryPanel()system.destroyWidgetPanel(panelInterplanetary)panelInterplanetary=nil end;system.showScreen(1)function getRelativePitch(velocity)velocity=vec3(velocity)local aF=-math.deg(math.atan(velocity.y,velocity.z))+180;aF=aF-90;if aF<0 then aF=360+aF end;if aF>180 then aF=-180+aF-180 end;return-aF end;function getRelativeYaw(velocity)velocity=vec3(velocity)local bb=math.deg(math.atan(velocity.y,velocity.x))-90;if bb<-180 then bb=360+bb end;return bb end;function AlignToWorldVector(bc,bd)if f()==0 or RateOfChange>MinimumRateOfChange+0.08 then if bd==nil then bd=t end;bc=vec3(bc):normalize()local be=vec3(core.getConstructWorldOrientationForward())-bc;local bf=-getMagnitudeInDirection(be,core.getConstructWorldOrientationRight())*s;local bg=-getMagnitudeInDirection(be,core.getConstructWorldOrientationUp())*s;if n==0 then n=bf/2 end;if o==0 then o=bg/2 end;YawInput2=YawInput2-(bf+(bf-n)*DampingMultiplier)PitchInput2=PitchInput2+bg+(bg-o)*DampingMultiplier;n=bf;o=bg;if math.abs(bf)0 and CustomTarget~=nil end)MakeButton("Clear Position","Clear Position",200,bk.height,bk.x-200-30,bk.y,function()return true end,ClearCurrentPosition,function()return AutopilotTargetIndex>0 and CustomTarget~=nil end)bh=60;bi=300;local ab=10;local ac=v/2-300;MakeButton("Enable Turn and Burn","Disable Turn and Burn",bi,bh,ab,ac,function()return TurnBurn end,ToggleTurnBurn)MakeButton("Engage Altitude Hold","Disable Altitude Hold",bi,bh,ab+bi+20,ac,function()return AltitudeHold end,ToggleAltitudeHold)ac=ac+bh+20;MakeButton("Engage Autoland","Disable Autoland",bi,bh,ab,ac,function()return AutoLanding end,ToggleAutoLanding)MakeButton("Engage Auto Takeoff","Disable Auto Takeoff",bi,bh,ab+bi+20,ac,function()return AutoTakeoff end,ToggleAutoTakeoff)ac=ac+bh+20;MakeButton("Show Orbit Display","Hide Orbit Display",bi,bh,ab,ac,function()return DisplayOrbit end,function()DisplayOrbit=not DisplayOrbit;if DisplayOrbit then MsgText="Orbit Display Enabled"else MsgText="Orbit Display Disabled"end end)MakeButton("Enable Emergency Warp","Disable Emergency Warp",bi,bh,ab+bi+20,ac,function()return EmergencyWarp end,function()EmergencyWarp=not EmergencyWarp;if EmergencyWarp then MsgText="Emergency Warp Enabled"else MsgText="Emergency Warp Disabled"end end,function()return warpdrive~=nil end)ac=ac+bh+20;MakeButton("Glide Re-Entry","Cancel Glide Re-Entry",bi,bh,ab,ac,function()return Reentry end,function()ReentryMode=true;BeginReentry()end,function()return CoreAltitude>ReentryAltitude end)MakeButton("Parachute Re-Entry","Cancel Parachute Re-Entry",bi,bh,ab+bi+20,ac,function()return Reentry end,BeginReentry,function()return CoreAltitude>ReentryAltitude end)ac=ac+bh+20;MakeButton("Engage Follow Mode","Disable Follow Mode",bi,bh,ab,ac,function()return FollowMode end,ToggleFollowMode,function()return l()==1 end)MakeButton("Enable Repair Arrows","Disable Repair Arrows",bi,bh,ab+bi+20,ac,function()return I end,function()I=not I;if I then MsgText="Repair Arrows Enabled"else MsgText="Repair Arrows Diabled"end end,function()return l()==1 end)ac=ac+bh+20;MakeButton("Enable AGG","Disable AGG",bi,bh,ab,ac,function()return antigrav.getState()==1 end,ToggleAntigrav,function()return antigrav~=nil end)ac=ac+bh+20;MakeButton(function()return string.format("Toggle Control Scheme - Current: %s",userControlScheme)end,function()return string.format("Control Scheme: %s",userControlScheme)end,bi*2,bh,ab,ac,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(ao)local bl=CoreAltitude;local velocity=core.getVelocity()local bm=vec3(velocity):len()local bn=vec3(core.getWorldVertical())local bo=vec3(core.getConstructWorldOrientationForward())local bp=vec3(core.getConstructWorldOrientationRight())local aF=getPitch(bn,bo,bp)local bq=getRoll(bn,bo,bp)local br=bq;local bs=aF;local bt=f()local bu=a(unit.getThrottle())local bv=bm*3.6;local bw=unit.getAxisCommandValue(0)local bx=GetFlightStyle()local by="ROLL"local bz=unit.getClosestPlanetInfluence()>0;if bu==nil then bu=0 end;if not bz then if bm>5 then aF=getRelativePitch(velocity)bq=getRelativeYaw(velocity)else aF=0;bq=0 end;by="YAW"end;ao[#ao+1]=LastOdometerOutput;ao[#ao+1]=p;ao[#ao+1]=RadarMessage;if S%L==0 then Q=true end;if fuelX~=0 and fuelY~=0 then DrawTank(ao,Q,fuelX,"Atmospheric ","ATMO",E,O,P)DrawTank(ao,Q,fuelX+100,"Space fuel t","SPACE",F,M,N)DrawTank(ao,Q,fuelX+200,"Rocket fuel ","ROCKET",G,J,K)end;if Q then Q=false;S=0 end;S=S+1;DrawVerticalSpeed(ao,bl,bt)if l()==0 or RemoteHud then if not IsInFreeLook()or brightHud then if bz then DrawRollLines(ao,centerX,centerY,br,by,bz)DrawArtificialHorizon(ao,bs,br,bt,centerX,centerY,bz)DrawAltitudeDisplay(ao,bl,bt)else DrawRollLines(ao,centerX,centerY,bq,by,bz)DrawArtificialHorizon(ao,aF,bq,bt,centerX,centerY,bz)end;DrawPrograde(ao,bt,velocity,bm,centerX,centerY)end end;DrawThrottle(ao,bx,bu,bw)DrawSpeed(ao,bv)DrawWarnings(ao)DisplayOrbitScreen(ao)if screen_2 then local bA=vec3(core.getConstructWorldPos())local ab=960+bA.x/MapXRatio;local ac=450+bA.y/MapYRatio;screen_2.moveContent(YouAreHere,(ab-80)/19.2,(ac-80)/10.8)end end;function IsInFreeLook()return system.isViewLocked()==0 and userControlScheme~="keyboard"and l()==0 end;function HUDPrologue(ao)local bB=rgb;local bC=X;local bD=rgb;local bE=X;if IsInFreeLook()and not brightHud then bB=[[rgb(]]..a(PrimaryR*0.4+0.5)..","..a(PrimaryG*0.4+0.5)..","..a(PrimaryB*0.3+0.5)..[[)]]bC=[[rgb(]]..a(PrimaryR*0.3+0.5)..","..a(PrimaryG*0.3+0.5)..","..a(PrimaryB*0.2+0.5)..[[)]]end;ao[#ao+1]=b([[ diff --git a/src/ButtonHUD.lua b/src/ButtonHUD.lua index 36adfb2..9022640 100644 --- a/src/ButtonHUD.lua +++ b/src/ButtonHUD.lua @@ -10,7 +10,7 @@ function script.onStart() {1000, 5000, 10000, 20000, 30000}) -- Written by Dimencia and Archaegeo. Optimization and Automation of scripting by ChronosWS Linked sources where appropriate, most have been modified. - VERSION_NUMBER = 4.832 + VERSION_NUMBER = 4.833 -- function localizations local mfloor = math.floor local stringf = string.format