-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathButtonHUD.conf
420 lines (406 loc) · 167 KB
/
ButtonHUD.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
name: ButtonsHud - Dimencia and Archaegeo v5.100 (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
select: manual
telemeter:
class: TelemeterUnit
select: manual
vBooster:
class: VerticalBooster
hover:
class: Hovercraft
door:
class: DoorUnit
select: manual
switch:
class: ManualSwitchUnit
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([[
<pre style="color: white; background-color: black; font-family: Consolas,monospace; font-size: 4vh; white-space: pre-wrap; margin: 1em">
Error: ]] .. message .. [[
</pre>]])
else
value.setCenteredText(message)
end
end
end
end
if __wrap_lua__printError and system and system.print then
system.print("Error: " .. message:gsub("\n", "<br>"))
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: (Default: false) Toggle on to use the below preferences. Toggle off to use saved preferences. Preferences will save regardless when exiting seat.
freeLookToggle = true --export: (Default: true) Set to false for vanilla DU free look behavior.
BrakeToggleDefault = true --export: (Default: true) Whether your brake toggle is on/off by default. Can be adjusted in the button menu. Of is vanilla DU brakes.
RemoteFreeze = false --export: (Default: false) Whether or not to freeze you when using a remote controller. Breaks some things, only freeze on surfboards
RemoteHud = false --export: (Default: false) Whether you want full HUD while in remote mode, experimental, might not look right.
brightHud = false --export: (Default: false) Enable to prevent hud dimming when in freelook.
VanillaRockets = false --export: (Default: false) If on, rockets behave like vanilla
InvertMouse = false --export: (Default: false) If true, then when controlling flight mouse Y axis is inverted (pushing up noses plane down) Does not affect selecting buttons or camera.
userControlScheme = "virtual joystick" --export: (Default: "virtual joystick") Set to "virtual joystick", "mouse", or "keyboard"
ResolutionX = 1920 --export: (Default: 1920) Does not need to be set to same as game resolution. You can set 1920 on a 2560 to get larger resolution
ResolutionY = 1080 --export: (Default: 1080) Does not need to be set to same as game resolution. You can set 1080 on a 1440 to get larger resolution
PrimaryR = 130 --export: (Default: 130) Primary HUD color
PrimaryG = 224 --export: (Default: 224) Primary HUD color
PrimaryB = 255 --export: (Default: 255) Primary HUD color
centerX = 960 --export: (Default: 960) X postion of Artifical Horizon (KSP Navball), Default 960. Use centerX=700 and centerY=880 for lower left placement.
centerY = 540 --export: (Default: 540) Y postion of Artifical Horizon (KSP Navball), Default 540. Use centerX=700 and centerY=880 for lower left placement.
throtPosX = 1300 --export: (Default: 1300) X position of Throttle Indicator, default 1300 to put it to right of default AH centerX parameter.
throtPosY = 540 --export: (Default: 540) Y position of Throttle indicator, default is 540 to place it centered on default AH centerY parameter.
vSpdMeterX = 1525 --export: (Default: 1525) X postion of Vertical Speed Meter. Default 1525 (use 1920x1080, it will scale)
vSpdMeterY = 250 --export: (Default: 250) Y postion of Vertical Speed Meter. Default 250 (use 1920x1080, it will scale)
altMeterX = 550 --export: (Default: 550) X postion of Altimeter. Default 550 (use 1920x1080, it will scale)
altMeterY = 540 --export: (Default: 540) Y postion of Altimeter. Default 500 (use 1920x1080, it will scale)
fuelX = 100 --export: (Default: 100) X position of fuel tanks, default is 100 for left side, set both fuelX and fuelY to 0 to hide fuel
fuelY = 350 --export: (Default: 350) Y position of fuel tanks, default 350 for left side, set both fuelX and fuelY to 0 to hide fuel
circleRad = 400 --export: (Default: 400) The size of the artifical horizon circle, recommended minimum 100, maximum 400. Looks different > 200. Set to 0 to remove.
DeadZone = 50 --export: (Default: 50) Number of pixels of deadzone at the center of the screen
DisplayOrbit = true --export: (Default: true) Show Orbit display when valid or not. May be toggled with shift Buttons
OrbitMapSize = 250 --export: (Default: 250) Size of the orbit map, make sure it is divisible by 4
OrbitMapX = 75 --export: (Default: 75) X postion of Orbit Display Disabled
OrbitMapY = 0 --export: (Default: 0) Y position of Orbit Display
showHud = true --export: (Default: true) Uncheck to hide the HUD and only use autopilot features via ALT+# keys.
ShowOdometer = true --export: (Default: true) Uncheck to hide the odometer panel up top.
hideHudOnToggleWidgets = true --export: (Default: true) Uncheck to keep showing HUD when you toggle on the widgets via ALT+3.
ShiftShowsRemoteButtons = true --export: (Default: true) Whether or not pressing Shift in remote controller mode shows you the buttons (otherwise no access to them)
StallAngle = 35 --export: (Default: 35) Determines how much Autopilot is allowed to make you yaw/pitch in atmosphere. Also gives a stall warning when not autopilot. (default 35, higher = more tolerance for yaw/pitch/roll)
speedChangeLarge = 5 --export: (Default: 5) The speed change that occurs when you tap speed up/down, default is 5 (25% throttle change).
speedChangeSmall = 1 --export: (Default: 1) the speed change that occurs while you hold speed up/down, default is 1 (5% throttle change).
brakeLandingRate = 30 --export: (Default: 30) Max loss of altitude speed in m/s when doing a brake landing, default 30. This is to prevent "bouncing" as hover/boosters catch you. Do not use negative number.
MaxPitch = 30 --export: (Default: 30) Maximum allowed pitch during takeoff and altitude changes while in altitude hold. Default is 20 deg. You can set higher or lower depending on your ships capabilities.
ReentrySpeed = 1050 --export: (Default: 1050) Target re-entry speed once in atmosphere in km/h.
AtmoSpeedLimit = 1050 --export: (Default: 1050) Speed limit in Atmosphere in km/h. If you exceed this limit the ship will attempt to break till below this limit.
SpaceSpeedLimit = 30000 --export: (Default: 30000) Space speed limit in KM/H. If you hit this speed but are not in active autopilot, engines will turn off.
ReentryAltitude = 2500 --export: (Default: 2500) Target alititude when using re-entry.
AutoTakeoffAltitude = 1000 --export: (Default: 1000) How high above your ground starting position AutoTakeoff tries to put you
TargetHoverHeight = 50 --export: (Default: 50) Hover height when retracting landing gear
LandingGearGroundHeight = 0 --export: (Default: 0) Set to AGL-1 when on ground (or 0)
MaxGameVelocity = 8333.00 --export: (Default: 8333.00) Max speed for your autopilot in m/s, do not go above 8333.055 (30000 km/hr), can be reduced to safe fuel, use 6944.4444 for 25000km/hr
TargetOrbitRadius = 1.4 --export: (Default: 1.4) How tight you want to orbit the planet at end of autopilot. The smaller the value the tighter the orbit. 1.4 sets an Alioth orbit of 56699m.
AutopilotInterplanetaryThrottle = 1.0 --export: (Default: 1.0) How much throttle, 0.0 to 1.0, you want it to use when in autopilot to another planet to reach MaxGameVelocity
warmup = 32 --export: (Default: 32) How long it takes your engines to warmup. Basic Space Engines, from XS to XL: 0.25,1,4,16,32
MouseYSensitivity = 0.003 --export: (Default: 0.003) For virtual joystick only
MouseXSensitivity = 0.003 --export: (Default: 0.003) For virtual joystick only
autoRollPreference = false --export: (Default: false) [Only in atmosphere]<br>When the pilot stops rolling, flight model will try to get back to horizontal (no roll)
autoRollFactor = 2 --export: (Default: 2) [Only in atmosphere]<br>When autoRoll is engaged, this factor will increase to strength of the roll back to 0<br>Valid values: Superior or equal to 0.01
rollSpeedFactor = 1.5 --export: (Default: 1.5) This factor will increase/decrease the player input along the roll axis<br>(higher value may be unstable)<br>Valid values: Superior or equal to 0.01
turnAssist = true --export: (Default: true) [Only in atmosphere]<br>When the pilot is rolling, the flight model will try to add yaw and pitch to make the construct turn better<br>The flight model will start by adding more yaw the more horizontal the construct is and more pitch the more vertical it is
turnAssistFactor = 2 --export: (Default: 2) [Only in atmosphere]<br>This factor will increase/decrease the turnAssist effect<br>(higher value may be unstable)<br>Valid values: Superior or equal to 0.01
TrajectoryAlignmentStrength = 0.002 --export: (Default: 0.002) How strongly AP tries to align your velocity vector to the target when not in orbit, recommend 0.002
torqueFactor = 2 --export: (Default: 2) Force factor applied to reach rotationSpeed<br>(higher value may be unstable)<br>Valid values: Superior or equal to 0.01
pitchSpeedFactor = 0.8 --export: (Default: 0.8) For keyboard control
yawSpeedFactor = 1 --export: (Default: 1) For keyboard control
brakeSpeedFactor = 3 --export: (Default: 3) When braking, this factor will increase the brake force by brakeSpeedFactor * velocity<br>Valid values: Superior or equal to 0.01
brakeFlatFactor = 1 --export: (Default: 1) When braking, this factor will increase the brake force by a flat brakeFlatFactor * velocity direction><br>(higher value may be unstable)<br>Valid values: Superior or equal to 0.01
DampingMultiplier = 40 --export: (Default: 40) How strongly autopilot dampens when nearing the correct orientation
fuelTankHandlingAtmo = 0 --export: (Default: 0) For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks.
fuelTankHandlingSpace = 0 --export: (Default: 0) For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks.
fuelTankHandlingRocket = 0 --export: (Default: 0) For accurate estimates, set this to the fuel tank handling level of the person who placed the element. Ignored for slotted tanks.
ContainerOptimization = 0 --export: (Default: 0) For accurate estimates, set this to the Container Optimization level of the person who placed the tanks. Ignored for slotted tanks.
FuelTankOptimization = 0 --export: (Default: 0) For accurate unslotted fuel tank calculation, set this to the fuel tank optimization skill level of the person who placed the tank. Ignored for slotted tanks.
ExtraLongitudeTags = "none" --export: (Default: "none") Enter any extra longitudinal tags you use inside '' seperated by space, i.e. "forward faster major" These will be added to the engines that are control by longitude.
ExtraLateralTags = "none" --export: (Default: "none") Enter any extra lateral tags you use inside '' seperated by space, i.e. "left right" These will be added to the engines that are control by lateral.
ExtraVerticalTags = "none" --export: (Default: "none") Enter any extra longitudinal tags you use inside '' seperated by space, i.e. "up down" These will be added to the engines that are control by vertical.
ExternalAGG = false --export: (Default: false) Toggle On if using an external AGG system. If on will prevent this HUD from doing anything with AGG.
UseSatNav = false --export: (Default: false) Toggle on if using Trog SatNav script. This will provide SatNav support.
apTickRate = 0.0166667 --export: (Default: 0.0166667) Set the Tick Rate for your autopilot features. 0.016667 is effectively 60 fps and the default value. 0.03333333 is 30 fps.
hudTickRate = 0.0666667 --export: (Default: 0.0666667) Set the tick rate for your HUD. Default is 4 times slower than apTickRate
ShouldCheckDamage = true --export: (Default: true) Whether or not damage checks are performed. Disabled for performance on very large ships
CalculateBrakeLandingSpeed = false --export: (Default: false) Whether BrakeLanding speed at non-waypoints should be calculated or use the brakeLandingRate user setting. Only set to true for ships with low mass to lift capability.
autoRollRollThreshold = 1.0 --export: (Default: 1.0) The minimum amount of roll before autoRoll kicks in and stabilizes (if active)
Nav=Navigator.new(system,core,unit)script={}BrakeToggleStatus=BrakeToggleDefault;BrakeIsOn=false;RetrogradeIsOn=false;ProgradeIsOn=false;Autopilot=false;TurnBurn=false;AltitudeHold=false;BrakeLanding=false;AutoTakeoff=false;Reentry=false;HoldAltitude=1000;AutopilotAccelerating=false;AutopilotRealigned=false;AutopilotBraking=false;AutopilotCruising=false;AutopilotEndSpeed=0;AutopilotStatus="Aligning"AutopilotPlanetGravity=0;PrevViewLock=1;AutopilotTargetName="None"AutopilotTargetCoords=nil;AutopilotTargetIndex=0;GearExtended=nil;TotalDistanceTravelled=0.0;TotalFlightTime=0;SavedLocations={}VectorToTarget=false;LocationIndex=0;LastMaxBrake=0;LockPitch=nil;LastMaxBrakeInAtmo=0;AntigravTargetAltitude=core.getAltitude()LastStartTime=0;SpaceTarget=false;local a={"userControlScheme","TargetOrbitRadius","apTickRate","freeLookToggle","turnAssist","PrimaryR","PrimaryG","PrimaryB","warmup","DeadZone","circleRad","MouseXSensitivity","MouseYSensitivity","MaxGameVelocity","showHud","autoRollPreference","InvertMouse","pitchSpeedFactor","yawSpeedFactor","rollSpeedFactor","brakeSpeedFactor","brakeFlatFactor","autoRollFactor","turnAssistFactor","torqueFactor","AutoTakeoffAltitude","TargetHoverHeight","AutopilotInterplanetaryThrottle","hideHudOnToggleWidgets","DampingMultiplier","fuelTankHandlingAtmo","ExternalAGG","ShouldCheckDamage","fuelTankHandlingSpace","fuelTankHandlingRocket","RemoteFreeze","hudTickRate","speedChangeLarge","speedChangeSmall","brightHud","brakeLandingRate","MaxPitch","ReentrySpeed","AtmoSpeedLimit","ReentryAltitude","centerX","centerY","SpaceSpeedLimit","vSpdMeterX","vSpdMeterY","altMeterX","altMeterY","fuelX","fuelY","LandingGearGroundHeight","TrajectoryAlignmentStrength","RemoteHud","StallAngle","ResolutionX","ResolutionY","UseSatNav","FuelTankOptimization","ContainerOptimization","ExtraLongitudeTags","ExtraLateralTags","ExtraVerticalTags","OrbitMapSize","OrbitMapX","OrbitMapY","DisplayOrbit","CalculateBrakeLandingSpeed"}local b={"SpaceTarget","BrakeToggleStatus","BrakeIsOn","RetrogradeIsOn","ProgradeIsOn","Autopilot","TurnBurn","AltitudeHold","BrakeLanding","Reentry","AutoTakeoff","HoldAltitude","AutopilotAccelerating","AutopilotBraking","AutopilotCruising","AutopilotRealigned","AutopilotEndSpeed","AutopilotStatus","AutopilotPlanetGravity","PrevViewLock","AutopilotTargetName","AutopilotTargetCoords","AutopilotTargetIndex","TotalDistanceTravelled","TotalFlightTime","SavedLocations","VectorToTarget","LocationIndex","LastMaxBrake","LockPitch","LastMaxBrakeInAtmo","AntigravTargetAltitude","LastStartTime"}local c=system.print;local d=math.floor;local e=string.format;local f=json.decode;local g=json.encode;local h=core.getElementMaxHitPointsById;local j=unit.getAtmosphereDensity;local k=core.getElementHitPointsById;local l=core.getElementTypeById;local m=core.getElementMassById;local n=core.getConstructMass;local o=Nav.control.isRemoteControlled;function round(p,q)local r=10^(q or 0)return d(p*r+0.5)/r end;local s=round(ResolutionX/2,0)local t=round(ResolutionY/2,0)local u=false;local v=true;local w=55;local x=false;local y=1;local z=1;local A=false;local B=0;local C=0;local D=0;local E=0;local F=0;local G=0;local H=0;local I=false;local J=false;local K="empty"local L=1;local M=5;local N=5;local O=false;local P,Q=0;local R,S=0;local T=false;local U=false;local V=nil;local W=0;local X=0;local Y=false;local Z=0;local a0=0;local a1=0;local a2=3;local a3=0;local a4=""local a5=""local a6=0;local a7=false;local a8=false;local a9=false;local aa=-1;local ab=false;local ac=""local ad=j()>0;local ae=core.getAltitude()local af=core.getElementIdList()local ag=system.getTime()local ah=nil;local ai=false;local aj=[[rgb(]]..d(PrimaryR+0.5)..","..d(PrimaryG+0.5)..","..d(PrimaryB+0.5)..[[)]]local ak=[[rgb(]]..d(PrimaryR*0.9+0.5)..","..d(PrimaryG*0.9+0.5)..","..d(PrimaryB*0.9+0.5)..[[)]]local al={}local am=0;local an=0;local ao=""local ap=true;local aq={}local ar=1;local as=0.001;local at=ResolutionX;local au=ResolutionY;local av=nil;local aw=nil;local ax=nil;local ay=nil;local az=false;local aA=false;local aB=0;local aC=nil;local aD={}local aE={}local aF={}local aG=0;local aH=false;local aI={}local aJ={}local aK=d(1/apTickRate)*2;local aL={}local aM={}local aN={}local aO={}local aP=false;local aQ=16;local aR=0;local aS=nil;local aT=""local aU=nil;local aV=nil;local aW=nil;local aX=nil;local aY=nil;local aZ=nil;local a_=nil;local b0=nil;local b1=false;local b2=false;local b3=autoRollPreference;local b4=vec3(core.getConstructWorldOrientationForward()):dot(vec3(core.getWorldVelocity()):normalize())local b5=vec3(core.getWorldVelocity())local b6=vec3(b5):len()local b7=math.cos(StallAngle*constants.deg2rad)local b8=LandingGearGroundHeight;local b9=system.getMouseDeltaX()local ba=system.getMouseDeltaY()local bb=false;local bc=system.getTime()local bd=0;local be=0;function LoadVariables()if dbHud_1 then local bf=dbHud_1.hasKey;if not useTheseSettings then for bg,bh in pairs(a)do if bf(bh)then local bi=f(dbHud_1.getStringValue(bh))if bi~=nil then c(bh.." "..dbHud_1.getStringValue(bh))_G[bh]=bi;az=true end end end end;coroutine.yield()for bg,bh in pairs(b)do if bf(bh)then local bi=f(dbHud_1.getStringValue(bh))if bi~=nil then c(bh.." "..dbHud_1.getStringValue(bh))_G[bh]=bi;az=true end end end;if useTheseSettings then K="Updated user preferences used. Will be saved when you exit seat.\nToggle off useTheseSettings to use saved values"a2=5 elseif az then K="Loaded Saved Variables (see Lua Chat Tab for list)"else K="No Saved Variables Found - Stand up / leave remote to save settings"end else K="No databank found, install one anywhere and rerun the autoconfigure to save variables"end;local bj=system.getTime()if LastStartTime+180<bj then LastMaxBrakeInAtmo=0 end;if az then s=round(ResolutionX/2,0)t=round(ResolutionY/2,0)at=ResolutionX;au=ResolutionY;BrakeToggleStatus=BrakeToggleDefault;userControlScheme=string.lower(userControlScheme)b3=autoRollPreference end;LastStartTime=bj;if string.find("keyboard virtual joystick mouse",userControlScheme)==nil then K="Invalid User Control Scheme selected. Change userControlScheme in Lua Parameters to keyboard, mouse, or virtual joystick\nOr use shift and button in screen"a2=5 end;b7=math.cos(StallAngle*constants.deg2rad)if antigrav and not ExternalAGG then if AntigravTargetAltitude==nil then AntigravTargetAltitude=ae end;antigrav.setBaseAltitude(AntigravTargetAltitude)end;aj=[[rgb(]]..d(PrimaryR+0.5)..","..d(PrimaryG+0.5)..","..d(PrimaryB+0.5)..[[)]]ak=[[rgb(]]..d(PrimaryR*0.9+0.5)..","..d(PrimaryG*0.9+0.5)..","..d(PrimaryB*0.9+0.5)..[[)]]end;function CalculateFuelVolume(bk,bl)if bk>bl then bl=bk end;if ContainerOptimization>0 then bl=bl-bl*ContainerOptimization*0.05 end;if FuelTankOptimization>0 then bl=bl-bl*FuelTankOptimization*0.05 end;return bl end;function ProcessElements()local bm=fuelX~=0 and fuelY~=0;for bg in pairs(af)do local type=l(af[bg])c(type)if type=="Landing Gear"then c("HERE1")A=true end;if type=="Dynamic Core Unit"then local bn=h(af[bg])if bn>10000 then aQ=128 elseif bn>1000 then aQ=64 elseif bn>150 then aQ=32 end end;aG=aG+h(af[bg])if bm and(type=="Atmospheric Fuel Tank"or type=="Space Fuel Tank"or type=="Rocket Fuel Tank")then local bn=h(af[bg])local bo=m(af[bg])local bk=0;local bp=system.getTime()if type=="Atmospheric Fuel Tank"then local bl=400;local bq=35.03;if bn>10000 then bl=51200;bq=5480 elseif bn>1300 then bl=6400;bq=988.67 elseif bn>150 then bl=1600;bq=182.67 end;bk=bo-bq;if fuelTankHandlingAtmo>0 then bl=bl+bl*fuelTankHandlingAtmo*0.2 end;bl=CalculateFuelVolume(bk,bl)aD[#aD+1]={af[bg],core.getElementNameById(af[bg]),bl,bq,bk,bp}end;if type=="Rocket Fuel Tank"then local bl=320;local bq=173.42;if bn>65000 then bl=40000;bq=25740 elseif bn>6000 then bl=5120;bq=4720 elseif bn>700 then bl=640;bq=886.72 end;bk=bo-bq;if fuelTankHandlingRocket>0 then bl=bl+bl*fuelTankHandlingRocket*0.1 end;bl=CalculateFuelVolume(bk,bl)aF[#aF+1]={af[bg],core.getElementNameById(af[bg]),bl,bq,bk,bp}end;if type=="Space Fuel Tank"then local bl=2400;local bq=182.67;if bn>10000 then bl=76800;bq=5480 elseif bn>1300 then bl=9600;bq=988.67 end;bk=bo-bq;if fuelTankHandlingSpace>0 then bl=bl+bl*fuelTankHandlingSpace*0.2 end;bl=CalculateFuelVolume(bk,bl)aE[#aE+1]={af[bg],core.getElementNameById(af[bg]),bl,bq,bk,bp}end end end end;function SetupChecks()if gyro~=nil then ah=gyro.getState()==1 end;if userControlScheme~="keyboard"then system.lockView(1)else system.lockView(0)end;if radar_1 then if l(radar_1.getId())=="Space Radar"then T=true else U=true end end;local br=j()if door and(br>0 or br==0 and ae<10000)then for _,bh in pairs(door)do bh.toggle()end end;if switch then for _,bh in pairs(switch)do bh.toggle()end end;if forcefield and(br>0 or br==0 and ae<10000)then for _,bh in pairs(forcefield)do bh.toggle()end end;if antigrav~=nil and not ExternalAGG then if antigrav.getState()==1 then antigrav.show()end end;if o()==1 and RemoteFreeze then system.freeze(1)else system.freeze(0)end;if A then c("HERE2")GearExtended=Nav.control.isAnyLandingGearExtended()==1;if GearExtended then Nav.control.extendLandingGears()else Nav.control.retractLandingGears()end end;local bs=AboveGroundLevel()if bs~=-1 or not ad and vec3(core.getVelocity()):len()<50 then BrakeIsOn=true;if not A then GearExtended=true end else BrakeIsOn=false end;if b8~=nil then Nav.axisCommandManager:setTargetGroundAltitude(b8)if b8==0 and not A then GearExtended=true;BrakeIsOn=true end else b8=Nav:getTargetGroundAltitude()if GearExtended then Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)else Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)end end;if ad and bs~=-1 then a_=core.getMaxKinematicsParametersAlongAxis("ground",core.getConstructOrientationUp())[1]end;userControlScheme=string.lower(userControlScheme)WasInAtmo=ad end;function ConvertResolutionX(bh)if ResolutionX==1920 then return bh else return round(ResolutionX*bh/1920,0)end end;function ConvertResolutionY(bh)if ResolutionY==1080 then return bh else return round(ResolutionY*bh/1080,0)end end;function RefreshLastMaxBrake(bt,bu)if bt==nil then bt=core.g()end;bt=round(bt,5)local bv=j()if bu~=nil and bu or(aC==nil or aC~=bt)then local b5=core.getVelocity()local bw=vec3(b5):len()local bx=f(unit.getData()).maxBrake;if bx~=nil and bx>0 and ad then bx=bx/utils.clamp(bw/100,0.1,1)bx=bx/bv;if bv>0.10 then if LastMaxBrakeInAtmo then LastMaxBrakeInAtmo=(LastMaxBrakeInAtmo+bx)/2 else LastMaxBrakeInAtmo=bx end end end;if bx~=nil and bx>0 then LastMaxBrake=bx end;aC=bt end end;function MakeButton(by,bz,bA,bB,bC,bD,bE,bF,bG)local bH={enableName=by,disableName=bz,width=bA,height=bB,x=bC,y=bD,toggleVar=bE,toggleFunction=bF,drawCondition=bG,hovered=false}table.insert(aq,bH)return bH end;function UpdateAtlasLocationsList()AtlasOrdered={}for bg,bh in pairs(aS[0])do table.insert(AtlasOrdered,{name=bh.name,index=bg})end;local function bI(bJ,bK)return bJ.name<bK.name end;table.sort(AtlasOrdered,bI)end;function AddLocationsToAtlas()for bg,bh in pairs(SavedLocations)do table.insert(aS[0],bh)end;UpdateAtlasLocationsList()end;function float_eq(bL,bM)if bL==0 then return math.abs(bM)<1e-09 end;if bM==0 then return math.abs(bL)<1e-09 end;return math.abs(bL-bM)<math.max(math.abs(bL),math.abs(bM))*epsilon end;function zeroConvertToMapPosition(bN,bO)local bP=vec3(bO)if bN.bodyId==0 then return setmetatable({latitude=bP.x,longitude=bP.y,altitude=bP.z,bodyId=0,systemId=bN.planetarySystemId},MapPosition)end;local bQ=bP-bN.center;local a3=bQ:len()local bR=a3-bN.radius;local bS=0;local bT=0;if not float_eq(a3,0)then local bU=math.atan(bQ.y,bQ.x)bT=bU>=0 and bU or 2*math.pi+bU;bS=math.pi/2-math.acos(bQ.z/a3)end;return setmetatable({latitude=math.deg(bS),longitude=math.deg(bT),altitude=bR,bodyId=bN.bodyId,systemId=bN.planetarySystemId},MapPosition)end;function zeroConvertToWorldCoordinates(bV)local p=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local bW='::pos{'..p..','..p..','..p..','..p..','..p..'}'local bX,bY,bS,bT,bR=string.match(bV,bW)if bX=="0"and bY=="0"then return vec3(tonumber(bS),tonumber(bT),tonumber(bR))end;bT=math.rad(bT)bS=math.rad(bS)local planet=aS[tonumber(bX)][tonumber(bY)]local bZ=math.cos(bS)local b_=vec3(bZ*math.cos(bT),bZ*math.sin(bT),math.sin(bS))return planet.center+(planet.radius+bR)*b_ end;function AddNewLocationByWaypoint(c0,planet,bV)if dbHud_1 then local c1={}local position=zeroConvertToWorldCoordinates(bV)if planet.name=="Space"then c1={position=position,name=c0,atmosphere=false,planetname=planet.name,gravity=planet.gravity}else local br=false;if planet.hasAtmosphere then br=true else br=false end;c1={position=position,name=c0,atmosphere=br,planetname=planet.name,gravity=planet.gravity}end;SavedLocations[#SavedLocations+1]=c1;table.insert(aS[0],c1)UpdateAtlasLocationsList()else K="Databank must be installed to save locations"end end;function AddNewLocation()if dbHud_1 then local position=vec3(core.getConstructWorldPos())local c2=planet.name..". "..#SavedLocations;if radar_1 then local c3,_=radar_1.getData():match('"constructId":"([0-9]*)","distance":([%d%.]*)')if c3~=nil and c3~=""then c2=c2 .." "..radar_1.getConstructName(c3)end end;local c1={}local br=false;if planet.hasAtmosphere then br=true end;c1={position=position,name=c2,atmosphere=br,planetname=planet.name,gravity=planet.gravity}SavedLocations[#SavedLocations+1]=c1;table.insert(aS[0],c1)UpdateAtlasLocationsList()K="Location saved as "..c2 else K="Databank must be installed to save locations"end end;function UpdatePosition(c4)local c5=-1;local c1;for bg,bh in pairs(SavedLocations)do if bh.name and bh.name==CustomTarget.name then c5=bg;break end end;if c5~=-1 then local c6;if c4~=nil then c1={position=SavedLocations[c5].position,name=c4,atmosphere=SavedLocations[c5].atmosphere,planetname=SavedLocations[c5].planetname,gravity=SavedLocations[c5].gravity}else c1={position=vec3(core.getConstructWorldPos()),name=SavedLocations[c5].name,atmosphere=j(),planetname=planet.name,gravity=unit.getClosestPlanetInfluence()}end;SavedLocations[c5]=c1;c5=-1;for bg,bh in pairs(aS[0])do if bh.name and bh.name==CustomTarget.name then c5=bg end end;if c5>-1 then aS[0][c5]=c1 end;UpdateAtlasLocationsList()K=CustomTarget.name.." position updated"AutopilotTargetIndex=0;UpdateAutopilotTarget()else K="Name Not Found"end end;function ClearCurrentPosition()local c5=-1;for bg,bh in pairs(aS[0])do if bh.name and bh.name==CustomTarget.name then c5=bg end end;if c5>-1 then table.remove(aS[0],c5)end;c5=-1;for bg,bh in pairs(SavedLocations)do if bh.name and bh.name==CustomTarget.name then K=bh.name.." saved location cleared"c5=bg;break end end;if c5~=-1 then table.remove(SavedLocations,c5)end;DecrementAutopilotTargetIndex()UpdateAtlasLocationsList()end;function DrawDeadZone(c7)c7[#c7+1]=e([[<circle class="dim line" style="fill:none" cx="50%%" cy="50%%" r="%d"/>]],DeadZone)end;function ToggleRadarPanel()if radarPanelID~=nil and a6==0 then system.destroyWidgetPanel(radarPanelID)radarPanelID=nil;if perisPanelID~=nil then system.destroyWidgetPanel(perisPanelID)perisPanelID=nil end else if a6==1 then system.destroyWidgetPanel(radarPanelID)radarPanelID=nil;_autoconf.displayCategoryPanel(radar,radar_size,L_TEXT("ui_lua_widget_periscope", "Periscope"),"periscope")perisPanelID=_autoconf.panels[_autoconf.panels_size]end;placeRadar=true;if radarPanelID==nil and placeRadar then _autoconf.displayCategoryPanel(radar,radar_size,L_TEXT("ui_lua_widget_radar", "Radar"),"radar")radarPanelID=_autoconf.panels[_autoconf.panels_size]placeRadar=false end;a6=0 end end;function ToggleWidgets()if ap then unit.show()core.show()if atmofueltank_size>0 then _autoconf.displayCategoryPanel(atmofueltank,atmofueltank_size,L_TEXT("ui_lua_widget_atmofuel", "Atmo Fuel"),"fuel_container")fuelPanelID=_autoconf.panels[_autoconf.panels_size]end;if spacefueltank_size>0 then _autoconf.displayCategoryPanel(spacefueltank,spacefueltank_size,L_TEXT("ui_lua_widget_spacefuel", "Space Fuel"),"fuel_container")spacefuelPanelID=_autoconf.panels[_autoconf.panels_size]end;if rocketfueltank_size>0 then _autoconf.displayCategoryPanel(rocketfueltank,rocketfueltank_size,L_TEXT("ui_lua_widget_rocketfuel", "Rocket Fuel"),"fuel_container")rocketfuelPanelID=_autoconf.panels[_autoconf.panels_size]end;ap=false else unit.hide()core.hide()if fuelPanelID~=nil then system.destroyWidgetPanel(fuelPanelID)fuelPanelID=nil end;if spacefuelPanelID~=nil then system.destroyWidgetPanel(spacefuelPanelID)spacefuelPanelID=nil end;if rocketfuelPanelID~=nil then system.destroyWidgetPanel(rocketfuelPanelID)rocketfuelPanelID=nil end;ap=true end end;function SetupInterplanetaryPanel()panelInterplanetary=system.createWidgetPanel("Interplanetary Helper")interplanetaryHeader=system.createWidget(panelInterplanetary,"value")interplanetaryHeaderText=system.createData('{"label": "Target Planet", "value": "N/A", "unit":""}')system.addDataToWidget(interplanetaryHeaderText,interplanetaryHeader)widgetDistance=system.createWidget(panelInterplanetary,"value")widgetDistanceText=system.createData('{"label": "distance", "value": "N/A", "unit":""}')system.addDataToWidget(widgetDistanceText,widgetDistance)widgetTravelTime=system.createWidget(panelInterplanetary,"value")widgetTravelTimeText=system.createData('{"label": "Travel Time", "value": "N/A", "unit":""}')system.addDataToWidget(widgetTravelTimeText,widgetTravelTime)widgetMaxMass=system.createWidget(panelInterplanetary,"value")widgetMaxMassText=system.createData('{"label": "Maximum Mass", "value": "N/A", "unit":""}')system.addDataToWidget(widgetMaxMassText,widgetMaxMass)widgetCurBrakeDistance=system.createWidget(panelInterplanetary,"value")widgetCurBrakeDistanceText=system.createData('{"label": "Cur Brake distance", "value": "N/A", "unit":""}')if not ad then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;widgetCurBrakeTime=system.createWidget(panelInterplanetary,"value")widgetCurBrakeTimeText=system.createData('{"label": "Cur Brake Time", "value": "N/A", "unit":""}')if not ad then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;widgetMaxBrakeDistance=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeDistanceText=system.createData('{"label": "Max Brake distance", "value": "N/A", "unit":""}')if not ad then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;widgetMaxBrakeTime=system.createWidget(panelInterplanetary,"value")widgetMaxBrakeTimeText=system.createData('{"label": "Max Brake Time", "value": "N/A", "unit":""}')if not ad then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;widgetTrajectoryAltitude=system.createWidget(panelInterplanetary,"value")widgetTrajectoryAltitudeText=system.createData('{"label": "Projected Altitude", "value": "N/A", "unit":""}')if not ad then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end;widgetTargetOrbit=system.createWidget(panelInterplanetary,"value")widgetTargetOrbitText=system.createData('{"label": "Target Altitude", "value": "N/A", "unit":""}')if not ad then system.addDataToWidget(widgetTargetOrbitText,widgetTargetOrbit)end end;function Contains(c8,c9,bC,bD,bA,bB)if c8>bC and c8<bC+bA and c9>bD and c9<bD+bB then return true else return false end end;function ToggleTurnBurn()TurnBurn=not TurnBurn end;function ToggleVectorToTarget(SpaceTarget)VectorToTarget=not VectorToTarget;if VectorToTarget then TurnBurn=false;if not AltitudeHold and not SpaceTarget then ToggleAltitudeHold()end end;VectorStatus="Proceeding to Waypoint"end;function ToggleAutoLanding()if BrakeLanding then BrakeLanding=false else StrongBrakes=planet.gravity*9.80665*n()<LastMaxBrake;if not StrongBrakes and b6>w then K="WARNING: Insufficient Brakes - Attempting coast landing, beware obstacles"end;AltitudeHold=false;AutoTakeoff=false;LockPitch=nil;BrakeLanding=true;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)end end;function ToggleAutoTakeoff()if AutoTakeoff then AutoTakeoff=false;if AltitudeHold then ToggleAltitudeHold()end else if not AltitudeHold then ToggleAltitudeHold()end;AutoTakeoff=true;HoldAltitude=ae+AutoTakeoffAltitude;GearExtended=false;Nav.control.retractLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(500)BrakeIsOn=true end end;function ToggleLockPitch()if LockPitch==nil then local ca=vec3(core.getConstructWorldOrientationForward())local cb=vec3(core.getConstructWorldOrientationRight())local cc=vec3(core.getWorldVertical())local cd=getPitch(cc,ca,cb)LockPitch=cd;AutoTakeoff=false;AltitudeHold=false;BrakeLanding=false else LockPitch=nil end end;function ToggleAltitudeHold()local bj=system.getTime()if bj-be<1.5 then if planet.hasAtmosphere then HoldAltitude=planet.spaceEngineMinAltitude-50;be=-1;if AltitudeHold then return end end else be=bj end;AltitudeHold=not AltitudeHold;if AltitudeHold then Autopilot=false;ProgradeIsOn=false;RetrogradeIsOn=false;I=false;BrakeLanding=false;Reentry=false;b3=true;LockPitch=nil;if not GearExtended and not BrakeIsOn or not ad or antigrav and antigrav.getState()==1 then AutoTakeoff=false;if be>-1 then HoldAltitude=ae end;if not a8 and Nav.axisCommandManager:getAxisCommandType(0)==0 then Nav.control.cancelCurrentControlMasterMode()end else AutoTakeoff=true;if be>-1 then HoldAltitude=ae+AutoTakeoffAltitude end;GearExtended=false;Nav.control.retractLandingGears()BrakeIsOn=true;Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)end;if a8 then HoldAltitude=100000 end else b3=autoRollPreference;AutoTakeoff=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;VectorToTarget=false end end;function ToggleFollowMode()if o()==1 then I=not I;if I then Autopilot=false;RetrogradeIsOn=false;ProgradeIsOn=false;AltitudeHold=false;Reentry=false;BrakeLanding=false;AutoTakeoff=false;OldGearExtended=GearExtended;GearExtended=false;Nav.control.retractLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)else BrakeIsOn=true;b3=autoRollPreference;GearExtended=OldGearExtended;if GearExtended then Nav.control.extendLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)end end else K="Follow Mode only works with Remote controller"I=false end end;function ToggleAutopilot()if AutopilotTargetIndex>0 and not Autopilot and not VectorToTarget and not a8 then local ce=zeroConvertToMapPosition(V,AutopilotTargetCoords)ce="::pos{"..ce.systemId..","..ce.bodyId..","..ce.latitude..","..ce.longitude..","..ce.altitude.."}"system.setWaypoint(ce)if CustomTarget~=nil then LockPitch=nil;SpaceTarget=CustomTarget.planetname=="Space"if SpaceTarget then if j()~=0 then a8=true;ToggleAltitudeHold()else Autopilot=true end elseif planet.name==CustomTarget.planetname then StrongBrakes=planet.gravity*9.80665*n()<LastMaxBrakeInAtmo;if not StrongBrakes and b6>w then K="Insufficient Brake Force\nCoast landing will be inaccurate"end;if j()>0 then if not AltitudeHold then if not VectorToTarget then ToggleVectorToTarget(SpaceTarget)end else if not VectorToTarget then ToggleVectorToTarget(SpaceTarget)end end else if ae>100000 or ae==0 then Autopilot=true else a7=true end end else RetrogradeIsOn=false;ProgradeIsOn=false;if j()~=0 then a8=true;ToggleAltitudeHold()else Autopilot=true end end elseif j()==0 then Autopilot=true;RetrogradeIsOn=false;ProgradeIsOn=false;AutopilotRealigned=false;I=false;AltitudeHold=false;BrakeLanding=false;Reentry=false;AutoTakeoff=false;u=false;LockPitch=nil else a8=true;ToggleAltitudeHold()end else a8=false;Autopilot=false;AutopilotRealigned=false;VectorToTarget=false;u=false;AutoTakeoff=false;AltitudeHold=false;VectorToTarget=false;HoldAltitude=ae end end;function ProgradeToggle()ProgradeIsOn=not ProgradeIsOn;RetrogradeIsOn=false;Autopilot=false;AltitudeHold=false;I=false;BrakeLanding=false;LockPitch=nil;Reentry=false;AutoTakeoff=false end;function RetrogradeToggle()RetrogradeIsOn=not RetrogradeIsOn;ProgradeIsOn=false;Autopilot=false;AltitudeHold=false;I=false;BrakeLanding=false;LockPitch=nil;Reentry=false;AutoTakeoff=false end;function BrakeToggle()BrakeIsOn=not BrakeIsOn;if BrakeLanding then BrakeLanding=false;b3=autoRollPreference end;if BrakeIsOn then AltitudeHold=false;VectorToTarget=false;AutoTakeoff=false;Reentry=false;ProgradeIsOn=false;BrakeLanding=false;AutoLanding=false;AltitudeHold=false;LockPitch=nil;b3=autoRollPreference end end;function CheckDamage(c7)local cf=0;ao=""local cg=aG;local ch=0;local ci=0;local cj=0;local ck=0;local cl=""for bg in pairs(af)do local bn=0;local cm=0;cm=h(af[bg])bn=k(af[bg])ch=ch+bn;if bn<cm then if bn==0 then cj=cj+1 else ci=ci+1 end;if aH and#al==0 then position=vec3(core.getElementPositionById(af[bg]))local bC=position.x-aQ;local bD=position.y-aQ;local cn=position.z-aQ;table.insert(al,core.spawnArrowSticker(bC,bD,cn+1,"down"))table.insert(al,core.spawnArrowSticker(bC,bD,cn+1,"down"))core.rotateSticker(al[2],0,0,90)table.insert(al,core.spawnArrowSticker(bC+1,bD,cn,"north"))table.insert(al,core.spawnArrowSticker(bC+1,bD,cn,"north"))core.rotateSticker(al[4],90,90,0)table.insert(al,core.spawnArrowSticker(bC-1,bD,cn,"south"))table.insert(al,core.spawnArrowSticker(bC-1,bD,cn,"south"))core.rotateSticker(al[6],90,-90,0)table.insert(al,core.spawnArrowSticker(bC,bD-1,cn,"east"))table.insert(al,core.spawnArrowSticker(bC,bD-1,cn,"east"))core.rotateSticker(al[8],90,0,90)table.insert(al,core.spawnArrowSticker(bC,bD+1,cn,"west"))table.insert(al,core.spawnArrowSticker(bC,bD+1,cn,"west"))core.rotateSticker(al[10],-90,0,90)table.insert(al,af[bg])end elseif aH and#al>0 and al[11]==af[bg]then for co in pairs(al)do core.deleteSticker(al[co])end;al={}end end;cf=d(ch/cg*100)if cf<100 then c7[#c7+1]=[[<g class="pbright txt">]]ck=d(cf*2.55)cl=e("rgb(%d,%d,%d)",255-ck,ck,0)if cf<100 then c7[#c7+1]=e([[<text class="txtbig txtmid" x=50%% y="1035" style="fill:%s">Elemental Integrity: %i %%</text>]],cl,cf)if cj>0 then c7[#c7+1]=e([[<text class="txtbig txtmid" x=50%% y="1055" style="fill:%s">Disabled Modules: %i Damaged Modules: %i</text>]],cl,cj,ci)elseif ci>0 then c7[#c7+1]=e([[<text class="txtbig txtmid" x=50%% y="1055"style="fill:%s">Damaged Modules: %i</text>]],cl,ci)end end;c7[#c7+1]=[[<\g>]]end end;function DrawCursorLine(c7)local cp=d(utils.clamp(a3/(at/4)*255,0,255))c7[#c7+1]=e("<line x1='0' y1='0' x2='%fpx' y2='%fpx' style='stroke:rgb(%d,%d,%d);stroke-width:2;transform:translate(50%%, 50%%)' />",a0,a1,d(PrimaryR+0.5)+cp,d(PrimaryG+0.5)-cp,d(PrimaryB+0.5)-cp)end;function getPitch(cq,cr,bK)local cs=cq:cross(bK):normalize_inplace()local cd=math.acos(utils.clamp(cs:dot(-cr),-1,1))*constants.rad2deg;if cs:cross(-cr):dot(bK)<0 then cd=-cd end;return cd end;local ct=math.atan;local function cu(cv,cw,cx)return ct(cw:cross(cx):dot(cv),cw:dot(cx))end;function clearAll()if ab then ab=false;AutopilotAccelerating=false;AutopilotBraking=false;AutopilotCruising=false;Autopilot=false;AutopilotRealigned=false;AutopilotStatus="Aligning"RetrogradeIsOn=false;ProgradeIsOn=false;AltitudeHold=false;Reentry=false;BrakeLanding=false;BrakeIsOn=false;AutoTakeoff=false;I=false;u=false;a7=false;a8=false;x=false;b3=autoRollPreference;VectorToTarget=false;TurnBurn=false;ah=false;LockPitch=nil else ab=true end end;function wipeSaveVariables()if not dbHud_1 then K="No Databank Found, unable to wipe. \nYou must have a Databank attached to ship prior to running the HUD autoconfigure"a2=5 else if aA then for bg,bh in pairs(a)do dbHud_1.setStringValue(bh,g(nil))end;for bg,bh in pairs(b)do if bh~="SavedLocations"then dbHud_1.setStringValue(bh,g(nil))end end;K="Databank wiped. New variables will save after re-enter seat and exit"a2=5;aA=false;az=false;Y=true else K="Press ALT-7 again to confirm wipe of ALL data"aA=true end end end;function CheckButtons()for _,bh in pairs(aq)do if bh.hovered then if not bh.drawCondition or bh.drawCondition()then bh.toggleFunction()end;bh.hovered=false end end end;function SetButtonContains()local bC=a0+at/2;local bD=a1+au/2;for _,bh in pairs(aq)do bh.hovered=Contains(bC,bD,bh.x,bh.y,bh.width,bh.height)end end;function DrawButton(c7,cy,hover,bC,bD,cz,cA,cB,cC,cD,cE)if type(cD)=="function"then cD=cD()end;if type(cE)=="function"then cE=cE()end;c7[#c7+1]=e("<rect x='%f' y='%f' width='%f' height='%f' fill='",bC,bD,cz,cA)if cy then c7[#c7+1]=e("%s'",cB)else c7[#c7+1]=cC end;if hover then c7[#c7+1]=" style='stroke:white; stroke-width:2'"else c7[#c7+1]=" style='stroke:black; stroke-width:1'"end;c7[#c7+1]="></rect>"c7[#c7+1]=e("<text x='%f' y='%f' font-size='24' fill='",bC+cz/2,bD+cA/2+5)if cy then c7[#c7+1]="black"else c7[#c7+1]="white"end;c7[#c7+1]="' text-anchor='middle' font-family='Montserrat'>"if cy then c7[#c7+1]=e("%s</text>",cD)else c7[#c7+1]=e("%s</text>",cE)end end;function DrawButtons(c7)local cF="rgb(50,50,50)'"local cG="rgb(210,200,200)"local cH=DrawButton;for _,bh in pairs(aq)do local bz=bh.disableName;local by=bh.enableName;if type(bz)=="function"then bz=bz()end;if type(by)=="function"then by=by()end;if not bh.drawCondition or bh.drawCondition()then cH(c7,bh.toggleVar(),bh.hovered,bh.x,bh.y,bh.width,bh.height,cG,cF,bz,by)end end end;function DrawTank(c7,aP,bC,cI,cJ,cK,cL,cM)local cN=1;local cO=2;local cP=3;local cQ=4;local cR=5;local cS=6;local cT=""local cU=0;local cV=fuelY;local cW=fuelY+10;if o()==1 and not RemoteHud then cV=cV-50;cW=cW-50 end;c7[#c7+1]=[[<g class="pdim txtfuel">]]if cJ=="ATMO"then cT="atmofueltank"elseif cJ=="SPACE"then cT="spacefueltank"else cT="rocketfueltank"end;cU=_G[cT.."_size"]if#cK>0 then for i=1,#cK do local c2=string.sub(cK[i][cO],1,12)local cX=0;for co=1,cU do if cK[i][cO]==f(unit[cT.."_"..co].getData()).name then cX=co;break end end;if aP or cL[i]==nil or cM[i]==nil then local cY=0;local cZ=0;local c_=0;local d0=0;local bp=system.getTime()if cX~=0 then cM[i]=f(unit[cT.."_"..cX].getData()).percentage;cL[i]=f(unit[cT.."_"..cX].getData()).timeLeft;if cL[i]=="n/a"then cL[i]=0 end else c_=m(cK[i][cN])-cK[i][cQ]cY=cK[i][cP]cM[i]=d(0.5+c_*100/cY)cZ=cK[i][cR]d0=cK[i][cS]if cZ<=c_ then cL[i]=0 else cL[i]=d(0.5+c_/((cZ-c_)/(bp-d0)))end;cK[i][cR]=c_;cK[i][cS]=bp end end;if c2==cI then c2=e("%s %d",cJ,i)end;if cX==0 then c2=c2 .." *"end;local d1;if cL[i]==0 then d1="n/a"else d1=FormatTimeString(cL[i])end;if cM[i]~=nil then local ck=d(cM[i]*2.55)local cl=e("rgb(%d,%d,%d)",255-ck,ck,0)local d2=""if d1~="n/a"and cL[i]<120 or cM[i]<5 then if aP then d2=[[class="red"]]end end;c7[#c7+1]=e([[
<text x=%d y="%d" %s>%s</text>
<text x=%d y="%d" style="fill:%s">%d%% %s</text>
]],bC,cV,d2,c2,bC,cW,cl,cM[i],d1)cV=cV+30;cW=cW+30 end end end;c7[#c7+1]="</g>"end;function HideInterplanetaryPanel()system.destroyWidgetPanel(panelInterplanetary)panelInterplanetary=nil end;function getRelativePitch(b5)b5=vec3(b5)local cd=-math.deg(math.atan(b5.y,b5.z))+180;cd=cd-90;if cd<0 then cd=360+cd end;if cd>180 then cd=-180+cd-180 end;return-cd end;function getRelativeYaw(b5)b5=vec3(b5)local d3=math.deg(math.atan(b5.y,b5.x))-90;if d3<-180 then d3=360+d3 end;return d3 end;function AlignToWorldVector(d4,d5,d6)if not ad or not bb or aa~=-1 or b6<w then local d7=d6;if d7==nil then d7=DampingMultiplier end;if d5==nil then d5=as end;d4=vec3(d4):normalize()local d8=vec3(core.getConstructWorldOrientationForward())-d4;local d9=-getMagnitudeInDirection(d8,core.getConstructWorldOrientationRight())*ar;local da=-getMagnitudeInDirection(d8,core.getConstructWorldOrientationUp())*ar;if am==0 then am=d9/2 end;if an==0 then an=da/2 end;if math.abs(d9)<0.1 then D=D-d9*2 else D=D-(d9+(d9-am)*d7)end;if math.abs(da)<0.1 then C=C+da*2 else C=C+da+(da-an)*d7 end;am=d9;an=da;if math.abs(d9)<d5 and math.abs(da)<d5 then return true end;return false elseif bb and aa==-1 then d4=vec3(core.getWorldVelocity())local d7=d6;if d7==nil then d7=DampingMultiplier end;if d5==nil then d5=as end;d4=vec3(d4):normalize()local d8=vec3(core.getConstructWorldOrientationForward())-d4;local d9=-getMagnitudeInDirection(d8,core.getConstructWorldOrientationRight())*ar;local da=-getMagnitudeInDirection(d8,core.getConstructWorldOrientationUp())*ar;if am==0 then am=d9/2 end;if an==0 then an=da/2 end;if math.abs(d9)<0.1 then D=D-d9*5 else D=D-(d9+(d9-am)*d7)end;if math.abs(da)<0.1 then C=C+da*5 else C=C+da+(da-an)*d7 end;am=d9;an=da;if math.abs(d9)<d5 and math.abs(da)<d5 then return true end;return false end end;function getAPEnableName()local c2=AutopilotTargetName;if c2==nil then local db,dc=getDistanceDisplayString((vec3(core.getConstructWorldPos())-CustomTarget.position):len())c2=CustomTarget.name.." "..db..dc end;if c2==nil then c2="None"end;return"Engage Autopilot: "..c2 end;function getAPDisableName()local c2=AutopilotTargetName;if c2==nil then c2=CustomTarget.name end;if c2==nil then c2="None"end;return"Disable Autopilot: "..c2 end;function ToggleAntigrav()if antigrav and not ExternalAGG then if antigrav.getState()==1 then antigrav.deactivate()antigrav.hide()else if AntigravTargetAltitude==nil then AntigravTargetAltitude=ae end;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;antigrav.activate()antigrav.show()end end end;function BeginReentry()if Reentry then K="Re-Entry cancelled"Reentry=false;b3=autoRollPreference;AltitudeHold=false elseif j()~=0 or unit.getClosestPlanetInfluence()<=0 or Reentry or not planet.hasAtmosphere then K="Re-Entry requirements not met: you must start out of atmosphere\n and within a planets gravity well over a planet with atmosphere"a2=5 elseif not x then StrongBrakes=planet.gravity*9.80665*n()<LastMaxBrakeInAtmo;if not StrongBrakes then K="WARNING: Insufficient Brakes for Parachute Re-Entry"else Reentry=true;if Nav.axisCommandManager:getAxisCommandType(0)~=controlMasterModeId.cruise then Nav.control.cancelCurrentControlMasterMode()end;b3=true;BrakeIsOn=false;K="Beginning Parachute Re-Entry - Strap In. Target speed: "..ReentrySpeed end else Reentry=true;if Nav.axisCommandManager:getAxisCommandType(0)~=controlMasterModeId.cruise then Nav.control.cancelCurrentControlMasterMode()end;AltitudeHold=true;b3=true;BrakeIsOn=false;HoldAltitude=ReentryAltitude;K="Beginning Re-entry. Target speed: "..ReentrySpeed.." Target Altitude: "..ReentryAltitude end end;function SetupButtons()local dd=50;local de=260;local df=MakeButton("Enable Brake Toggle","Disable Brake Toggle",de,dd,at/2-de/2,au/2+350,function()return BrakeToggleStatus end,function()BrakeToggleStatus=not BrakeToggleStatus;if BrakeToggleStatus then K="Brakes in Toggle Mode"else K="Brakes in Default Mode"end end)MakeButton("Align Prograde","Disable Prograde",de,dd,at/2-de/2-50-df.width,au/2-dd+380,function()return ProgradeIsOn end,ProgradeToggle)MakeButton("Align Retrograde","Disable Retrograde",de,dd,at/2-de/2+df.width+50,au/2-dd+380,function()return RetrogradeIsOn end,RetrogradeToggle,function()return j()==0 end)local dg=MakeButton(getAPEnableName,getAPDisableName,600,60,at/2-600/2,au/2-60/2-400,function()return Autopilot end,ToggleAutopilot)MakeButton("Save Position","Save Position",200,dg.height,dg.x+dg.width+30,dg.y,function()return false end,AddNewLocation,function()return AutopilotTargetIndex==0 or CustomTarget==nil end)MakeButton("Update Position","Update Position",200,dg.height,dg.x+dg.width+30,dg.y,function()return false end,UpdatePosition,function()return AutopilotTargetIndex>0 and CustomTarget~=nil end)MakeButton("Clear Position","Clear Position",200,dg.height,dg.x-200-30,dg.y,function()return true end,ClearCurrentPosition,function()return AutopilotTargetIndex>0 and CustomTarget~=nil end)dd=60;de=300;local bC=10;local bD=au/2-300;MakeButton("Enable Turn and Burn","Disable Turn and Burn",de,dd,bC,bD,function()return TurnBurn end,ToggleTurnBurn)MakeButton("Engage Altitude Hold","Disable Altitude Hold",de,dd,bC+de+20,bD,function()return AltitudeHold end,ToggleAltitudeHold)bD=bD+dd+20;MakeButton("Engage Autoland","Disable Autoland",de,dd,bC,bD,function()return AutoLanding end,ToggleAutoLanding)MakeButton("Engage Auto Takeoff","Disable Auto Takeoff",de,dd,bC+de+20,bD,function()return AutoTakeoff end,ToggleAutoTakeoff)bD=bD+dd+20;MakeButton("Show Orbit Display","Hide Orbit Display",de,dd,bC,bD,function()return DisplayOrbit end,function()DisplayOrbit=not DisplayOrbit;if DisplayOrbit then K="Orbit Display Enabled"else K="Orbit Display Disabled"end end)bD=bD+dd+20;MakeButton("Glide Re-Entry","Cancel Glide Re-Entry",de,dd,bC,bD,function()return Reentry end,function()x=true;BeginReentry()end,function()return ae>ReentryAltitude end)MakeButton("Parachute Re-Entry","Cancel Parachute Re-Entry",de,dd,bC+de+20,bD,function()return Reentry end,BeginReentry,function()return ae>ReentryAltitude end)bD=bD+dd+20;MakeButton("Engage Follow Mode","Disable Follow Mode",de,dd,bC,bD,function()return I end,ToggleFollowMode,function()return o()==1 end)MakeButton("Enable Repair Arrows","Disable Repair Arrows",de,dd,bC+de+20,bD,function()return aH end,function()aH=not aH;if aH then K="Repair Arrows Enabled"else K="Repair Arrows Diabled"end end,function()return o()==1 end)bD=bD+dd+20;if not ExternalAGG then MakeButton("Enable AGG","Disable AGG",de,dd,bC,bD,function()return antigrav.getState()==1 end,ToggleAntigrav,function()return antigrav~=nil end)end;bD=bD+dd+20;MakeButton(function()return e("Toggle Control Scheme - Current: %s",userControlScheme)end,function()return e("Control Scheme: %s",userControlScheme)end,de*2,dd,bC,bD,function()return false end,function()if userControlScheme=="keyboard"then userControlScheme="mouse"elseif userControlScheme=="mouse"then userControlScheme="virtual joystick"else userControlScheme="keyboard"end end)end;function GetFlightStyle()local dh=Nav.axisCommandManager:getAxisCommandType(0)local di="TRAVEL"if dh==1 then di="CRUISE"end;if Autopilot then di="AUTOPILOT"end;return di end;function UpdateHud(c7)local bR=ae;local b5=core.getVelocity()local bw=vec3(b5):len()local cc=vec3(core.getWorldVertical())local ca=vec3(core.getConstructWorldOrientationForward())local cb=vec3(core.getConstructWorldOrientationRight())local dj=vec3(core.getConstructWorldOrientationUp())local dk=getRoll(cc,ca,cb)local dl=dk/180*math.pi;local dm=math.cos(dl)local dn=math.sin(dl)local cd=getPitch(cc,ca,cb*dm+dj*dn)local dp=dk;local dq=cd;local dr=j()local ds=d(unit.getThrottle())local dt=bw*3.6;local du=unit.getAxisCommandValue(0)local di=GetFlightStyle()local dv="ROLL"local dw=unit.getClosestPlanetInfluence()>0;if ds==nil then ds=0 end;if not dw then if bw>5 then cd=getRelativePitch(b5)dk=getRelativeYaw(b5)else cd=0;dk=0 end;dv="YAW"end;c7[#c7+1]=a5;c7[#c7+1]=ao;c7[#c7+1]=a4;if aR%aK==0 then aP=true end;if fuelX~=0 and fuelY~=0 then DrawTank(c7,aP,fuelX,"Atmospheric ","ATMO",aD,aN,aO)DrawTank(c7,aP,fuelX+100,"Space fuel t","SPACE",aE,aL,aM)DrawTank(c7,aP,fuelX+200,"Rocket fuel ","ROCKET",aF,aI,aJ)end;if aP then aP=false;aR=0 end;aR=aR+1;DrawVerticalSpeed(c7,bR)if o()==0 or RemoteHud then if not IsInFreeLook()or brightHud then if dw then DrawRollLines(c7,centerX,centerY,dp,dv,dw)DrawArtificialHorizon(c7,dq,dp,centerX,centerY,dw,d(getRelativeYaw(b5)),bw)else DrawRollLines(c7,centerX,centerY,dk,dv,dw)DrawArtificialHorizon(c7,cd,dk,centerX,centerY,dw,d(dk),bw)end;DrawAltitudeDisplay(c7,bR,dw)DrawPrograde(c7,b5,bw,centerX,centerY)end end;DrawThrottle(c7,di,ds,du)DrawSpeed(c7,dt)DrawWarnings(c7)DisplayOrbitScreen(c7)if screen_2 then local bV=vec3(core.getConstructWorldPos())local bC=960+bV.x/aU;local bD=450+bV.y/aV;screen_2.moveContent(aW,(bC-80)/19.2,(bD-80)/10.8)end end;function IsInFreeLook()return system.isViewLocked()==0 and userControlScheme~="keyboard"and o()==0 end;function HUDPrologue(c7)local dx=aj;local dy=ak;local dz=aj;local dA=ak;if IsInFreeLook()and not brightHud then dx=[[rgb(]]..d(PrimaryR*0.4+0.5)..","..d(PrimaryG*0.4+0.5)..","..d(PrimaryB*0.3+0.5)..[[)]]dy=[[rgb(]]..d(PrimaryR*0.3+0.5)..","..d(PrimaryG*0.3+0.5)..","..d(PrimaryB*0.2+0.5)..[[)]]end;c7[#c7+1]=e([[
<head>
<style>
body {margin: 0}
svg {position:absolute;top:0;left:0;font-family:Montserrat;}
.txt {font-size:10px;font-weight:bold;}
.txttick {font-size:12px;font-weight:bold;}
.txtbig {font-size:14px;font-weight:bold;}
.altsm {font-size:16px;font-weight:normal;}
.altbig {font-size:21px;font-weight:normal;}
.line {stroke-width:2px;fill:none}
.linethick {stroke-width:3px;fill:none}
.warnings {font-size:26px;fill:red;text-anchor:middle;font-family:Bank}
.warn {fill:orange;font-size:24px}
.crit {fill:darkred;font-size:28px}
.bright {fill:%s;stroke:%s}
.pbright {fill:%s;stroke:%s}
.dim {fill:%s;stroke:%s}
.pdim {fill:%s;stroke:%s}
.red {fill:red;stroke:red}
.redout {fill:none;stroke:red}
.op30 {opacity:0.3}
.op10 {opacity:0.1}
.txtstart {text-anchor:start}
.txtend {text-anchor:end}
.txtmid {text-anchor:middle}
.txtvspd {font-family:sans-serif;font-weight:normal}
.txtvspdval {font-size:20px}
.txtfuel {font-size:11px;font-weight:bold}
.txtorb {font-size:12px}
.txtorbbig {font-size:18px}
.hudver {font-size:10px;font-weight:bold;fill:red;text-anchor:end;font-family:Bank}
.msg {font-size:40px;fill:red;text-anchor:middle;font-weight:normal}
.cursor {stroke:white}
</style>
</head>
<body>
<svg height="100%%" width="100%%" viewBox="0 0 %d %d">
]],dx,dx,dz,dz,dy,dy,dA,dA,ResolutionX,ResolutionY)end;function HUDEpilogue(c7)c7[#c7+1]="</svg>"end;function DrawSpeed(c7,dt)local dB=throtPosY-10;local dC=throtPosX+10;c7[#c7+1]=[[<g class="pdim txt txtend">]]if o()==1 and not RemoteHud then dB=75 end;c7[#c7+1]=e([[
<g class="pbright txtstart">
<text class="txtbig" x="%d" y="%d">%d km/h</text>
</g>
</g>]],dC,dB,d(dt))end;function DrawOdometer(c7,W,TotalDistanceTravelled,di,X,dr)local dD=ConvertResolutionX(1240)local dE=ConvertResolutionY(55)local dF=dE+10;local dr=j()local bt=core.g()local dG=0;local dH=0;local dI=0;RefreshLastMaxBrake(bt)if ad then dI=LastMaxBrakeInAtmo else dI=LastMaxBrake end;maxThrust=Nav:maxForceForward()aB=n()if not ShowOdometer then return end;local dJ=vec3(core.getWorldAcceleration()):len()/9.80665;if bt>0.1 then dH=aB*bt;dG=maxThrust/bt end;c7[#c7+1]=[[<g class="pdim txt txtend">]]if o()==1 and not RemoteHud then dD=ConvertResolutionX(1120)dE=ConvertResolutionY(55)dF=dE+10 elseif ad then local dK=ConvertResolutionX(770)c7[#c7+1]=e([[
<text x="%d" y="%d">ATMOSPHERE</text>
<text x="%d" y="%d">%.2f</text>
]],dK,dE,dK,dF,dr)end;c7[#c7+1]=e([[
<g class="pbright txtend">
</g>
<text x="%d" y="%d">GRAVITY</text>
<text x="%d" y="%d">%.2f g</text>
<text x="%d" y="%d">ACCEL</text>
<text x="%d" y="%d">%.2f g</text>
]],dD,dE,dD,dF,bt/9.80665,dD,dE+20,dD,dF+20,dJ)c7[#c7+1]=e([[
<g class="pbright txt">
<path class="linethick" d="M %d 0 L %d %d Q %d %d %d %d L %d 0"/>]],ConvertResolutionX(660),ConvertResolutionX(700),ConvertResolutionY(35),ConvertResolutionX(960),ConvertResolutionY(55),ConvertResolutionX(1240),ConvertResolutionY(35),ConvertResolutionX(1280))if o()==0 or RemoteHud then c7[#c7+1]=e([[
<text class="txtstart" x="%d" y="%d" >Trip: %.2f km</text>
<text class="txtstart" x="%d" y="%d">Lifetime: %.2f Mm</text>
<text class="txtstart" x="%d" y="%d">Trip Time: %s</text>
<text class="txtstart" x="%d" y="%d">Total Time: %s</text>
<text class="txtstart" x="%d" y="%d">Mass: %.2f Tons</text>
<text class="txtend" x="%d" y="%d">Max Brake: %.2f kN</text>
<text class="txtend" x="%d" y="%d">Max Thrust: %.2f kN</text>
<text class="txtbig txtmid" x="%d" y="%d">%s</text>]],ConvertResolutionX(700),ConvertResolutionY(20),W,ConvertResolutionX(700),ConvertResolutionY(30),TotalDistanceTravelled/1000,ConvertResolutionX(830),ConvertResolutionY(20),FormatTimeString(X),ConvertResolutionX(830),ConvertResolutionY(30),FormatTimeString(TotalFlightTime),ConvertResolutionX(970),ConvertResolutionY(20),aB/1000,ConvertResolutionX(1240),ConvertResolutionY(10),dI/1000,ConvertResolutionX(1240),ConvertResolutionY(30),maxThrust/1000,ConvertResolutionX(960),ConvertResolutionY(180),di)if bt>0.1 then c7[#c7+1]=e([[
<text class="txtstart" x="%d" y="%d">Max Mass: %.2f Tons</text>
<text class="txtend" x="%d" y="%d">Req Thrust: %.2f kN</text>
]],ConvertResolutionX(970),ConvertResolutionY(30),dG/1000,ConvertResolutionX(1240),ConvertResolutionY(20),dH/1000)else c7[#c7+1]=e([[
<text class="txtstart" x="%d" y="%d" text-anchor="start">Max Mass: n/a</text>
<text class="txtend" x="%d" y="%d" text-anchor="end">Req Thrust: n/a</text>
]],ConvertResolutionX(970),ConvertResolutionY(30),ConvertResolutionX(1240),ConvertResolutionY(20))end else c7[#c7+1]=e([[<text class="txtbig txtmid" x="960" y="33">%s</text>]],ConvertResolutionX(960),ConvertResolutionY(33),di)end;c7[#c7+1]="</g>"end;function DrawThrottle(c7,di,ds,du)local cV=throtPosY+10;local cW=throtPosY+20;if o()==1 and not RemoteHud then cV=55;cW=65 end;local dL="CRUISE"local unit="km/h"local dM=du;if di=="TRAVEL"or di=="AUTOPILOT"then dL="THROT"unit="%"dM=ds;local dN="dim"if ds<0 then dN="red"end;c7[#c7+1]=e([[<g class="%s">
<path class="linethick" d="M %d %d L %d %d L %d %d L %d %d"/>
<g transform="translate(0 %d)">
<polygon points="%d,%d %d,%d %d,%d"/>
</g>]],dN,throtPosX-7,throtPosY-50,throtPosX,throtPosY-50,throtPosX,throtPosY+50,throtPosX-7,throtPosY+50,1-math.abs(ds),throtPosX-10,throtPosY+50,throtPosX-15,throtPosY+53,throtPosX-15,throtPosY+47)end;c7[#c7+1]=e([[
<g class="pbright txtstart">
<text x="%d" y="%d">%s</text>
<text x="%d" y="%d">%d %s</text>
</g>
</g>]],throtPosX+10,cV,dL,throtPosX+10,cW,dM,unit)end;function DrawVerticalSpeed(c7,bR)if bR<200000 and not ad or bR and ad then local dO=-vec3(core.getWorldVertical()):dot(vec3(core.getWorldVelocity()))local dP=0;if math.abs(dO)>1 then dP=45*math.log(math.abs(dO),10)if dO<0 then dP=-dP end end;c7[#c7+1]=e([[
<g class="pbright txt txtvspd" transform="translate(%d %d) scale(0.6)">
<text x="31" y="-41">1000</text>
<text x="-10" y="-65">100</text>
<text x="-54" y="-45">10</text>
<text x="-73" y="3">O</text>
<text x="-56" y="52">-10</text>
<text x="-14" y="72">-100</text>
<text x="29" y="50">-1000</text>
<text x="85" y="0" class="txtvspdval txtend">%d m/s</text>
<g class="linethick">
<path d="m-41 75 2.5-4.4m17 12 1.2-4.9m20 7.5v-10m-75-34 4.4-2.5m-12-17 4.9-1.2m17 40 7-7m-32-53h10m34-75 2.5 4.4m17-12 1.2 4.9m20-7.5v10m-75 34 4.4 2.5m-12 17 4.9 1.2m17-40 7 7m-32 53h10m116 75-2.5-4.4m-17 12-1.2-4.9m40-17-7-7m-12-128-2.5 4.4m-17-12-1.2 4.9m40 17-7 7"/>
<circle r="90" />
</g>
<path transform="rotate(%d)" d="m-0.094-7c-22 2.2-45 4.8-67 7 23 1.7 45 5.6 67 7 4.4-0.068 7.8-4.9 6.3-9.1-0.86-2.9-3.7-5-6.8-4.9z" />
</g>
]],vSpdMeterX,vSpdMeterY,d(dO),d(dP))end end;function getHeading(cr)local dQ=-vec3(core.getWorldVertical())cr=cr-cr:project_on(dQ)local dR=vec3(0,0,1)dR=dR-dR:project_on(dQ)local dS=dR:cross(dQ)local dP=dR:angle_between(cr)*constants.rad2deg;if cr:dot(dS)<0 then dP=360-dP end;return dP end;function DrawRollLines(c7,centerX,centerY,dp,dv,dw)local dT=circleRad;local dU=20;dU=d(dU)local dV=d(dp)if dw then for i=-45,45,5 do local dW=i;c7[#c7+1]=e([[<g transform="rotate(%f,%d,%d)">]],dW,centerX,centerY)len=5;if i%15==0 then len=15 elseif i%10==0 then len=10 end;c7[#c7+1]=e([[<line x1=%d y1=%d x2=%d y2="%d"/></g>]],centerX,centerY+dT+dU-len,centerX,centerY+dT+dU)end;c7[#c7+1]=e([["
<g class="pdim txt txtmid">
<text x="%d" y="%d">%s</text>
<text x="%d" y="%d">%d deg</text>
</g>
]],centerX,centerY+dT+dU-35,dv,centerX,centerY+dT+dU-25,dV)c7[#c7+1]=e([[<g transform="rotate(%f,%d,%d)">]],-dp,centerX,centerY)c7[#c7+1]=e([[<<polygon points="%d,%d %d,%d %d,%d"/>]],centerX-5,centerY+dT+dU-20,centerX+5,centerY+dT+dU-20,centerX,centerY+dT+dU-15)c7[#c7+1]="</g>"end;local d3=dV;if dw then d3=getHeading(vec3(core.getConstructWorldOrientationForward()))end;local dX=20;local dY=d(d3)local dZ=0;local d_=centerY+dT+dU+20;local e0=centerX;if dv~="YAW"then d_=ConvertResolutionY(130)e0=ConvertResolutionX(960)end;local e1=[[<path class="txttick line" d="]]for i=d(dY-(dX+10)-dY%5+0.5),d(dY+dX+10+dY%5+0.5),5 do local bC=e0+-i*5+d3*5;if i%10==0 then dZ=10;local p=i;if p==360 then p=0 elseif p>360 then p=p-360 elseif p<0 then p=p+360 end;c7[#c7+1]=e([[
<text x="%f" y="%f">%d</text>]],bC+5,d_-12,p)elseif i%5==0 then dZ=5 end;if dZ==10 then e1=e([[%s M %f %f v %d]],e1,bC,d_-5,dZ)else e1=e([[%s M %f %f v %d]],e1,bC,d_-2.5,dZ)end end;c7[#c7+1]=e1 ..[["/>]]c7[#c7+1]=e([[<<polygon points="%d,%d %d,%d %d,%d"/>]],e0-5,d_+10,e0+5,d_+10,e0,d_+5)if dw then dv="HDG"end;c7[#c7+1]=e([["
<g class="pdim txt txtmid">
<text x="%d" y="%d">%d deg</text>
<text x="%d" y="%d">%s</text>
</g>
]],e0,d_+25,dY,e0,d_+35,dv)end;function DrawArtificialHorizon(c7,dq,dp,centerX,centerY,dw,e2,bw)local dT=circleRad;local e3=d(dT*3/5)if dT>0 then local e4=d(dq)local len=0;local e1=e([[<path transform="rotate(%f,%d,%d)" class="dim line" d="]],-1*dp,centerX,centerY)if not ad then e1=e([[<path transform="rotate(0,%d,%d)" class="dim line" d="]],centerX,centerY)end;c7[#c7+1]=e([[<clipPath id="cut"><circle r="%f" cx="%d" cy="%d"/></clipPath>]],dT-1,centerX,centerY)c7[#c7+1]=[[<g class="dim txttick" clip-path="url(#cut)">]]for i=d(e4-30-e4%5+0.5),d(e4+30+e4%5+0.5),5 do if i%10==0 then len=30 elseif i%5==0 then len=20 end;local bD=centerY+-i*5+dq*5;if len==30 then e1=e([[%s M %d %f h %d]],e1,centerX-e3-len,bD,len)if ad then c7[#c7+1]=e([[<g path transform="rotate(%f,%d,%d)" class="pdim txt txtmid"><text x="%d" y="%f">%d</text></g>]],-1*dp,centerX,centerY,centerX-e3+10,bD,i)c7[#c7+1]=e([[<g path transform="rotate(%f,%d,%d)" class="pdim txt txtmid"><text x="%d" y="%f">%d</text></g>]],-1*dp,centerX,centerY,centerX+e3-10,bD,i)if i==0 or i==180 or i==-180 then c7[#c7+1]=e([[<path transform="rotate(%f,%d,%d)" d="m %d,%f %d,0" stroke-width="1" style="fill:none;stroke:#F5B800;" />]],-1*dp,centerX,centerY,centerX-e3+20,bD,e3*2-40)end else c7[#c7+1]=e([[<g class="pdim txt txtmid"><text x="%d" y="%f">%d</text></g>]],centerX-e3+10,bD,i)c7[#c7+1]=e([[<g class="pdim txt txtmid"><text x="%d" y="%f">%d</text></g>]],centerX+e3-10,bD,i)end;e1=e([[%s M %d %f h %d]],e1,centerX+e3,bD,len)else e1=e([[%s M %d %f h %d]],e1,centerX-e3-len,bD,len)e1=e([[%s M %d %f h %d]],e1,centerX+e3,bD,len)end end;c7[#c7+1]=e1 ..[["/>]]local e5="PITCH"if not dw then e5="REL PITCH"end;if dq>90 and not ad then dq=90-(dq-90)elseif dq<-90 and not ad then dq=-90-(dq+90)end;if dT>200 then if ad then if bw>w then c7[#c7+1]=e([["
<g class="pdim txt txtmid">
<text x="%d" y="%d">%s</text>
<text x="%d" y="%d">%d deg</text>
</g>
]],centerX,centerY-15,"Yaw",centerX,centerY+20,e2)end;c7[#c7+1]=e([[<g transform="rotate(%f,%d,%d)">]],-dp,centerX,centerY)else c7[#c7+1]=e([[<g transform="rotate(0,%d,%d)">]],centerX,centerY)end;c7[#c7+1]=e([[<<polygon points="%d,%d %d,%d %d,%d"/> class="pdim txtend"><text x="%d" y="%f">%d</text>]],centerX-e3+25,centerY-5,centerX-e3+20,centerY,centerX-e3+25,centerY+5,centerX-e3+50,centerY+4,e4)c7[#c7+1]=e([[<<polygon points="%d,%d %d,%d %d,%d"/> class="pdim txtend"><text x="%d" y="%f">%d</text>]],centerX+e3-25,centerY-5,centerX+e3-20,centerY,centerX+e3-25,centerY+5,centerX+e3-30,centerY+4,e4)c7[#c7+1]="</g>"end;local e6=d(dT/3)c7[#c7+1]=e([[<path d="m %d,%d %d,0" stroke-width="2" style="fill:none;stroke:#F5B800;" />]],centerX-e6,centerY,dT-e6)if not ad and dw then c7[#c7+1]=e([[<path transform="rotate(%f,%d,%d)" d="m %d,%f %d,0" stroke-width="1" style="fill:none;stroke:#F5B800;" />]],-1*dp,centerX,centerY,centerX-e3+10,centerY,e3*2-20)end;c7[#c7+1]="</g>"if dT<200 then if ad and bw>w then c7[#c7+1]=e([["
<g class="pdim txt txtmid">
<text x="%d" y="%d">%s</text>
<text x="%d" y="%d">%d deg</text>
<text x="%d" y="%d">%s</text>
<text x="%d" y="%d">%d deg</text>
</g>
]],centerX,centerY-dT,e5,centerX,centerY-dT+10,e4,centerX,centerY-15,"Yaw",centerX,centerY+20,e2)else c7[#c7+1]=e([["
<g class="pdim txt txtmid">
<text x="%d" y="%d">%s</text>
<text x="%d" y="%d">%d deg</text>
</g>
]],centerX,centerY-dT,e5,centerX,centerY-dT+15,e4)end end end end;function DrawAltitudeDisplay(c7,bR,dw)local e7=altMeterX;local e8=altMeterY;local e9=78;local ea=19;local eb=AboveGroundLevel()if eb~=-1 then table.insert(c7,e([[
<g class="pdim altsm txtend">
<text x="%d" y="%d">AGL: %.1fm</text>
</g>
]],e7+e9,e8+ea+20,eb))end;if dw and(bR<200000 and not ad or bR and ad)then table.insert(c7,e([[
<g class="pdim">
<rect class="line" x="%d" y="%d" width="%d" height="%d"/>
<clipPath id="alt"><rect class="line" x="%d" y="%d" width="%d" height="%d"/></clipPath>
<g clip-path="url(#alt)">]],e7-1,e8-4,e9+2,ea+6,e7+1,e8-1,e9-4,ea))local c5=0;local ec=1;local ed=0;local ee=bR<0;local ef=9;if ee then ef=0 end;local bR=math.abs(bR)while c5<6 do local eg=11;local eh=16;local ei=9;local ej=14;local d2="altsm"if c5>2 then eh=eh+3;eg=eg+2;ej=ej+2;ei=ei-6;d2="altbig"end;if ee then d2=d2 .." red"end;local ek=bR/ec%10;local el=d(ek)local em=d((el+1)%10)local en=ed;if c5==0 then en=ek-el;if ee then en=1-en end end;if ee and(c5==0 or ed~=0)then local eo=em;em=el;el=eo end;local ep=eh*(en-1)local eq=ep+eh;local bC=e7+ei+(6-c5)*eg;local bD=e8+ej;table.insert(c7,e([[
<g class="%s">
<text x="%d" y="%f">%d</text>
<text x="%d" y="%f">%d</text>
</g>
]],d2,bC,bD+ep,em,bC,bD+eq,el))c5=c5+1;ec=ec*10;if el==ef then ed=en else ed=0 end end;table.insert(c7,[[</g></g>]])end end;function DrawPrograde(c7,b5,bw,centerX,centerY)if bw>5 and not ad or bw>w then local dT=circleRad;local er=20;local es=20;local et=vec3(b5)local eu=getRelativePitch(et)local ev=getRelativeYaw(et)local ew=14;local ex=ew/2;local ey=-ev/es*dT;local ez=eu/er*dT;local bC=centerX+ey;local bD=centerY+ez;local a3=math.sqrt(ey^2+ez^2)local eA=[[<circle
cx="]]..bC..[["
cy="]]..bD..[["
r="]]..ex/ew..[["
style="fill:#d7fe00;stroke:none;fill-opacity:1"/>
<circle
cx="]]..bC..[["
cy="]]..bD..[["
r="]]..ex..[["
style="stroke:#d7fe00;stroke-opacity:1;fill:none" />
<path
d="M ]]..bC-ew..[[,]]..bD..[[ h ]]..ex..[["
style="stroke:#d7fe00;stroke-opacity:1" />
<path
d="M ]]..bC+ex..[[,]]..bD..[[ h ]]..ex..[["
style="stroke:#d7fe00;stroke-opacity:1" />
<path
d="M ]]..bC..[[,]]..bD-ew..[[ v ]]..ex..[["
style="stroke:#d7fe00;stroke-opacity:1" />]]if a3<dT then c7[#c7+1]=eA else local dP=math.atan(ez,ey)local eB=4;local eC=centerX+dT*math.cos(dP)local eD=centerY+dT*math.sin(dP)c7[#c7+1]=e('<g transform="rotate(%f %f %f)"><rect x="%f" y="%f" width="%f" height="%f" stroke="#d7fe00" fill="#d7fe00" /><path d="M %f %f l %f %f l %f %f z" fill="#d7fe00" stroke="#d7fe00"></g>',dP*180/math.pi,eC,eD,eC-eB,eD-eB/2,eB*2,eB,eC+eB,eD-eB,eB,eB,-eB,eB)end;if not ad then eu=getRelativePitch(-et)ev=getRelativeYaw(-et)ey=-ev/es*dT;ez=eu/er*dT;bC=centerX+ey;bD=centerY+ez;a3=math.sqrt(ey^2+ez^2)if a3<dT then local eE=[[<circle
cx="]]..bC..[["
cy="]]..bD..[["
r="]]..ex..[["
style="stroke:#d7fe00;stroke-opacity:1;fill:none" />
<path
d="M ]]..bC..[[,]]..bD-ew..[[ v ]]..ex..[["
style="stroke:#d7fe00;stroke-opacity:1" id="l"/>
<use
xlink:href="#l"
transform="rotate(120,]]..bC..[[,]]..bD..[[)" />
<use
xlink:href="#l"
transform="rotate(-120,]]..bC..[[,]]..bD..[[)" />
<path
d="M ]]..bC-ex..[[,]]..bD..[[ h ]]..ew..[["
style="stroke-width:0.5;stroke:#d7fe00;stroke-opacity:1"
transform="rotate(-45,]]..bC..[[,]]..bD..[[)" id="c"/>
<use
xlink:href="#c"
transform="rotate(-90,]]..bC..[[,]]..bD..[[)"/>]]c7[#c7+1]=eE end end end end;function DrawWarnings(c7)c7[#c7+1]=e([[<text class="hudver" x="%d" y="%d">DU Hud Version: %.3f</text>]],ConvertResolutionX(1900),ConvertResolutionY(1070),VERSION_NUMBER)c7[#c7+1]=[[<g class="warnings">]]if unit.isMouseControlActivated()==1 then c7[#c7+1]=e([[
<text x="%d" y="%d">Warning: Invalid Control Scheme Detected</text>]],ConvertResolutionX(960),ConvertResolutionY(550))c7[#c7+1]=e([[
<text x="%d" y="%d">Keyboard Scheme must be selected</text>]],ConvertResolutionX(960),ConvertResolutionY(600))c7[#c7+1]=e([[
<text x="%d" y="%d">Set your preferred scheme in Lua Parameters instead</text>]],ConvertResolutionX(960),ConvertResolutionY(650))end;local eF=ConvertResolutionX(960)local eG=ConvertResolutionY(860)local eH=ConvertResolutionY(880)local eI=ConvertResolutionY(900)local eJ=ConvertResolutionY(960)local eK=ConvertResolutionY(200)local eL=ConvertResolutionY(150)local eM=ConvertResolutionY(960)if o()==1 and not RemoteHud then eG=ConvertResolutionY(135)eH=ConvertResolutionY(155)eI=ConvertResolutionY(175)eK=ConvertResolutionY(115)eL=ConvertResolutionY(95)end;if BrakeIsOn then c7[#c7+1]=e([[<text x="%d" y="%d">Brake Engaged</text>]],eF,eG)end;if ad and bb and hoverDetectGround()==-1 then c7[#c7+1]=e([[<text x="%d" y="%d">** STALL WARNING **</text>]],eF,eK+50)end;if ah then c7[#c7+1]=e([[<text x="%d" y="%d">Gyro Enabled</text>]],eF,eM)end;if GearExtended then if A then c7[#c7+1]=e([[<text class="warn" x="%d" y="%d">Gear Extended</text>]],eF,eH)else c7[#c7+1]=e([[<text x="%d" y="%d">Landed (G: Takeoff)</text>]],eF,eH)end;local db,dc=getDistanceDisplayString(Nav:getTargetGroundAltitude())c7[#c7+1]=e([[<text class="warn" x="%d" y="%d">Hover Height: %s</text>]],eF,eI,db..dc)end;if O then c7[#c7+1]=e([[<text class="warn" x="%d" y="%d">ROCKET BOOST ENABLED</text>]],eF,eJ+20)end;if antigrav and not ExternalAGG and antigrav.getState()==1 and AntigravTargetAltitude~=nil then if math.abs(ae-antigrav.getBaseAltitude())<501 then c7[#c7+1]=e([[<text class="warn" x="%d" y="%d">AGG On - Target Altitude: %d Singluarity Altitude: %d</text>]],eF,eK+20,d(AntigravTargetAltitude),d(antigrav.getBaseAltitude()))else c7[#c7+1]=e([[<text x="%d" y="%d">AGG On - Target Altitude: %d Singluarity Altitude: %d</text>]],eF,eK+20,d(AntigravTargetAltitude),d(antigrav.getBaseAltitude()))end elseif Autopilot and AutopilotTargetName~="None"then c7[#c7+1]=e([[<text class="warn" x="%d" y="%d">Autopilot %s</text>]],eF,eK+20,AutopilotStatus)elseif LockPitch~=nil then c7[#c7+1]=e([[<text class="warn" x="%d" y="%d">LockedPitch: %d</text>]],eF,eK+20,d(LockPitch))elseif I then c7[#c7+1]=e([[<text class="warn" x="%d" y="%d">Follow Mode Engaged</text>]],eF,eK+20)elseif Reentry then c7[#c7+1]=e([[<text class="warn" x="%d" y="%d">Parachute Re-entry in Progress</text>]],eF,eK+20)end;if AltitudeHold then if AutoTakeoff then local db,dc=getDistanceDisplayString(HoldAltitude)c7[#c7+1]=e([[<text class="warn" x="%d" y="%d">Ascent to %s</text>]],eF,eK,db..dc)if BrakeIsOn then c7[#c7+1]=e([[<text class="crit" x="%d" y="%d">Throttle Up and Disengage Brake For Takeoff</text>]],eF,eK+50)end else local db,dc=getDistanceDisplayString2(HoldAltitude)c7[#c7+1]=e([[<text class="warn" x="%d" y="%d">Altitude Hold: %s</text>]],eF,eK,db..dc)end end;if BrakeLanding then if StrongBrakes then c7[#c7+1]=e([[<text x="%d" y="%d">Brake-Landing</text>]],eF,eK)else c7[#c7+1]=e([[<text x="%d" y="%d">Coast-Landing</text>]],eF,eK)end end;if ProgradeIsOn then c7[#c7+1]=e([[<text class="crit" x="%d" y="%d">Prograde Alignment</text>]],eF,eK)end;if RetrogradeIsOn then c7[#c7+1]=e([[<text class="crit" x="%d" y="%d">Retrograde Alignment</text>]],eF,eK)end;if TurnBurn then c7[#c7+1]=e([[<text class="crit" x="%d" y="%d">Turn & Burn Braking</text>]],eF,eL)end;if VectorToTarget then c7[#c7+1]=e([[<text class="warn" x="%d" y="%d">%s</text>]],eF,eK+30,VectorStatus)end;c7[#c7+1]="</g>"end;function DisplayOrbitScreen(c7)if orbit~=nil and j()<0.2 and planet~=nil and orbit.apoapsis~=nil and orbit.periapsis~=nil and orbit.period~=nil and orbit.apoapsis.speed>5 and DisplayOrbit then local eN=OrbitMapX;local eO=OrbitMapY;local eP=OrbitMapSize;local eQ=4;eO=eO+eQ;local eR=15;local bC=eN+eP+eN/2+eQ;local bD=eO+eP/2+5+eQ;local eS,eT,eU,eV;eS=eP/4;eV=0;c7[#c7+1]=[[<g class="pbright txtorb txtmid">]]c7[#c7+1]=e('<rect width="%f" height="%d" rx="10" ry="10" x="%d" y="%d" style="fill:rgb(0,0,100);stroke-width:4;stroke:white;fill-opacity:0.3;" />',eP+eN*2,eP+eO,eQ,eQ)if orbit.periapsis~=nil and orbit.apoapsis~=nil then eU=(orbit.apoapsis.altitude+orbit.periapsis.altitude+planet.radius*2)/(eS*2)eT=(planet.radius+orbit.periapsis.altitude+(orbit.apoapsis.altitude-orbit.periapsis.altitude)/2)/eU*(1-orbit.eccentricity)eV=eS-orbit.periapsis.altitude/eU-planet.radius/eU;local eW=""if orbit.periapsis.altitude<=0 then eW='redout'end;c7[#c7+1]=e([[<ellipse class="%s line" cx="%f" cy="%f" rx="%f" ry="%f"/>]],eW,eN+eP/2+eV+eQ,eO+eP/2+eQ,eS,eT)c7[#c7+1]=e('<circle cx="%f" cy="%f" r="%f" stroke="white" stroke-width="3" fill="blue" />',eN+eP/2+eQ,eO+eP/2+eQ,planet.radius/eU)end;if orbit.apoapsis~=nil and orbit.apoapsis.speed<MaxGameVelocity and orbit.apoapsis.speed>1 then c7[#c7+1]=e([[<line class="pdim op30 linethick" x1="%f" y1="%f" x2="%f" y2="%f"/>]],bC-35,bD-5,eN+eP/2+eS+eV,bD-5)c7[#c7+1]=e([[<text x="%f" y="%f">Apoapsis</text>]],bC,bD)bD=bD+eR;local db,dc=getDistanceDisplayString(orbit.apoapsis.altitude)c7[#c7+1]=e([[<text x="%f" y="%f">%s</text>]],bC,bD,db..dc)bD=bD+eR;c7[#c7+1]=e([[<text x="%f" y="%f">%s</text>]],bC,bD,FormatTimeString(orbit.timeToApoapsis))bD=bD+eR;c7[#c7+1]=e([[<text x="%f" y="%f">%s</text>]],bC,bD,getSpeedDisplayString(orbit.apoapsis.speed))end;bD=eO+eP/2+5+eQ;bC=eN-eN/2+10+eQ;if orbit.periapsis~=nil and orbit.periapsis.speed<MaxGameVelocity and orbit.periapsis.speed>1 then c7[#c7+1]=e([[<line class="pdim op30 linethick" x1="%f" y1="%f" x2="%f" y2="%f"/>]],bC+35,bD-5,eN+eP/2-eS+eV,bD-5)c7[#c7+1]=e([[<text x="%f" y="%f">Periapsis</text>]],bC,bD)bD=bD+eR;local db,dc=getDistanceDisplayString(orbit.periapsis.altitude)c7[#c7+1]=e([[<text x="%f" y="%f">%s</text>]],bC,bD,db..dc)bD=bD+eR;c7[#c7+1]=e([[<text x="%f" y="%f">%s</text>]],bC,bD,FormatTimeString(orbit.timeToPeriapsis))bD=bD+eR;c7[#c7+1]=e([[<text x="%f" y="%f">%s</text>]],bC,bD,getSpeedDisplayString(orbit.periapsis.speed))end;c7[#c7+1]=e([[<text class="txtorbbig" x="%f" y="%d">%s</text>]],eN+eP/2+eQ,20+eQ,planet.name)if orbit.period~=nil and orbit.periapsis~=nil and orbit.apoapsis~=nil and orbit.apoapsis.speed>1 then local eX=orbit.timeToApoapsis/orbit.period*2*math.pi;local eY=eS*math.cos(eX)local eZ=eT*math.sin(eX)c7[#c7+1]=e('<circle cx="%f" cy="%f" r="5" stroke="white" stroke-width="3" fill="white" />',eN+eP/2+eY+eV+eQ,eO+eP/2+eZ+eQ)end;c7[#c7+1]=[[</g>]]end end;function getDistanceDisplayString(a3)local e_=a3>100000;local bi,dc=""if e_ then bi,dc=round(a3/1000/200,1),"SU"elseif a3<1000 then bi,dc=round(a3,1),"m"else bi,dc=round(a3/1000,1),"Km"end;return bi,dc end;function getDistanceDisplayString2(a3)local e_=a3>100000;local bi,dc=""if e_ then bi,dc=round(a3/1000/200,2)," SU"elseif a3<1000 then bi,dc=round(a3,2)," M"else bi,dc=round(a3/1000,2)," KM"end;return bi,dc end;function getSpeedDisplayString(bw)return d(round(bw*3.6,0)+0.5).." km/h"end;function FormatTimeString(f0)local f1=0;local f2=0;local f3=0;if f0<60 then f0=d(f0)elseif f0<3600 then f1=d(f0/60)f0=d(f0%60)elseif f0<86400 then f2=d(f0/3600)f1=d(f0%3600/60)else f3=d(f0/86400)f2=d(f0%86400/3600)end;if f3>0 then return f3 .."d "..f2 .."h "elseif f2>0 then return f2 .."h "..f1 .."m "elseif f1>0 then return f1 .."m "..f0 .."s"elseif f0>0 then return f0 .."s"else return"0s"end end;function getMagnitudeInDirection(d4,f4)d4=vec3(d4)f4=vec3(f4):normalize()local bi=d4*f4;return bi.x+bi.y+bi.z end;function UpdateAutopilotTarget()if AutopilotTargetIndex==0 then AutopilotTargetName="None"V=nil;return true end;local f5=AtlasOrdered[AutopilotTargetIndex].index;local f6=aS[0][f5]if f6.center then AutopilotTargetName=f6.name;V=aY[0][f5]if CustomTarget~=nil then if j()==0 then if system.updateData(widgetMaxBrakeTimeText,widgetMaxBrakeTime)~=1 then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;if system.updateData(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)~=1 then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;if system.updateData(widgetCurBrakeTimeText,widgetCurBrakeTime)~=1 then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;if system.updateData(widgetCurBrakeDistanceText,widgetCurBrakeDistance)~=1 then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;if system.updateData(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)~=1 then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end;if system.updateData(widgetTargetOrbitText,widgetTargetOrbit)~=1 then system.addDataToWidget(widgetTargetOrbitText,widgetTargetOrbit)end end;if system.updateData(widgetMaxMassText,widgetMaxMass)~=1 then system.addDataToWidget(widgetMaxMassText,widgetMaxMass)end;if system.updateData(widgetTravelTimeText,widgetTravelTime)~=1 then system.addDataToWidget(widgetTravelTimeText,widgetTravelTime)end end;CustomTarget=nil else CustomTarget=f6;for _,bh in pairs(aY[0])do if bh.name==CustomTarget.planetname then V=bh;AutopilotTargetName=CustomTarget.name;break end end;if system.updateData(widgetMaxMassText,widgetMaxMass)~=1 then system.addDataToWidget(widgetMaxMassText,widgetMaxMass)end;if system.updateData(widgetTravelTimeText,widgetTravelTime)~=1 then system.addDataToWidget(widgetTravelTimeText,widgetTravelTime)end end;if CustomTarget==nil then AutopilotTargetCoords=vec3(V.center)else AutopilotTargetCoords=CustomTarget.position end;if V.name~="Space"then if V.hasAtmosphere then AutopilotTargetOrbit=math.floor(V.radius*(TargetOrbitRadius-1)+V.noAtmosphericDensityAltitude)else AutopilotTargetOrbit=math.floor(V.radius*(TargetOrbitRadius-1)+V.surfaceMaxAltitude)end end;if CustomTarget~=nil and CustomTarget.planetname=="Space"then AutopilotEndSpeed=0 else _,AutopilotEndSpeed=b0(V):escapeAndOrbitalSpeed(AutopilotTargetOrbit)end;AutopilotPlanetGravity=0;AutopilotAccelerating=false;AutopilotBraking=false;AutopilotCruising=false;Autopilot=false;AutopilotRealigned=false;AutopilotStatus="Aligning"return true end;function IncrementAutopilotTargetIndex()AutopilotTargetIndex=AutopilotTargetIndex+1;if AutopilotTargetIndex>#AtlasOrdered then AutopilotTargetIndex=0 end;UpdateAutopilotTarget()end;function DecrementAutopilotTargetIndex()AutopilotTargetIndex=AutopilotTargetIndex-1;if AutopilotTargetIndex<0 then AutopilotTargetIndex=#AtlasOrdered end;UpdateAutopilotTarget()end;function GetAutopilotMaxMass()local f7=LastMaxBrakeInAtmo/V:getGravity(V.center+vec3(0,0,1)*V.radius):len()return f7 end;function GetAutopilotTravelTime()if not Autopilot then if CustomTarget==nil or CustomTarget.planetname~=planet.name then AutopilotDistance=(V.center-vec3(core.getConstructWorldPos())):len()else AutopilotDistance=(CustomTarget.position-vec3(core.getConstructWorldPos())):len()end end;local b5=core.getWorldVelocity()local bw=vec3(b5):len()local f8,f9=aZ.computeDistanceAndTime(vec3(b5):len(),MaxGameVelocity,n(),Nav:maxForceForward(),warmup,0)local P,Q;if not TurnBurn then P,Q=GetAutopilotBrakeDistanceAndTime(MaxGameVelocity)else P,Q=GetAutopilotTBBrakeDistanceAndTime(MaxGameVelocity)end;local _,fa;if not TurnBurn then _,fa=GetAutopilotBrakeDistanceAndTime(bw)else _,fa=GetAutopilotTBBrakeDistanceAndTime(bw)end;local fb=0;local fc=0;if AutopilotCruising or not Autopilot and bw>5 then fc=aZ.computeTravelTime(bw,0,AutopilotDistance)elseif P+f8<AutopilotDistance then fb=AutopilotDistance-(P+f8)fc=aZ.computeTravelTime(8333.0556,0,fb)else local fd=(AutopilotDistance-P)/f8;f8=AutopilotDistance-P;f9=f9*fd end;if CustomTarget~=nil and CustomTarget.planetname==planet.name and not Autopilot then return fc elseif AutopilotBraking then return fa elseif AutopilotCruising then return fc+fa else return f9+Q+fc end end;function GetAutopilotBrakeDistanceAndTime(bw)if not ad then RefreshLastMaxBrake()return aZ.computeDistanceAndTime(bw,AutopilotEndSpeed,n(),0,0,LastMaxBrake-AutopilotPlanetGravity*n())else if LastMaxBrakeInAtmo and LastMaxBrakeInAtmo>0 then return aZ.computeDistanceAndTime(bw,AutopilotEndSpeed,n(),0,0,LastMaxBrakeInAtmo-AutopilotPlanetGravity*n())else return 0,0 end end end;function GetAutopilotTBBrakeDistanceAndTime(bw)RefreshLastMaxBrake()return aZ.computeDistanceAndTime(bw,AutopilotEndSpeed,n(),Nav:maxForceForward(),warmup,LastMaxBrake-AutopilotPlanetGravity*n())end;function hoverDetectGround()local fe=-1;local ff=-1;if vBooster then fe=vBooster.distance()end;if hover then ff=hover.distance()end;if fe~=-1 and ff~=-1 then if fe<ff then return fe else return ff end elseif fe~=-1 then return fe elseif ff~=-1 then return ff else return-1 end end;function AboveGroundLevel()local fg=-1;local fh=hoverDetectGround()if telemeter_1 then fg=telemeter_1.getDistance()end;if fh~=-1 and fg~=-1 then if fh<fg then return fh else return fg end elseif fh~=-1 then return fh else return fg end end;function tablelength(fi)local fj=0;for _ in pairs(fi)do fj=fj+1 end;return fj end;function BeginProfile(fk)ProfileTimeStart=system.getTime()end;function EndProfile(fk)local fl=system.getTime()-ProfileTimeStart;ProfileTimeSum=ProfileTimeSum+fl;ProfileCount=ProfileCount+1;if fl>ProfileTimeMax then ProfileTimeMax=fl end;if fl<ProfileTimeMin then ProfileTimeMin=fl end end;function ResetProfiles()ProfileTimeMin=9999;ProfileTimeMax=0;ProfileCount=0;ProfileTimeSum=0 end;function ReportProfiling()local fm=ProfileTimeSum;local fn=ProfileTimeSum/ProfileCount;local fo=ProfileTimeMin;local fp=ProfileTimeMax;local fq=ProfileCount;c(e("SUM: %.4f AVG: %.4f MIN: %.4f MAX: %.4f CNT: %d",fm,fn,fo,fp,fq))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 updateRadar()if radar_1 then local fr=radar_1.getEntries()local fs=radar_1.getData()local ft=ConvertResolutionX(1770)local fu=ConvertResolutionY(330)if#fr>0 then local fv=fs:find('identifiedConstructs":%[%]')if fv==nil and perisPanelID==nil then a6=1;ToggleRadarPanel()end;if fv~=nil and perisPanelID~=nil then ToggleRadarPanel()end;if radarPanelID==nil then ToggleRadarPanel()end;a4=e([[<text class="pbright txtbig txtmid" x="%d" y="%d">Radar: %i contacts</text>]],ft,fu,#fr)local fw={}for bg,bh in pairs(fr)do if radar_1.hasMatchingTransponder(bh)==1 then table.insert(fw,bh)end end;if#fw>0 then local bD=ConvertResolutionY(15)local bC=ConvertResolutionX(1370)a4=e([[%s<text class="pbright txtbig txtmid" x="%d" y="%d">Friendlies In Range</text>]],a4,bC,bD)for bg,bh in pairs(fw)do bD=bD+20;a4=e([[%s<text class="pdim txtmid" x="%d" y="%d">%s</text>]],a4,bC,bD,radar_1.getConstructName(bh))end end else local fx;fx=fs:find('worksInEnvironment":false')if fx then a4=e([[
<text class="pbright txtbig txtmid" x="%d" y="%d">Radar: Jammed</text>]],ft,fu)else a4=e([[
<text class="pbright txtbig txtmid" x="%d" y="%d">Radar: No Contacts</text>]],ft,fu)end;if radarPanelID~=nil then a6=0;ToggleRadarPanel()end end end end;function DisplayMessage(c7,db)if db~="empty"then c7[#c7+1]=[[<text class="msg" x="50%%" y="310" >]]for fy in string.gmatch(db,"([^\n]+)")do c7[#c7+1]=e([[<tspan x="50%%" dy="35">%s</tspan>]],fy)end;c7[#c7+1]=[[</text>]]end;if a2~=0 then unit.setTimer("msgTick",a2)a2=0 end end;function updateDistance()local bp=system.getTime()local b5=vec3(core.getWorldVelocity())local dt=vec3(b5):len()local fz=bp-ag;if dt>1.38889 then dt=dt/1000;local fA=dt*(bp-ag)TotalDistanceTravelled=TotalDistanceTravelled+fA;W=W+fA end;X=X+fz;TotalFlightTime=TotalFlightTime+fz;ag=bp end;function Atlas()return{[0]={[0]={GM=0,bodyId=0,center={x=0,y=0,z=0},name='Space',planetarySystemId=0,radius=0,hasAtmosphere=false,gravity=0},[2]={name="Alioth",description="Alioth is the planet selected by the arkship for landfall; it is a typical goldilocks planet where humanity may rebuild in the coming decades. The arkship geological survey reports mountainous regions alongside deep seas and lush forests. This is where it all starts.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9401,atmosphericEngineMaxAltitude=5580,biosphere="Forest",classification="Mesoplanet",bodyId=2,GM=157470826617,gravity=1.0082568597356114,fullAtmosphericDensityMaxAltitude=-10,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=6272,numSatellites=2,positionFromSun=2,center={x=-8,y=-8,z=-126303},radius=126067.8984375,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=3410,surfaceArea=199718780928,surfaceAverageAltitude=200,surfaceMaxAltitude=1100,surfaceMinAltitude=-330,systemZone="High",territories=259472,type="Planet",waterLevel=0,planetarySystemId=0},[21]={name="Alioth Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=21,GM=2118960000,gravity=0.24006116402380084,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=457933,y=-1509011,z=115524},radius=30000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=11309733888,surfaceAverageAltitude=140,surfaceMaxAltitude=200,surfaceMinAltitude=10,systemZone=nil,territories=14522,type="",waterLevel=nil,planetarySystemId=0},[22]={name="Alioth Moon 4",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=22,GM=2165833514,gravity=0.2427018259886451,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-1692694,y=729681,z=-411464},radius=30330,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=0,surfaceArea=11559916544,surfaceAverageAltitude=-15,surfaceMaxAltitude=-5,surfaceMinAltitude=-50,systemZone=nil,territories=14522,type="",waterLevel=nil,planetarySystemId=0},[5]={name="Feli",description="Feli is easily identified by its massive and deep crater. Outside of the crater, the arkship geological survey reports a fairly bland and uniform planet, it also cannot explain the existence of the crater. Feli is particular for having an extremely small atmosphere, allowing life to develop in the deeper areas of its crater but limiting it drastically on the actual surface.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.5488,atmosphericEngineMaxAltitude=66725,biosphere="Barren",classification="Mesoplanet",bodyId=5,GM=16951680000,gravity=0.4801223280476017,fullAtmosphericDensityMaxAltitude=30,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=78500,numSatellites=1,positionFromSun=5,center={x=-43534464,y=22565536,z=-48934464},radius=41800,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=42800,surfaceArea=21956466688,surfaceAverageAltitude=18300,surfaceMaxAltitude=18500,surfaceMinAltitude=46,systemZone="Low",territories=27002,type="Planet",waterLevel=nil,planetarySystemId=0},[50]={name="Feli Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=50,GM=499917600,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-43902841.78,y=22261034.7,z=-48862386},radius=14000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=800,surfaceMaxAltitude=900,surfaceMinAltitude=0,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[120]={name="Ion",description="Ion is nothing more than an oversized ice cube frozen through and through. It is a largely inhospitable planet due to its extremely low temperatures. The arkship geological survey reports extremely rough mountainous terrain with little habitable land.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9522,atmosphericEngineMaxAltitude=10480,biosphere="Ice",classification="Hypopsychroplanet",bodyId=120,GM=7135606629,gravity=0.36009174603570127,fullAtmosphericDensityMaxAltitude=-30,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=17700,numSatellites=2,positionFromSun=12,center={x=2865536.7,y=-99034464,z=-934462.02},radius=44950,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=6410,surfaceArea=25390383104,surfaceAverageAltitude=500,surfaceMaxAltitude=1300,surfaceMinAltitude=250,systemZone="Average",territories=32672,type="Planet",waterLevel=nil,planetarySystemId=0},[121]={name="Ion Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=121,GM=106830900,gravity=0.08802242599860607,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=2472916.8,y=-99133747,z=-1133582.8},radius=11000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=1520530944,surfaceAverageAltitude=100,surfaceMaxAltitude=200,surfaceMinAltitude=3,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[122]={name="Ion Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=122,GM=176580000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=2995424.5,y=-99275010,z=-1378480.7},radius=15000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=-1900,surfaceMaxAltitude=-1400,surfaceMinAltitude=-2100,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[9]={name="Jago",description="Jago is a water planet. The large majority of the planet's surface is covered by large oceans dotted by small areas of landmass across the planet. The arkship geological survey reports deep seas across the majority of the planet with sub 15 percent coverage of solid ground.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9835,atmosphericEngineMaxAltitude=9695,biosphere="Water",classification="Mesoplanet",bodyId=9,GM=18606274330,gravity=0.5041284298678057,fullAtmosphericDensityMaxAltitude=-90,habitability="Very High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=10900,numSatellites=0,positionFromSun=9,center={x=-94134462,y=12765534,z=-3634464},radius=61590,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=5900,surfaceArea=47668367360,surfaceAverageAltitude=0,surfaceMaxAltitude=1200,surfaceMinAltitude=-500,systemZone="Very High",territories=60752,type="Planet",waterLevel=0,planetarySystemId=0},[100]={name="Lacobus",description="Lacobus is an ice planet that also features large bodies of water. The arkship geological survey reports deep oceans alongside a frozen and rough mountainous environment. Lacobus seems to feature regional geothermal activity allowing for the presence of water on the surface.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.7571,atmosphericEngineMaxAltitude=11120,biosphere="Ice",classification="Psychroplanet",bodyId=100,GM=13975172474,gravity=0.45611622622739767,fullAtmosphericDensityMaxAltitude=-20,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=12510,numSatellites=3,positionFromSun=10,center={x=98865536,y=-13534464,z=-934461.99},radius=55650,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=6790,surfaceArea=38917074944,surfaceAverageAltitude=800,surfaceMaxAltitude=1660,surfaceMinAltitude=250,systemZone="Average",territories=50432,type="Planet",waterLevel=0,planetarySystemId=0},[102]={name="Lacobus Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=102,GM=444981600,gravity=0.14403669598391783,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=99180968,y=-13783862,z=-926156.4},radius=18000,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=0,surfaceArea=4071504128,surfaceAverageAltitude=150,surfaceMaxAltitude=300,surfaceMinAltitude=10,systemZone=nil,territories=5072,type="",waterLevel=nil,planetarySystemId=0},[103]={name="Lacobus Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=103,GM=211503600,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=99250052,y=-13629215,z=-1059341.4},radius=14000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=-1380,surfaceMaxAltitude=-1280,surfaceMinAltitude=-1880,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[101]={name="Lacobus Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=101,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=98905288.17,y=-13950921.1,z=-647589.53},radius=15000,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=500,surfaceMaxAltitude=820,surfaceMinAltitude=3,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[1]={name="Madis",description="Madis is a barren wasteland of a rock; it sits closest to the sun and temperatures reach extreme highs during the day. The arkship geological survey reports long rocky valleys intermittently separated by small ravines.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.8629,atmosphericEngineMaxAltitude=7165,biosphere="Barren",classification="hyperthermoplanet",bodyId=1,GM=6930729684,gravity=0.36009174603570127,fullAtmosphericDensityMaxAltitude=220,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=8050,numSatellites=3,positionFromSun=1,center={x=17465536,y=22665536,z=-34464},radius=44300,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=4480,surfaceArea=24661377024,surfaceAverageAltitude=750,surfaceMaxAltitude=850,surfaceMinAltitude=670,systemZone="Low",territories=30722,type="Planet",waterLevel=nil,planetarySystemId=0},[10]={name="Madis Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=10,GM=78480000,gravity=0.08002039003323584,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17448118.224,y=22966846.286,z=143078.82},radius=10000,safeAreaEdgeAltitude=500000,size="XL",spaceEngineMinAltitude=0,surfaceArea=1256637056,surfaceAverageAltitude=210,surfaceMaxAltitude=420,surfaceMinAltitude=0,systemZone=nil,territories=1472,type="",waterLevel=nil,planetarySystemId=0},[11]={name="Madis Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=11,GM=237402000,gravity=0.09602446196397631,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17194626,y=22243633.88,z=-214962.81},radius=12000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=1809557376,surfaceAverageAltitude=-700,surfaceMaxAltitude=300,surfaceMinAltitude=-2900,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[12]={name="Madis Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=12,GM=265046609,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=17520614,y=22184730,z=-309989.99},radius=15000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=700,surfaceMaxAltitude=1100,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[26]={name="Sanctuary",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9666,atmosphericEngineMaxAltitude=6935,biosphere="",classification="",bodyId=26,GM=68234043600,gravity=1.0000000427743831,fullAtmosphericDensityMaxAltitude=-30,habitability="",hasAtmosphere=true,isSanctuary=true,noAtmosphericDensityAltitude=7800,numSatellites=0,positionFromSun=0,center={x=-1404835,y=562655,z=-285074},radius=83400,safeAreaEdgeAltitude=0,size="L",spaceEngineMinAltitude=4230,surfaceArea=87406149632,surfaceAverageAltitude=80,surfaceMaxAltitude=500,surfaceMinAltitude=-60,systemZone=nil,territories=111632,type="",waterLevel=0,planetarySystemId=0},[6]={name="Sicari",description="Sicari is a typical desert planet; it has survived for millenniums and will continue to endure. While not the most habitable of environments it remains a relatively untouched and livable planet of the Alioth sector. The arkship geological survey reports large flatlands alongside steep plateaus.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.897,atmosphericEngineMaxAltitude=7725,biosphere="Desert",classification="Mesoplanet",bodyId=6,GM=10502547741,gravity=0.4081039739797361,fullAtmosphericDensityMaxAltitude=-625,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=8770,numSatellites=0,positionFromSun=6,center={x=52765536,y=27165538,z=52065535},radius=51100,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=4480,surfaceArea=32813432832,surfaceAverageAltitude=130,surfaceMaxAltitude=220,surfaceMinAltitude=50,systemZone="Average",territories=41072,type="Planet",waterLevel=nil,planetarySystemId=0},[7]={name="Sinnen",description="Sinnen is a an empty and rocky hell. With no atmosphere to speak of it is one of the least hospitable planets in the sector. The arkship geological survey reports mostly flatlands alongside deep ravines which look to have once been riverbeds. This planet simply looks to have dried up and died, likely from solar winds.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9226,atmosphericEngineMaxAltitude=10335,biosphere="Desert",classification="Mesoplanet",bodyId=7,GM=13033380591,gravity=0.4401121421448438,fullAtmosphericDensityMaxAltitude=-120,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=11620,numSatellites=1,positionFromSun=7,center={x=58665538,y=29665535,z=58165535},radius=54950,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=6270,surfaceArea=37944188928,surfaceAverageAltitude=317,surfaceMaxAltitude=360,surfaceMinAltitude=23,systemZone="Average",territories=48002,type="Planet",waterLevel=nil,planetarySystemId=0},[70]={name="Sinnen Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=70,GM=396912600,gravity=0.1360346539426409,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=58969616,y=29797945,z=57969449},radius=17000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=3631681280,surfaceAverageAltitude=-2050,surfaceMaxAltitude=-1950,surfaceMinAltitude=-2150,systemZone=nil,territories=4322,type="",waterLevel=nil,planetarySystemId=0},[110]={name="Symeon",description="Symeon is an ice planet mysteriously split at the equator by a band of solid desert. Exactly how this phenomenon is possible is unclear but some sort of weather anomaly may be responsible. The arkship geological survey reports a fairly diverse mix of flat-lands alongside mountainous formations.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.9559,atmosphericEngineMaxAltitude=6920,biosphere="Ice, Desert",classification="Hybrid",bodyId=110,GM=9204742375,gravity=0.3920998898971822,fullAtmosphericDensityMaxAltitude=-30,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=7800,numSatellites=0,positionFromSun=11,center={x=14165536,y=-85634465,z=-934464.3},radius=49050,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=4230,surfaceArea=30233462784,surfaceAverageAltitude=39,surfaceMaxAltitude=450,surfaceMinAltitude=126,systemZone="High",territories=38882,type="Planet",waterLevel=nil,planetarySystemId=0},[4]={name="Talemai",description="Talemai is a planet in the final stages of an Ice Age. It seems likely that the planet was thrown into tumult by a cataclysmic volcanic event which resulted in its current state. The arkship geological survey reports large mountainous regions across the entire planet.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.8776,atmosphericEngineMaxAltitude=9685,biosphere="Barren",classification="Psychroplanet",bodyId=4,GM=14893847582,gravity=0.4641182439650478,fullAtmosphericDensityMaxAltitude=-78,habitability="Average",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=10890,numSatellites=3,positionFromSun=4,center={x=-13234464,y=55765536,z=465536},radius=57500,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=5890,surfaceArea=41547563008,surfaceAverageAltitude=580,surfaceMaxAltitude=610,surfaceMinAltitude=520,systemZone="Average",territories=52922,type="Planet",waterLevel=nil,planetarySystemId=0},[42]={name="Talemai Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=42,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-13058408,y=55781856,z=740177.76},radius=15000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=720,surfaceMaxAltitude=850,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0},[40]={name="Talemai Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=40,GM=141264000,gravity=0.09602446196397631,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-13503090,y=55594325,z=769838.64},radius=12000,safeAreaEdgeAltitude=500000,size="S",spaceEngineMinAltitude=0,surfaceArea=1809557376,surfaceAverageAltitude=250,surfaceMaxAltitude=450,surfaceMinAltitude=0,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[41]={name="Talemai Moon 3",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=41,GM=106830900,gravity=0.08802242599860607,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=-12800515,y=55700259,z=325207.84},radius=11000,safeAreaEdgeAltitude=500000,size="XS",spaceEngineMinAltitude=0,surfaceArea=1520530944,surfaceAverageAltitude=190,surfaceMaxAltitude=400,surfaceMinAltitude=0,systemZone=nil,territories=1922,type="",waterLevel=nil,planetarySystemId=0},[8]={name="Teoma",description="[REDACTED] The arkship geological survey [REDACTED]. This planet should not be here.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.7834,atmosphericEngineMaxAltitude=5580,biosphere="Forest",classification="Mesoplanet",bodyId=8,GM=18477723600,gravity=0.48812434578525177,fullAtmosphericDensityMaxAltitude=15,habitability="High",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=6280,numSatellites=0,positionFromSun=8,center={x=80865538,y=54665536,z=-934463.94},radius=62000,safeAreaEdgeAltitude=500000,size="L",spaceEngineMinAltitude=3420,surfaceArea=48305131520,surfaceAverageAltitude=700,surfaceMaxAltitude=1100,surfaceMinAltitude=-200,systemZone="High",territories=60752,type="Planet",waterLevel=0,planetarySystemId=0},[3]={name="Thades",description="Thades is a scorched desert planet. Perhaps it was once teaming with life but now all that remains is ash and dust. The arkship geological survey reports a rocky mountainous planet bisected by a massive unnatural ravine; something happened to this planet.",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0.03552,atmosphericEngineMaxAltitude=32180,biosphere="Desert",classification="Thermoplanet",bodyId=3,GM=11776905000,gravity=0.49612641213015557,fullAtmosphericDensityMaxAltitude=150,habitability="Low",hasAtmosphere=true,isSanctuary=false,noAtmosphericDensityAltitude=32800,numSatellites=2,positionFromSun=3,center={x=29165536,y=10865536,z=65536},radius=49000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=21400,surfaceArea=30171856896,surfaceAverageAltitude=13640,surfaceMaxAltitude=13690,surfaceMinAltitude=370,systemZone="Low",territories=38882,type="Planet",waterLevel=nil,planetarySystemId=0},[30]={name="Thades Moon 1",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=30,GM=211564034,gravity=0.11202853997062348,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=29214402,y=10907080.695,z=433858.2},radius=14000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2463008768,surfaceAverageAltitude=60,surfaceMaxAltitude=300,surfaceMinAltitude=0,systemZone=nil,territories=3002,type="",waterLevel=nil,planetarySystemId=0},[31]={name="Thades Moon 2",description="",antiGravMinAltitude=1000,atmosphericDensityAboveSurface=0,atmosphericEngineMaxAltitude=0,biosphere="",classification="",bodyId=31,GM=264870000,gravity=0.12003058201190042,fullAtmosphericDensityMaxAltitude=0,habitability="",hasAtmosphere=false,isSanctuary=false,noAtmosphericDensityAltitude=0,numSatellites=0,positionFromSun=0,center={x=29404193,y=10432768,z=19554.131},radius=15000,safeAreaEdgeAltitude=500000,size="M",spaceEngineMinAltitude=0,surfaceArea=2827433472,surfaceAverageAltitude=70,surfaceMaxAltitude=350,surfaceMinAltitude=0,systemZone=nil,territories=3632,type="",waterLevel=nil,planetarySystemId=0}}}end;function SetupAtlas()aS=Atlas()for bg,bh in pairs(aS[0])do if av==nil or bh.center.x<av then av=bh.center.x end;if aw==nil or bh.center.x>aw then aw=bh.center.x end;if ax==nil or bh.center.y<ax then ax=bh.center.y end;if ay==nil or bh.center.y>ay then ay=bh.center.y end end;aT=""local fB=1.1*(aw-av)/1920;local fC=1.4*(ay-ax)/1080;for bg,bh in pairs(aS[0])do local bC=960+bh.center.x/fB;local bD=540+bh.center.y/fC;aT=aT..'<circle cx="'..bC..'" cy="'..bD..'" r="'..bh.radius/fB*30 ..'" stroke="white" stroke-width="3" fill="blue" />'if not string.match(bh.name,"Moon")and not string.match(bh.name,"Sanctuary")and not string.match(bh.name,"Space")then aT=aT.."<text x='"..bC.."' y='"..bD+bh.radius/fB*30+20 .."' font-size='28' fill="..aj.." text-anchor='middle' font-family='Montserrat'>"..bh.name.."</text>"end end;local bV=vec3(core.getConstructWorldPos())local bC=960+bV.x/fB;local bD=540+bV.y/fC;aT=aT..'<circle cx="'..bC..'" cy="'..bD..'" r="5" stroke="white" stroke-width="3" fill="red"/>'aT=aT.."<text x='"..bC.."' y='"..bD-50 .."' font-size='36' fill='darkred' text-anchor='middle' font-family='Bank' font-weight='bold'>You Are Here</text>"aT=aT..[[</svg>]]aU=fB;aV=fC;if screen_2 then screen_2.setHTML('<svg width="100%" height="100%" viewBox="0 0 1920 1080">'..aT)local bV=vec3(core.getConstructWorldPos())local bC=960+bV.x/fB;local bD=540+bV.y/fC;aT='<svg><circle cx="80" cy="80" r="5" stroke="white" stroke-width="3" fill="red"/>'aT=aT.."<text x='80' y='105' font-size='18' fill="..aj.." text-anchor='middle' font-family='Montserrat''>You Are Here</text></svg>"aW=screen_2.addContent((bC-80)/19.20,(bD-80)/10.80,aT)end end;function PlanetRef()local function fD(fE)return type(fE)=='number'end;local function fF(fE)return type(tonumber(fE))=='number'end;local function fG(fH)return type(fH)=='table'end;local function fI(fJ)return type(fJ)=='string'end;local function fK(bh)return fG(bh)and fD(bh.x and bh.y and bh.z)end;local function fL(fM)return fG(fM)and fD(fM.latitude and fM.longitude and fM.altitude and fM.bodyId and fM.systemId)end;local fN=math.pi/180;local fO=180/math.pi;local epsilon=1e-10;local p=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local bW='::pos{'..p..','..p..','..p..','..p..','..p..'}'local utils=require('cpml.utils')local vec3=require('cpml.vec3')local fP=utils.clamp;local function float_eq(bL,bM)if bL==0 then return math.abs(bM)<1e-09 end;if bM==0 then return math.abs(bL)<1e-09 end;return math.abs(bL-bM)<math.max(math.abs(bL),math.abs(bM))*epsilon end;local function fQ(fE)local bi=string.gsub(string.reverse(e('%.4f',fE)),'^0*%.?','')return bi==''and'0'or string.reverse(bi)end;local function fR(fS)if fK(fS)then return e('{x=%.3f,y=%.3f,z=%.3f}',fS.x,fS.y,fS.z)end;if fG(fS)and not getmetatable(fS)then local fT={}local fU=next(fS)if type(fU)=='nil'or fU==1 then fT=fS else for bg,bh in pairs(fS)do local dM=fR(bh)if type(bg)=='number'then table.insert(fT,e('[%s]=%s',bg,dM))else table.insert(fT,e('%s=%s',bg,dM))end end end;return e('{%s}',table.concat(fT,','))end;if fI(fS)then return e("'%s'",fS:gsub("'",[[\']]))end;return tostring(fS)end;local fV={}fV.__index=fV;fV.__tostring=function(fS,fW)local fX={}for bg in pairs(fS)do table.insert(fX,bg)end;table.sort(fX)local fT={}for _,bg in ipairs(fX)do local dM=fR(fS[bg])if type(bg)=='number'then table.insert(fT,e('[%s]=%s',bg,dM))else table.insert(fT,e('%s=%s',bg,dM))end end;if fW then return e('%s%s',fW,table.concat(fT,',\n'..fW))end;return e('{%s}',table.concat(fT,','))end;fV.__eq=function(fY,fZ)return fY.planetarySystemId==fZ.planetarySystemId and fY.bodyId==fZ.bodyId and float_eq(fY.radius,fZ.radius)and float_eq(fY.center.x,fZ.center.x)and float_eq(fY.center.y,fZ.center.y)and float_eq(fY.center.z,fZ.center.z)and float_eq(fY.GM,fZ.GM)end;local function f_(bX,bY,g0,bO,g1)assert(fF(bX),'Argument 1 (planetarySystemId) must be a number:'..type(bX))assert(fF(bY),'Argument 2 (bodyId) must be a number:'..type(bY))assert(fF(g0),'Argument 3 (radius) must be a number:'..type(g0))assert(fG(bO),'Argument 4 (worldCoordinates) must be a array or vec3.'..type(bO))assert(fF(g1),'Argument 5 (GM) must be a number:'..type(g1))return setmetatable({planetarySystemId=tonumber(bX),bodyId=tonumber(bY),radius=tonumber(g0),center=vec3(bO),GM=tonumber(g1)},fV)end;local MapPosition={}MapPosition.__index=MapPosition;MapPosition.__tostring=function(g2)return e('::pos{%d,%d,%s,%s,%s}',g2.systemId,g2.bodyId,fQ(g2.latitude*fO),fQ(g2.longitude*fO),fQ(g2.altitude))end;MapPosition.__eq=function(fY,fZ)return fY.bodyId==fZ.bodyId and fY.systemId==fZ.systemId and float_eq(fY.latitude,fZ.latitude)and float_eq(fY.altitude,fZ.altitude)and(float_eq(fY.longitude,fZ.longitude)or float_eq(fY.latitude,math.pi/2)or float_eq(fY.latitude,-math.pi/2))end;local function g3(g4,bY,bS,bT,bR)local bX=g4;if fI(g4)and not bT and not bR and not bY and not bS then bX,bY,bS,bT,bR=string.match(g4,bW)assert(bX,'Argument 1 (position string) is malformed.')else assert(fF(bX),'Argument 1 (systemId) must be a number:'..type(bX))assert(fF(bY),'Argument 2 (bodyId) must be a number:'..type(bY))assert(fF(bS),'Argument 3 (latitude) must be in degrees:'..type(bS))assert(fF(bT),'Argument 4 (longitude) must be in degrees:'..type(bT))assert(fF(bR),'Argument 5 (altitude) must be in meters:'..type(bR))end;bX=tonumber(bX)bY=tonumber(bY)bS=tonumber(bS)bT=tonumber(bT)bR=tonumber(bR)if bY==0 then return setmetatable({latitude=bS,longitude=bT,altitude=bR,bodyId=bY,systemId=bX},MapPosition)end;return setmetatable({latitude=fN*fP(bS,-90,90),longitude=fN*(bT%360),altitude=bR,bodyId=bY,systemId=bX},MapPosition)end;local g5={}g5.__index=g5;g5.__tostring=function(fS,fW)local g6=fW and fW..' 'local g7={}local fX={}for bg in pairs(fS)do table.insert(fX,bg)end;table.sort(fX)for _,g8 in ipairs(fX)do bdy=fS[g8]local g9=fV.__tostring(bdy,g6)if fW then table.insert(g7,e('[%s]={\n%s\n%s}',g8,g9,fW))else table.insert(g7,e(' [%s]=%s',g8,g9))end end;if fW then return e('\n%s%s%s',fW,table.concat(g7,',\n'..fW),fW)end;return e('{\n%s\n}',table.concat(g7,',\n'))end;local function ga(gb)local aS={}local pid;for _,bh in pairs(gb)do local c3=bh.planetarySystemId;if type(c3)~='number'then error('Invalid planetary system ID: '..tostring(c3))elseif pid and c3~=pid then error('Mismatch planetary system IDs: '..c3 ..' and '..pid)end;local gc=bh.bodyId;if type(gc)~='number'then error('Invalid body ID: '..tostring(gc))elseif aS[gc]then error('Duplicate body ID: '..tostring(gc))end;setmetatable(bh.center,getmetatable(vec3.unit_x))aS[gc]=setmetatable(bh,fV)pid=c3 end;return setmetatable(aS,g5)end;aX={}local function gd(gb)return setmetatable({galaxyAtlas=gb or{}},aX)end;aX.__index=function(fH,i)if type(i)=='number'then local system=fH.galaxyAtlas[i]return ga(system)end;return rawget(aX,i)end;aX.__pairs=function(fS)return function(fH,bg)local ge,nv=next(fH,bg)return ge,nv and ga(nv)end,fS.galaxyAtlas,nil end;aX.__tostring=function(fS)local gf={}for _,gg in pairs(fS or{})do local gh=gg:getPlanetarySystemId()local gi=g5.__tostring(gg,' ')table.insert(gf,e(' [%s]={%s\n }',gh,gi))end;return e('{\n%s\n}\n',table.concat(gf,',\n'))end;aX.BodyParameters=f_;aX.MapPosition=g3;aX.PlanetarySystem=ga;function aX.createBodyParameters(gj,bY,gk,gl,gm,gn,go)assert(fF(gj),'Argument 1 (planetarySystemId) must be a number:'..type(gj))assert(fF(bY),'Argument 2 (bodyId) must be a number:'..type(bY))assert(fF(gk),'Argument 3 (surfaceArea) must be a number:'..type(gk))assert(fG(gl),'Argument 4 (aPosition) must be an array or vec3:'..type(gl))assert(fG(gm),'Argument 5 (verticalAtPosition) must be an array or vec3:'..type(gm))assert(fF(gn),'Argument 6 (altitude) must be in meters:'..type(gn))assert(fF(go),'Argument 7 (gravityAtPosition) must be number:'..type(go))local g0=math.sqrt(gk/4/math.pi)local a3=g0+gn;local gp=vec3(gl)+a3*vec3(gm)local g1=go*a3*a3;return f_(gj,bY,g0,gp,g1)end;aX.isMapPosition=fL;function aX:getPlanetarySystem(g4)if i==nil then i=0 end;if nv==nil then nv=0 end;local gj=g4;if fL(g4)then gj=g4.systemId end;if type(gj)=='number'then local system=self.galaxyAtlas[i]if system then if getmetatable(nv)~=g5 then system=ga(system)end;return system end end end;function g5:castIntersections(gq,f4,gr,gs)local gr=gr or function(gt)return 1.05*gt.radius end;local gu={}if gs then for _,i in ipairs(gs)do gu[i]=self[i]end else gs={}for bg,gt in pairs(self)do table.insert(gs,bg)gu[bg]=gt end end;local function gv(gw,gx)local gy=gu[gw].center-gq;local gz=gu[gx].center-gq;return gy:len()<gz:len()end;table.sort(gs,gv)local gA=f4:normalize()for i,c3 in ipairs(gs)do local gt=gu[c3]local gB=gt.center-gq;local g0=gr(gt)local gC=gB:dot(gA)local gD=gC^2-(gB:len2()-g0^2)if gD>=0 then local gE=math.sqrt(gD)local gF=gC+gE;local gG=gC-gE;if gG>0 then return gt,gF,gG elseif gF>0 then return gt,gF,nil end end end;return nil,nil,nil end;function g5:closestBody(gH)assert(type(gH)=='table','Invalid coordinates.')local gI,gt;local gJ=vec3(gH)for _,gK in pairs(self)do local gL=(gK.center-gJ):len2()if(not gt or gL<gI)and gK.name~="Space"then gt=gK;gI=gL end end;return gt end;function g5:convertToBodyIdAndWorldCoordinates(g4)local gM=g4;if fI(g4)then gM=g3(g4)end;if gM.bodyId==0 then return 0,vec3(gM.latitude,gM.longitude,gM.altitude)end;local gK=self:getBodyParameters(gM)if gK then return gM.bodyId,gK:convertToWorldCoordinates(gM)end end;function g5:getBodyParameters(g4)local bY=g4;if fL(g4)then bY=g4.bodyId end;assert(fF(bY),'Argument 1 (bodyId) must be a number:'..type(bY))return self[bY]end;function g5:getPlanetarySystemId()local _,bh=next(self)return bh and bh.planetarySystemId end;function fV:convertToMapPosition(bO)assert(fG(bO),'Argument 1 (worldCoordinates) must be an array or vec3:'..type(bO))local bP=vec3(bO)if self.bodyId==0 then return setmetatable({latitude=bP.x,longitude=bP.y,altitude=bP.z,bodyId=0,systemId=self.planetarySystemId},MapPosition)end;local bQ=bP-self.center;local a3=bQ:len()local bR=a3-self.radius;local bS=0;local bT=0;if not float_eq(a3,0)then local bU=math.atan(bQ.y,bQ.x)bT=bU>=0 and bU or 2*math.pi+bU;bS=math.pi/2-math.acos(bQ.z/a3)end;return setmetatable({latitude=bS,longitude=bT,altitude=bR,bodyId=self.bodyId,systemId=self.planetarySystemId},MapPosition)end;function fV:convertToWorldCoordinates(g4)local gM=fI(g4)and g3(g4)or g4;if gM.bodyId==0 then return vec3(gM.latitude,gM.longitude,gM.altitude)end;assert(fL(gM),'Argument 1 (mapPosition) is not an instance of "MapPosition".')assert(gM.systemId==self.planetarySystemId,'Argument 1 (mapPosition) has a different planetary system ID.')assert(gM.bodyId==self.bodyId,'Argument 1 (mapPosition) has a different planetary body ID.')local bZ=math.cos(gM.latitude)return self.center+(self.radius+gM.altitude)*vec3(bZ*math.cos(gM.longitude),bZ*math.sin(gM.longitude),math.sin(gM.latitude))end;function fV:getAltitude(bO)return(vec3(bO)-self.center):len()-self.radius end;function fV:getDistance(bO)return(vec3(bO)-self.center):len()end;function fV:getGravity(bO)local gN=self.center-vec3(bO)local gO=gN:len2()return self.GM/gO*gN/math.sqrt(gO)end;return setmetatable(aX,{__call=function(_,...)return gd(...)end})end;function Keplers()local vec3=require('cpml.vec3')local PlanetRef=PlanetRef()local function fI(fJ)return type(fJ)=='string'end;local function fG(fH)return type(fH)=='table'end;local function float_eq(bL,bM)if bL==0 then return math.abs(bM)<1e-09 end;if bM==0 then return math.abs(bL)<1e-09 end;return math.abs(bL-bM)<math.max(math.abs(bL),math.abs(bM))*constants.epsilon end;Kepler={}Kepler.__index=Kepler;function Kepler:escapeAndOrbitalSpeed(bR)assert(self.body)local a3=bR+self.body.radius;if not float_eq(a3,0)then local orbit=math.sqrt(self.body.GM/a3)return math.sqrt(2)*orbit,orbit end;return nil,nil end;function Kepler:orbitalParameters(g4,b5)assert(self.body)assert(fG(g4)or fI(g4))assert(fG(b5))local bV=(fI(g4)or PlanetRef.isMapPosition(g4))and self.body:convertToWorldCoordinates(g4)or vec3(g4)local bh=vec3(b5)local gP=bV-self.body.center;local gz=bh:len2()local gQ=gP:len()local gR=self.body.GM;local gS=((gz-gR/gQ)*gP-gP:dot(bh)*bh)/gR;local bL=gR/(2*gR/gQ-gz)local gT=gS:len()local gA=gS:normalize()local gU=bL*(1-gT)local gV=bL*(1+gT)local gW=gU*gA+self.body.center;local gX=gT<=1 and-gV*gA+self.body.center or nil;local gY=math.sqrt(bL*gR*(1-gT*gT))local gZ=gX and 2*math.pi*math.sqrt(bL^3/gR)local g_=math.acos(gS:dot(gP)/(gT*gQ))if gP:dot(bh)<0 then g_=-(g_-2*math.pi)end;local h0=math.acos((math.cos(g_)+gT)/(1+gT*math.cos(g_)))local h1=h0;if h1<0 then h1=h1+2*math.pi end;local h2=h1-gT*math.sin(h1)local h3=0;local h4=0;local h5=0;if gZ~=nil then h3=h2/(2*math.pi/gZ)h4=gZ-h3;h5=h4+gZ/2;if g_-math.pi>0 then h4=h3;h5=h4+gZ/2 end;if h5>gZ then h5=h5-gZ end end;return{periapsis={position=gW,speed=gY/gU,circularOrbitSpeed=math.sqrt(gR/gU),altitude=gU-self.body.radius},apoapsis=gX and{position=gX,speed=gY/gV,circularOrbitSpeed=math.sqrt(gR/gV),altitude=gV-self.body.radius},currentVelocity=bh,currentPosition=bV,eccentricity=gT,period=gZ,eccentricAnomaly=h0,meanAnomaly=h2,timeToPeriapsis=h4,timeToApoapsis=h5}end;local function h6(h7)local gK=PlanetRef.BodyParameters(h7.planetarySystemId,h7.bodyId,h7.radius,h7.center,h7.GM)return setmetatable({body=gK},Kepler)end;return setmetatable(Kepler,{__call=function(_,...)return h6(...)end})end;function Kinematics()local aZ={}local h8=30000000/3600;local h9=h8*h8;local ha=100;local function hb(bh)return 1/math.sqrt(1-bh*bh/h9)end;function aZ.computeAccelerationTime(hc,hd,he)local hf=h8*math.asin(hc/h8)return(h8*math.asin(he/h8)-hf)/hd end;function aZ.computeDistanceAndTime(hc,he,hg,hh,hi,hj)hi=hi or 0;hj=hj or 0;local hk=hc<=he;local hl=hh*(hk and 1 or-1)/hg;local hm=-hj/hg;local hn=hl+hm;if hk and hn<=0 or not hk and hn>=0 then return-1,-1 end;local ho,hp=0,0;if hl~=0 and hi>0 then local hf=math.asin(hc/h8)local hq=math.pi*(hl/2+hm)local hr=hl*hi;local hs=h8*math.pi;local bh=function(fH)local cz=(hq*fH-hr*math.sin(math.pi*fH/2/hi)+hs*hf)/hs;local ht=math.tan(cz)return h8*ht/math.sqrt(ht*ht+1)end;local hu=hk and function(fJ)return fJ>=he end or function(fJ)return fJ<=he end;hp=2*hi;if hu(bh(hp))then local hv=0;while math.abs(hp-hv)>0.5 do local fH=(hp+hv)/2;if hu(bh(fH))then hp=fH else hv=fH end end end;local hw=hc;local hx=hp/ha;for hy=1,ha do local bw=bh(hy*hx)ho=ho+(bw+hw)*hx/2;hw=bw end;if hp<2*hi then return ho,hp end;hc=hw end;local hf=h8*math.asin(hc/h8)local bj=(h8*math.asin(he/h8)-hf)/hn;local hz=h9*math.cos(hf/h8)/hn;local a3=hz-h9*math.cos((hn*bj+hf)/h8)/hn;return a3+ho,bj+hp end;function aZ.computeTravelTime(hc,hd,a3)if a3==0 then return 0 end;if hd>0 then local hf=h8*math.asin(hc/h8)local hz=h9*math.cos(hf/h8)/hd;return(h8*math.acos(hd*(hz-a3)/h9)-hf)/hd end;assert(hc>0,'Acceleration and initial speed are both zero.')return a3/hc end;function aZ.lorentz(bh)return hb(bh)end;return aZ end;function script.onStart()VERSION_NUMBER=5.100;SetupComplete=false;beginSetup=coroutine.create(function()Nav.axisCommandManager:setupCustomTargetSpeedRanges(axisCommandId.longitudinal,{1000,5000,10000,20000,30000})LoadVariables()coroutine.yield()ProcessElements()coroutine.yield()SetupChecks()SetupButtons()coroutine.yield()SetupAtlas()aX=PlanetRef()aY=aX(Atlas())aZ=Kinematics()b0=Keplers()AddLocationsToAtlas()UpdateAtlasLocationsList()UpdateAutopilotTarget()coroutine.yield()unit.hide()system.showScreen(1)collectgarbage("collect")coroutine.yield()unit.setTimer("apTick",apTickRate)unit.setTimer("hudTick",hudTickRate)unit.setTimer("oneSecond",1)unit.setTimer("tenthSecond",1/10)if UseSatNav then unit.setTimer("fiveSecond",5)end end)end;function SaveDataBank(hA)if dbHud_1 then if not Y then for bg,bh in pairs(b)do dbHud_1.setStringValue(bh,g(_G[bh]))if hA and dbHud_2 then dbHud_2.setStringValue(bh,g(_G[bh]))end end;for bg,bh in pairs(a)do dbHud_1.setStringValue(bh,g(_G[bh]))if hA and dbHud_2 then dbHud_2.setStringValue(bh,g(_G[bh]))end end;c("Saved Variables to Datacore")if hA and dbHud_2 then K="Databank copied. Remove copy when ready."end end end end;function script.onStop()_autoconf.hideCategoryPanels()if antigrav~=nil and not ExternalAGG then antigrav.hide()end;if warpdrive~=nil then warpdrive.hide()end;core.hide()Nav.control.switchOffHeadlights()local br=j()if door and(br>0 or br==0 and ae<10000)then for _,bh in pairs(door)do bh.toggle()end end;if switch then for _,bh in pairs(switch)do bh.toggle()end end;if forcefield and(br>0 or br==0 and ae<10000)then for _,bh in pairs(forcefield)do bh.toggle()end end;SaveDataBank()if button then button.activate()end end;function script.onTick(hB)if hB=="tenthSecond"then if AutopilotTargetName~="None"then if panelInterplanetary==nil then SetupInterplanetaryPanel()end;if AutopilotTargetName~=nil then local hC=CustomTarget~=nil;planetMaxMass=GetAutopilotMaxMass()system.updateData(interplanetaryHeaderText,'{"label": "Target", "value": "'..AutopilotTargetName..'", "unit":""}')travelTime=GetAutopilotTravelTime()if hC then a3=(vec3(core.getConstructWorldPos())-CustomTarget.position):len()else a3=(AutopilotTargetCoords-vec3(core.getConstructWorldPos())):len()end;if not TurnBurn then P,Q=GetAutopilotBrakeDistanceAndTime(b6)R,S=GetAutopilotBrakeDistanceAndTime(MaxGameVelocity)else P,Q=GetAutopilotTBBrakeDistanceAndTime(b6)R,S=GetAutopilotTBBrakeDistanceAndTime(MaxGameVelocity)end;local db,dc=getDistanceDisplayString(a3)system.updateData(widgetDistanceText,'{"label": "distance", "value": "'..db..'", "unit":"'..dc..'"}')system.updateData(widgetTravelTimeText,'{"label": "Travel Time", "value": "'..FormatTimeString(travelTime)..'", "unit":""}')db,dc=getDistanceDisplayString(P)system.updateData(widgetCurBrakeDistanceText,'{"label": "Cur Brake distance", "value": "'..db..'", "unit":"'..dc..'"}')system.updateData(widgetCurBrakeTimeText,'{"label": "Cur Brake Time", "value": "'..FormatTimeString(Q)..'", "unit":""}')db,dc=getDistanceDisplayString(R)system.updateData(widgetMaxBrakeDistanceText,'{"label": "Max Brake distance", "value": "'..db..'", "unit":"'..dc..'"}')system.updateData(widgetMaxBrakeTimeText,'{"label": "Max Brake Time", "value": "'..FormatTimeString(S)..'", "unit":""}')system.updateData(widgetMaxMassText,'{"label": "Maximum Mass", "value": "'..e("%.2f",planetMaxMass/1000)..'", "unit":" Tons"}')db,dc=getDistanceDisplayString(AutopilotTargetOrbit)system.updateData(widgetTargetOrbitText,'{"label": "Target Orbit", "value": "'..e("%.2f",db)..'", "unit":"'..dc..'"}')if j()>0 and not WasInAtmo then system.removeDataFromWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)system.removeDataFromWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)system.removeDataFromWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)system.removeDataFromWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)system.removeDataFromWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)WasInAtmo=true end;if j()==0 and WasInAtmo then if system.updateData(widgetMaxBrakeTimeText,widgetMaxBrakeTime)==1 then system.addDataToWidget(widgetMaxBrakeTimeText,widgetMaxBrakeTime)end;if system.updateData(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)==1 then system.addDataToWidget(widgetMaxBrakeDistanceText,widgetMaxBrakeDistance)end;if system.updateData(widgetCurBrakeTimeText,widgetCurBrakeTime)==1 then system.addDataToWidget(widgetCurBrakeTimeText,widgetCurBrakeTime)end;if system.updateData(widgetCurBrakeDistanceText,widgetCurBrakeDistance)==1 then system.addDataToWidget(widgetCurBrakeDistanceText,widgetCurBrakeDistance)end;if system.updateData(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)==1 then system.addDataToWidget(widgetTrajectoryAltitudeText,widgetTrajectoryAltitude)end;WasInAtmo=false end end else HideInterplanetaryPanel()end;if warpdrive~=nil then if f(warpdrive.getData()).destination~="Unknown"and f(warpdrive.getData()).distance>400000 then warpdrive.show()showWarpWidget=true else warpdrive.hide()showWarpWidget=false end end elseif hB=="oneSecond"then ab=false;RefreshLastMaxBrake(nil,true)updateDistance()updateRadar()updateWeapons()local c7={}local di=GetFlightStyle()DrawOdometer(c7,W,TotalDistanceTravelled,di,X)if ShouldCheckDamage then CheckDamage(c7)end;a5=table.concat(c7,"")collectgarbage("collect")elseif hB=="fiveSecond"then ac=dbHud_1.getStringValue("SPBAutopilotTargetName")if ac~=nil and ac~=""and ac~="SatNavNotChanged"then local bi=json.decode(dbHud_1.getStringValue("SavedLocations"))if bi~=nil then _G["SavedLocations"]=bi;local c5=-1;local c1;for bg,bh in pairs(SavedLocations)do if bh.name and bh.name=="SatNav Location"then c5=bg;break end end;if c5~=-1 then c1=SavedLocations[c5]c5=-1;for bg,bh in pairs(aS[0])do if bh.name and bh.name=="SatNav Location"then c5=bg;break end end;if c5>-1 then aS[0][c5]=c1 end;UpdateAtlasLocationsList()K=c1.name.." position updated"end end;for i=1,#AtlasOrdered do if AtlasOrdered[i].name==ac then AutopilotTargetIndex=i;system.print("Index = "..AutopilotTargetIndex.." "..AtlasOrdered[i].name)UpdateAutopilotTarget()dbHud_1.setStringValue("SPBAutopilotTargetName","SatNavNotChanged")break end end end elseif hB=="msgTick"then local c7={}DisplayMessage(c7,"empty")K="empty"unit.stopTimer("msgTick")a2=3 elseif hB=="animateTick"then b2=true;b1=false;a0=0;a1=0;unit.stopTimer("animateTick")elseif hB=="hudTick"then local c7={}HUDPrologue(c7)if showHud then UpdateHud(c7)else DisplayOrbitScreen(c7)DrawWarnings(c7)end;HUDEpilogue(c7)c7[#c7+1]=e([[<svg width="100%%" height="100%%" style="position:absolute;top:0;left:0" viewBox="0 0 %d %d">]],ResolutionX,ResolutionY)if K~="empty"then DisplayMessage(c7,K)end;if o()==0 and userControlScheme=="virtual joystick"then DrawDeadZone(c7)end;if o()==1 and screen_1 and screen_1.getMouseY()~=-1 then SetButtonContains()DrawButtons(c7)if screen_1.getMouseState()==1 then CheckButtons()end;c7[#c7+1]=e([[<g transform="translate(%d %d)"><circle class="cursor" cx="%fpx" cy="%fpx" r="5"/></g>]],s,t,a0,a1)elseif system.isViewLocked()==0 then if o()==1 and J then SetButtonContains()DrawButtons(c7)if not b1 and not b2 then local hD=table.concat(c7,"")c7={}c7[#c7+1]=e("<style>@keyframes test { from { opacity: 0; } to { opacity: 1; } } body { animation-name: test; animation-duration: 0.5s; }</style><body><svg width='100%%' height='100%%' position='absolute' top='0' left='0'><rect width='100%%' height='100%%' x='0' y='0' position='absolute' style='fill:rgb(6,5,26);'/></svg><svg width='50%%' height='50%%' style='position:absolute;top:30%%;left:25%%' viewbox='0 0 %d %d'>",ResolutionX,ResolutionY)c7[#c7+1]=aT;c7[#c7+1]=hD;c7[#c7+1]="</body>"b1=true;c7[#c7+1]=[[</svg></body>]]unit.setTimer("animateTick",0.5)local content=table.concat(c7,"")system.setScreen(content)elseif b2 then local hD=table.concat(c7,"")c7={}c7[#c7+1]=e("<body style='background-color:rgb(6,5,26)'><svg width='50%%' height='50%%' style='position:absolute;top:30%%;left:25%%' viewbox='0 0 %d %d'>",ResolutionX,ResolutionY)c7[#c7+1]=aT;c7[#c7+1]=hD;c7[#c7+1]="</body>"end;if not b1 then c7[#c7+1]=e([[<g transform="translate(%d %d)"><circle class="cursor" cx="%fpx" cy="%fpx" r="5"/></g>]],s,t,a0,a1)end else CheckButtons()end else if not J and o()==0 then CheckButtons()if a3>DeadZone then DrawCursorLine(c7)end else SetButtonContains()DrawButtons(c7)end;c7[#c7+1]=e([[<g transform="translate(%d %d)"><circle class="cursor" cx="%fpx" cy="%fpx" r="5"/></g>]],s,t,a0,a1)end;c7[#c7+1]=[[</svg></body>]]content=table.concat(c7,"")if not DidLogOutput then system.logInfo(LastContent)DidLogOutput=true end elseif hB=="apTick"then b4=vec3(core.getConstructWorldOrientationForward()):dot(vec3(core.getWorldVelocity()):normalize())ad=j()>0;local bj=system.getTime()local hE=bj-bc;bc=bj;local hF=core.getVelocity()local hG=getRelativeYaw(hF)local hH=getRelativePitch(hF)bb=ad and hG<-StallAngle or hG>StallAngle or hH<-StallAngle or hH>StallAngle;b9=system.getMouseDeltaX()ba=system.getMouseDeltaY()if InvertMouse and not J then ba=-ba end;D=0;H=0;C=0;b5=vec3(core.getWorldVelocity())b6=vec3(b5):len()sys=aY[0]planet=sys:closestBody(core.getConstructWorldPos())kepPlanet=b0(planet)orbit=kepPlanet:orbitalParameters(core.getConstructWorldPos(),b5)aa=hoverDetectGround()local ca=vec3(core.getConstructWorldOrientationForward())local cb=vec3(core.getConstructWorldOrientationRight())local hI=vec3(core.getConstructWorldOrientationUp())local cc=vec3(core.getWorldVertical())local cd=getPitch(cc,ca,cb)local bt=planet:getGravity(core.getConstructWorldPos()):len()*n()bd=0;local dk=getRoll(cc,ca,cb)local dl=math.abs(dk/180*math.pi)local dm=math.cos(dl)local dn=math.sin(dl)local hJ=getPitch(cc,ca,cb*dm+vec3(core.getConstructWorldOrientationUp())*dn)a_=core.getMaxKinematicsParametersAlongAxis("ground",core.getConstructOrientationUp())[1]if o()==1 and screen_1 and screen_1.getMouseY()~=-1 then a0=screen_1.getMouseX()*ResolutionX;a1=screen_1.getMouseY()*ResolutionY elseif system.isViewLocked()==0 then if o()==1 and J then if not b1 then a0=a0+b9;a1=a1+ba end else a0=0;a1=0 end else a0=a0+b9;a1=a1+ba;a3=math.sqrt(a0*a0+a1*a1)if not J and o()==0 then if userControlScheme=="virtual joystick"then if a0>0 and a0>DeadZone then D=D-(a0-DeadZone)*MouseXSensitivity elseif a0<0 and a0<DeadZone*-1 then D=D-(a0+DeadZone)*MouseXSensitivity else D=0 end;if a1>0 and a1>DeadZone then C=C-(a1-DeadZone)*MouseYSensitivity elseif a1<0 and a1<DeadZone*-1 then C=C-(a1+DeadZone)*MouseYSensitivity else C=0 end elseif userControlScheme=="mouse"then a0=0;a1=0;C=(-utils.smoothstep(ba,-100,100)+0.5)*2*y;D=(-utils.smoothstep(b9,-100,100)+0.5)*2*z else a0=0;a1=0 end end end;local hK=b6>8334;if b6>SpaceSpeedLimit/3.6 and not ad and not Autopilot and not hK then K="Space Speed Engine Shutoff reached"if Nav.axisCommandManager:getAxisCommandType(0)==1 then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)end;if not hK and LastIsWarping then if not BrakeIsOn then BrakeToggle()end;if Autopilot then ToggleAutopilot()end end;LastIsWarping=hK;if ad and j()>0.09 then if b6>AtmoSpeedLimit/3.6 then if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byThrottle then Nav.control.cancelCurrentControlMasterMode()end end end;if BrakeIsOn then G=1 else G=0 end;ae=core.getAltitude()if ae==0 then ae=(vec3(core.getConstructWorldPos())-planet.center):len()-planet.radius end;if ProgradeIsOn then if b6>w then local hL=AlignToWorldVector(vec3(b5),0.01)if a7 then b3=true;if b6<ReentrySpeed/3.6 then BrakeIsOn=false;ProgradeIsOn=false;x=true;a7=false;a9=true;Autopilot=false;b3=autoRollPreference;BeginReentry()else BrakeIsOn=true end end end end;if RetrogradeIsOn then if ad then RetrogradeIsOn=false elseif b6>w then AlignToWorldVector(-vec3(b5))end end;if not ProgradeIsOn and a7 then if j()==0 then x=true;BeginReentry()a7=false;a9=true else a7=false;ToggleAutopilot()end end;if a9 and ae<ReentryAltitude+100 and b6*3.6>ReentrySpeed-100 then ToggleAutopilot()a9=false end;if Autopilot and j()==0 and not a7 then local P,Q;if not TurnBurn then P,Q=GetAutopilotBrakeDistanceAndTime(b6)else P,Q=GetAutopilotTBBrakeDistanceAndTime(b6)end;P=P;Q=Q;local hM=AutopilotTargetCoords;local hN=false;AutopilotDistance=(vec3(hM)-vec3(core.getConstructWorldPos())):len()local hO=(AutopilotTargetCoords-vec3(core.getConstructWorldPos())):len()local db,dc=getDistanceDisplayString(hO)system.updateData(widgetDistanceText,'{"label": "distance", "value": "'..db..'", "unit":"'..dc..'"}')local hP=true;local hQ=(V.center-(vec3(core.getConstructWorldPos())+vec3(b5):normalize()*AutopilotDistance)):len()-V.radius;db,dc=getDistanceDisplayString(hQ)system.updateData(widgetTrajectoryAltitudeText,'{"label": "Projected Altitude", "value": "'..db..'", "unit":"'..dc..'"}')if orbit.apoapsis==nil and b6>300 and AutopilotAccelerating then local d8=vec3(hM)-vec3(core.getConstructWorldPos())local hR=utils.clamp(math.deg(cu(hI,b5:normalize(),d8:normalize()))*b6/500,-90,90)local hS=utils.clamp(math.deg(cu(cb,b5:normalize(),d8:normalize()))*b6/500,-90,90)if math.abs(hR)<5 and math.abs(hS)<5 then hR=hR*2;hS=hS*2 end;if math.abs(hR)<2 and math.abs(hS)<2 then hR=hR*2;hS=hS*2 end;local hG=-math.deg(cu(hI,ca,b5:normalize()))local hH=-math.deg(cu(cb,ca,b5:normalize()))if apPitchPID==nil then apPitchPID=pid.new(2*0.01,0,2*0.1)end;apPitchPID:inject(hS-hH)local hT=utils.clamp(apPitchPID:get(),-1,1)C=C+hT;if apYawPID==nil then apYawPID=pid.new(2*0.01,0,2*0.1)end;apYawPID:inject(hR-hG)local hU=utils.clamp(apYawPID:get(),-1,1)D=D+hU;hN=true end;if hQ<AutopilotTargetOrbit*1.5 then if CustomTarget~=nil and CustomTarget.planetname=="Space"then AutopilotEndSpeed=0 else _,AutopilotEndSpeed=b0(V):escapeAndOrbitalSpeed(hQ)end end;if not AutopilotCruising and not AutopilotBraking and not hN then hP=AlignToWorldVector((hM-vec3(core.getConstructWorldPos())):normalize())elseif TurnBurn and not hN then hP=AlignToWorldVector(-vec3(b5):normalize())end;if AutopilotAccelerating then if not hP or BrakeIsOn then AutopilotStatus="Adjusting Trajectory"else AutopilotStatus="Accelerating"end;if not u then BrakeIsOn=false;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,AutopilotInterplanetaryThrottle)u=true end;if vec3(core.getVelocity()):len()>=MaxGameVelocity or unit.getThrottle()==0 and u then AutopilotAccelerating=false;AutopilotStatus="Cruising"AutopilotCruising=true;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)u=false end;if AutopilotDistance<=P then AutopilotAccelerating=false;AutopilotStatus="Braking"AutopilotBraking=true;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)u=false end elseif AutopilotBraking then BrakeIsOn=true;G=1;if TurnBurn then Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,100)end;if CustomTarget~=nil and CustomTarget.planetname=="Space"and b6<50 then K="Autopilot complete, arrived at space location"AutopilotBraking=false;Autopilot=false;AutopilotStatus="Aligning"elseif(CustomTarget==nil or CustomTarget~=nil and CustomTarget.planetname~="Space")and orbit.periapsis~=nil and orbit.eccentricity<1 then AutopilotStatus="Circularizing"local _,hV=b0(V):escapeAndOrbitalSpeed((vec3(core.getConstructWorldPos())-planet.center):len()-planet.radius)if b6<=hV or orbit.apoapsis.altitude<AutopilotTargetOrbit and orbit.periapsis.altitude<AutopilotTargetOrbit then BrakeIsOn=false;AutopilotBraking=false;Autopilot=false;AutopilotStatus="Aligning"K="Autopilot completed, orbit established"G=0;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)u=false;if CustomTarget~=nil and CustomTarget.planetname~="Space"then ProgradeIsOn=true;a7=true end end end elseif AutopilotCruising then if AutopilotDistance<=P then AutopilotAccelerating=false;AutopilotStatus="Braking"AutopilotBraking=true end;if unit.getThrottle()>0 then AutopilotAccelerating=true;AutopilotStatus="Accelerating"AutopilotCruising=false end else if hP then if not AutopilotRealigned and CustomTarget==nil or not AutopilotRealigned and CustomTarget~=nil and CustomTarget.planetname~="Space"then if not a7 then AutopilotTargetCoords=vec3(V.center)+(AutopilotTargetOrbit+V.radius)*vec3(core.getConstructWorldOrientationRight())AutopilotShipUp=core.getConstructWorldOrientationUp()AutopilotShipRight=core.getConstructWorldOrientationRight()end;AutopilotRealigned=true elseif hP then AutopilotAccelerating=true;AutopilotStatus="Accelerating"if not u then Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,AutopilotInterplanetaryThrottle)u=true;BrakeIsOn=false end end end end end;if I then b3=true;local hS=0;local bV=vec3(core.getConstructWorldPos())+vec3(unit.getMasterPlayerRelativePosition())local hW=bV-vec3(core.getConstructWorldPos())local hX=vec3(hW):project_on(vec3(core.getConstructWorldOrientationForward())):len()local hY=vec3(hW):project_on(vec3(core.getConstructWorldOrientationRight())):len()local a3=math.sqrt(hX*hX+hY*hY)AlignToWorldVector(hW:normalize())local hZ=40;local h_=a3<hZ;local i0=100;local i1=utils.clamp((a3-hZ)/2,10,i0)C=0;local hP=math.abs(D)<0.1;if hP and b6<i1 and not h_ then BrakeIsOn=false;hS=-20 else BrakeIsOn=true;hS=0 end;local i2=1.0;if math.abs(hS-cd)>i2 then if pitchPID==nil then pitchPID=pid.new(2*0.01,0,2*0.1)end;pitchPID:inject(hS-cd)local hT=pitchPID:get()C=hT end end;local dQ=vec3(core.getWorldVertical())*-1;if AltitudeHold or BrakeLanding or Reentry or VectorToTarget or LockPitch~=nil then local dw=unit.getClosestPlanetInfluence()>0;local i3=HoldAltitude-ae;local i4=500+b6;local hS=(utils.smoothstep(i3,-i4,i4)-0.5)*2*MaxPitch*utils.clamp(b6/100,0.1,1)if not AltitudeHold then hS=0 end;if LockPitch~=nil then if dw then hS=LockPitch else LockPitch=nil end end;b3=true;if Reentry then local i5=ReentrySpeed;if Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)~=i5 then Nav.axisCommandManager:setTargetSpeedCommand(axisCommandId.longitudinal,i5)Nav.axisCommandManager:setTargetSpeedCommand(axisCommandId.vertical,0)Nav.axisCommandManager:setTargetSpeedCommand(axisCommandId.lateral,0)end;if not x then hS=-80;if j()>0.02 then K="PARACHUTE DEPLOYED"Reentry=false;BrakeLanding=true;hS=0;b3=autoRollPreference end elseif Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)==ReentrySpeed then x=false;Reentry=false;b3=autoRollPreference end end;local i6=C;if b6>w and not a8 and not VectorToTarget and not BrakeLanding then AlignToWorldVector(vec3(b5))end;if VectorToTarget and CustomTarget~=nil and AutopilotTargetIndex>0 then local d8=CustomTarget.position-vec3(core.getConstructWorldPos())local hI=vec3(core.getConstructWorldOrientationUp())local hR=math.deg(cu(cc,b5:normalize(),d8:normalize()))*2;local i7=50;local i8=math.rad(math.abs(dk))if b6>i7 then bd=utils.clamp(hR/2,-90,90)local i9=hR;hR=utils.clamp(hG-hR,hG-StallAngle*0.85,hG+StallAngle*0.85)*math.cos(i8)+utils.clamp(hS-hJ,-StallAngle*0.85,StallAngle*0.85)*math.sin(math.rad(dk))hS=utils.clamp(hS*math.cos(i8),-StallAngle*0.85,StallAngle*0.85)+utils.clamp(math.abs(i9),-StallAngle*0.85,StallAngle*0.85)*math.sin(i8)end;local ia=hR;if not bb and b6>i7 then if yawPID==nil then yawPID=pid.new(2*0.01,0,2*0.1)end;yawPID:inject(ia)local hU=utils.clamp(yawPID:get(),-1,1)D=D+hU elseif aa>-1 or b6<i7 then AlignToWorldVector(d8)else AlignToWorldVector(b5)end;local ib=planet:getAltitude(CustomTarget.position)local ic=math.sqrt(d8:len()^2-(ae-ib)^2)local id=LastMaxBrakeInAtmo;if id then id=id*utils.clamp(b6/100,0.1,1)*j()else id=LastMaxBrake end;local dO=b5.x*dQ.x+b5.y*dQ.y+b5.z*dQ.z;local ie=b5:len()-math.abs(dO)local ig=vec3(core.getWorldAirFrictionAcceleration())local ih=math.sqrt(ig:len()-ig:project_on(dQ):len())*n()if b6>100 then P,Q=aZ.computeDistanceAndTime(b6,100,n(),0,0,id+ih)local ii,ij=aZ.computeDistanceAndTime(100,0,n(),0,0,id/2)P=P+ii else P,Q=aZ.computeDistanceAndTime(b6,0,n(),0,0,id/2)end;StrongBrakes=true;if ic<=P+b6*hE/2 then VectorStatus="Finalizing Approach"if Nav.axisCommandManager:getAxisCommandType(0)==axisCommandType.byTargetSpeed then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)if AltitudeHold then ToggleAltitudeHold()end;BrakeLanding=true;VectorToTarget=false elseif not AutoTakeoff then BrakeIsOn=false end end;C=i6;local fg=-1;local i2=0.1;if BrakeLanding then hS=0;local dO=b5.x*dQ.x+b5.y*dQ.y+b5.z*dQ.z;local ik=false;local il=30;if a_~=nil and a_>0 then local ih=0;local dr=utils.clamp(j(),0.4,2)local id=LastMaxBrakeInAtmo*utils.clamp(b6/100,0.1,1)*dr;local im=a_*dr+id+ih-bt;local io=id+ih-bt;local ip=id/2+ih-bt;local iq=b6-math.sqrt(math.abs(ip/2)*20/(0.5*n()))*utils.sign(ip)if iq<0 then iq=0 end;local ir;if b6>100 then local is,_=aZ.computeDistanceAndTime(b6,100,n(),0,0,id)local it,_=aZ.computeDistanceAndTime(100,0,n(),0,0,math.sqrt(id))ir=is+it else ir=aZ.computeDistanceAndTime(b6,0,n(),0,0,math.sqrt(id))end;if ir<20 then BrakeIsOn=false else local iu=0;if iq>100 then local iv,_=aZ.computeDistanceAndTime(iq,100,n(),0,0,im)local iw,_=aZ.computeDistanceAndTime(100,0,n(),0,0,a_*dr+math.sqrt(id)+ih-bt)iu=iv+iw else iu,_=aZ.computeDistanceAndTime(iq,0,n(),0,0,a_*dr+math.sqrt(id)+ih-bt)end;iu=(iu+15+b6*hE)*1.1;local ix=CustomTarget~=nil and planet:getAltitude(CustomTarget.position)>0;if ix then local ib=planet:getAltitude(CustomTarget.position)local iy=ae-ib-100;local d8=CustomTarget.position-vec3(core.getConstructWorldPos())local iz=math.sqrt(d8:len()^2-(ae-ib)^2)if iz>100 then ix=false elseif iy<=iu or iu==-1 then BrakeIsOn=true;ik=true else BrakeIsOn=false;ik=true end end;if not ix and CalculateBrakeLandingSpeed then if iu>=il then BrakeIsOn=true else BrakeIsOn=false end;ik=true end end end;if Nav.axisCommandManager:getAxisCommandType(0)==1 then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setTargetGroundAltitude(500)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(500)fg=aa;if fg>-1 then b3=autoRollPreference;if b6<1 or b5:normalize():dot(cc)<0 then BrakeLanding=false;AltitudeHold=false;GearExtended=true;Nav.control.extendLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)Z=0;BrakeIsOn=true else BrakeIsOn=true end elseif StrongBrakes and b5:normalize():dot(-dQ)<0.999 then BrakeIsOn=true elseif dO<-brakeLandingRate and not ik then BrakeIsOn=true elseif not ik then BrakeIsOn=false end end;if AutoTakeoff or a8 then if hS<15 and ae/HoldAltitude>0.75 then AutoTakeoff=false;if not a8 then if Nav.axisCommandManager:getAxisCommandType(0)==0 then Nav.control.cancelCurrentControlMasterMode()end elseif a8 and b6<w then Autopilot=true;a8=false;AltitudeHold=false;if Nav.axisCommandManager:getAxisCommandType(0)==1 then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)elseif a8 then if Nav.axisCommandManager:getAxisCommandType(0)~=0 then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)BrakeIsOn=true end elseif a8 and j()==0 and ae>75000 then if Nav.axisCommandManager:getAxisCommandType(0)==0 then Nav.control.cancelCurrentControlMasterMode()end;if Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)~=1500 then Nav.axisCommandManager:setTargetSpeedCommand(axisCommandId.longitudinal,1500)Nav.axisCommandManager:setTargetSpeedCommand(axisCommandId.vertical,0)Nav.axisCommandManager:setTargetSpeedCommand(axisCommandId.lateral,0)end end end;local iA=hoverDetectGround()>-1;local iB=cd;if VectorToTarget and not iA and b6>100 then local i8=math.rad(math.abs(dk))iB=cd*math.cos(i8)+hH*math.sin(i8)end;local iC=utils.clamp(hS-iB,-StallAngle*0.85,StallAngle*0.85)if math.abs(iC)>i2 and(not bb and(math.abs(dk)<5 or VectorToTarget)or BrakeLanding or iA)then if pitchPID==nil then pitchPID=pid.new(8*0.01,0,8*0.1)end;pitchPID:inject(iC)local hT=pitchPID:get()C=C+hT end end;L=orbit.eccentricity;if antigrav and not ExternalAGG and ae<200000 then if AntigravTargetAltitude==nil or AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;if desiredBaseAltitude~=AntigravTargetAltitude then desiredBaseAltitude=AntigravTargetAltitude;antigrav.setBaseAltitude(desiredBaseAltitude)end end end end;function script.onFlush()if antigrav and not ExternalAGG then if antigrav.getState()==0 and antigrav.getBaseAltitude()~=AntigravTargetAltitude then antigrav.setBaseAltitude(AntigravTargetAltitude)end end;pitchSpeedFactor=math.max(pitchSpeedFactor,0.01)yawSpeedFactor=math.max(yawSpeedFactor,0.01)rollSpeedFactor=math.max(rollSpeedFactor,0.01)torqueFactor=math.max(torqueFactor,0.01)brakeSpeedFactor=math.max(brakeSpeedFactor,0.01)brakeFlatFactor=math.max(brakeFlatFactor,0.01)autoRollFactor=math.max(autoRollFactor,0.01)turnAssistFactor=math.max(turnAssistFactor,0.01)local iD=utils.clamp(B+C+system.getControlDeviceForwardInput(),-1,1)local iE=utils.clamp(E+H+system.getControlDeviceYawInput(),-1,1)local iF=utils.clamp(F+D-system.getControlDeviceLeftRightInput(),-1,1)local iG=G;local iH=vec3(core.getWorldVertical())local iI=vec3(core.getConstructWorldOrientationUp())local iJ=vec3(core.getConstructWorldOrientationForward())local iK=vec3(core.getConstructWorldOrientationRight())local iL=vec3(core.getWorldVelocity())local iM=vec3(core.getWorldVelocity()):normalize()local iN=getRoll(iH,iJ,iK)local iO=math.abs(iN)local iP=utils.sign(iN)local j=j()local iQ=vec3(core.getWorldAngularVelocity())local iR=iD*pitchSpeedFactor*iK+iE*rollSpeedFactor*iJ+iF*yawSpeedFactor*iI;if iH:len()>0.01 and j>0.0 or ProgradeIsOn then if b3==true and math.abs(bd-iN)>autoRollRollThreshold and iE==0 then local iS=bd;local iT=autoRollFactor;if rollPID==nil then rollPID=pid.new(iT*0.01,0,iT*0.1)end;rollPID:inject(iS-iN)local iU=rollPID:get()iR=iR+iU*iJ end end;if iH:len()>0.01 and j>0.0 then local iV=20.0;if turnAssist==true and iO>iV and iD==0 and iF==0 then local iW=turnAssistFactor*0.1;local iX=turnAssistFactor*0.025;local iY=(iO-iV)/(180-iV)*180;local iZ=0;if iY<90 then iZ=iY/90 elseif iY<180 then iZ=(180-iY)/90 end;iZ=iZ*iZ;local i_=-iP*iX*(1.0-iZ)local j0=iW*iZ;iR=iR+j0*iK+i_*iI end end;local j1=1;local j2=0;local j3=1;local j4=torqueFactor*(iR-iQ)local j5=vec3(core.getWorldAirFrictionAngularAcceleration())j4=j4-j5;Nav:setEngineTorqueCommand('torque',j4,j1,'airfoil','','',j3)local j6=-iG*(brakeSpeedFactor*iL+brakeFlatFactor*iM)Nav:setEngineForceCommand('brake',j6)local j7=''local j8=vec3()local j9=false;local ja='thrust analog longitudinal 'if ExtraLongitudeTags~="none"then ja=ja..ExtraLongitudeTags end;local jb=Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)if jb==axisCommandType.byThrottle then local jc=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(ja,axisCommandId.longitudinal)Nav:setEngineForceCommand(ja,jc,j1)elseif jb==axisCommandType.byTargetSpeed then local jc=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.longitudinal)j7=j7 ..' , '..ja;j8=j8+jc;if Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)==0 or Nav.axisCommandManager:getCurrentToTargetDeltaSpeed(axisCommandId.longitudinal)<-Nav.axisCommandManager:getTargetSpeedCurrentStep(axisCommandId.longitudinal)*0.5 then j9=true end end;local jd='thrust analog lateral 'if ExtraLateralTags~="none"then jd=jd..ExtraLateralTags end;local je=Nav.axisCommandManager:getAxisCommandType(axisCommandId.lateral)if je==axisCommandType.byThrottle then local jf=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(jd,axisCommandId.lateral)Nav:setEngineForceCommand(jd,jf,j1)elseif je==axisCommandType.byTargetSpeed then local jg=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.lateral)j7=j7 ..' , '..jd;j8=j8+jg end;local jh='thrust analog vertical 'if ExtraVerticalTags~="none"then jh=jh..ExtraVerticalTags end;local ji=Nav.axisCommandManager:getAxisCommandType(axisCommandId.vertical)if ji==axisCommandType.byThrottle then local jj=Nav.axisCommandManager:composeAxisAccelerationFromThrottle(jh,axisCommandId.vertical)if Z~=0 or BrakeLanding and BrakeIsOn then Nav:setEngineForceCommand(jh,jj,j1,'airfoil','ground','',j3)else Nav:setEngineForceCommand(jh,vec3(),j1)Nav:setEngineForceCommand('airfoil vertical',jj,j1,'airfoil','','',j3)Nav:setEngineForceCommand('ground vertical',jj,j1,'ground','','',j3)end elseif ji==axisCommandType.byTargetSpeed then if Z==0 then Nav:setEngineForceCommand('hover',vec3(),j1)end;local jk=Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.vertical)j7=j7 ..' , '..jh;j8=j8+jk end;if j8:len()>constants.epsilon then if G~=0 or j9 or math.abs(iM:dot(iJ))<0.95 then j7=j7 ..', brake'end;Nav:setEngineForceCommand(j7,j8,j2,'','','',j3)end;Nav:setBoosterCommand('rocket_engine')if O and not VanillaRockets then local bw=vec3(core.getVelocity()):len()local jl=0.15;if Nav.axisCommandManager:getAxisCommandType(0)==1 then local jm=Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)if bw*3.6>jm*(1-jl)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bw*3.6<jm*(1-jl)and not IsRocketOn then IsRocketOn=true;Nav:toggleBoosters()end else local jn=unit.getThrottle()local i1=jn/100;if j==0 then i1=i1*MaxGameVelocity;if bw>=i1*(1-jl)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bw<i1*(1-jl)and not IsRocketOn then IsRocketOn=true;Nav:toggleBoosters()end else i1=i1*ReentrySpeed/3.6;if bw>=i1*(1-jl)and IsRocketOn then IsRocketOn=false;Nav:toggleBoosters()elseif bw<i1*(1-jl)and not IsRocketOn then IsRocketOn=true;Nav:toggleBoosters()end end end end end;function script.onUpdate()if not SetupComplete then local _,bi=coroutine.resume(beginSetup)if bi then SetupComplete=true end else Nav:update()if not b1 and content~=LastContent then system.setScreen(content)end;LastContent=content end end;function script.onActionStart(jo)if jo=="gear"then GearExtended=not GearExtended;if GearExtended then VectorToTarget=false;LockPitch=nil;if Nav.axisCommandManager:getAxisCommandType(0)==1 then Nav.control.cancelCurrentControlMasterMode()end;Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal,0)if(vBooster or hover)and aa==-1 and(j()>0 or ae<ReentryAltitude)then StrongBrakes=planet.gravity*9.80665*n()<LastMaxBrakeInAtmo;if not StrongBrakes and b6>w then K="WARNING: Insufficient Brakes - Attempting landing anyway"end;Reentry=false;AutoTakeoff=false;AltitudeHold=false;BrakeLanding=true;b3=true;GearExtended=false else BrakeIsOn=true;Nav.control.extendLandingGears()Nav.axisCommandManager:setTargetGroundAltitude(LandingGearGroundHeight)end;if A and not BrakeLanding then Nav.control.extendLandingGears()end else if A then Nav.control.retractLandingGears()end;Nav.axisCommandManager:setTargetGroundAltitude(TargetHoverHeight)end elseif jo=="light"then if Nav.control.isAnyHeadlightSwitchedOn()==1 then Nav.control.switchOffHeadlights()else Nav.control.switchOnHeadlights()end elseif jo=="forward"then B=B-1 elseif jo=="backward"then B=B+1 elseif jo=="left"then E=E-1 elseif jo=="right"then E=E+1 elseif jo=="yawright"then F=F-1 elseif jo=="yawleft"then F=F+1 elseif jo=="straferight"then Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.lateral,1.0)elseif jo=="strafeleft"then Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.lateral,-1.0)elseif jo=="up"then Z=Z+1;Nav.axisCommandManager:deactivateGroundEngineAltitudeStabilization()Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.vertical,1.0)elseif jo=="down"then Z=Z-1;Nav.axisCommandManager:deactivateGroundEngineAltitudeStabilization()Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.vertical,-1.0)elseif jo=="groundaltitudeup"then OldButtonMod=M;OldAntiMod=N;if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitude<HoldAltitude+10 and AntigravTargetAltitude>HoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude+N;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude+N end else AntigravTargetAltitude=desiredBaseAltitude+100 end elseif AltitudeHold then HoldAltitude=HoldAltitude+M else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(1.0)end elseif jo=="groundaltitudedown"then OldButtonMod=M;OldAntiMod=N;if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitude<HoldAltitude+10 and AntigravTargetAltitude>HoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude-N;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude-N;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end end else AntigravTargetAltitude=desiredBaseAltitude end elseif AltitudeHold then HoldAltitude=HoldAltitude-M else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(-1.0)end elseif jo=="option1"then IncrementAutopilotTargetIndex()v=false elseif jo=="option2"then DecrementAutopilotTargetIndex()v=false elseif jo=="option3"then if hideHudOnToggleWidgets then if showHud then showHud=false else showHud=true end end;v=false;ToggleWidgets()elseif jo=="option4"then ToggleAutopilot()v=false elseif jo=="option5"then ToggleLockPitch()v=false elseif jo=="option6"then ToggleAltitudeHold()v=false elseif jo=="option7"then wipeSaveVariables()v=false elseif jo=="option8"then ToggleFollowMode()v=false elseif jo=="option9"then if gyro~=nil then gyro.toggle()ah=gyro.getState()==1 end;v=false elseif jo=="lshift"then if system.isViewLocked()==1 then J=true;PrevViewLock=system.isViewLocked()system.lockView(1)elseif o()==1 and ShiftShowsRemoteButtons then J=true;b2=false;b1=false end elseif jo=="brake"then if BrakeToggleStatus then BrakeToggle()elseif not BrakeIsOn then BrakeToggle()else BrakeIsOn=true end elseif jo=="lalt"then if o()==0 and not freeLookToggle and userControlScheme=="keyboard"then system.lockView(1)end elseif jo=="booster"then if VanillaRockets then Nav:toggleBoosters()elseif not O then if not IsRocketOn then Nav:toggleBoosters()IsRocketOn=true end;O=true else if IsRocketOn then Nav:toggleBoosters()IsRocketOn=false end;O=false end elseif jo=="stopengines"then Nav.axisCommandManager:resetCommand(axisCommandId.longitudinal)clearAll()elseif jo=="speedup"then if not J then Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal,speedChangeLarge)else IncrementAutopilotTargetIndex()end elseif jo=="speeddown"then if not J then Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal,-speedChangeLarge)else DecrementAutopilotTargetIndex()end elseif jo=="antigravity"and not ExternalAGG then if antigrav~=nil then ToggleAntigrav()end end end;function script.onActionStop(jo)if jo=="forward"then B=0 elseif jo=="backward"then B=0 elseif jo=="left"then E=0 elseif jo=="right"then E=0 elseif jo=="yawright"then F=0 elseif jo=="yawleft"then F=0 elseif jo=="straferight"then Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral,-1.0)elseif jo=="strafeleft"then Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral,1.0)elseif jo=="up"then Z=0;Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical,-1.0)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(currentGroundAltitudeStabilization)Nav:setEngineForceCommand('hover',vec3(),1)elseif jo=="down"then Z=0;Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical,1.0)Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(currentGroundAltitudeStabilization)Nav:setEngineForceCommand('hover',vec3(),1)elseif jo=="groundaltitudeup"then if antigrav and not ExternalAGG and antigrav.getState()==1 then N=OldAntiMod end;if AltitudeHold then M=OldButtonMod end;v=false elseif jo=="groundaltitudedown"then if antigrav and not ExternalAGG and antigrav.getState()==1 then N=OldAntiMod end;if AltitudeHold then M=OldButtonMod end;v=false elseif jo=="lshift"then if system.isViewLocked()==1 then J=false;a0=0;a1=0;system.lockView(PrevViewLock)elseif o()==1 and ShiftShowsRemoteButtons then J=false;b2=false;b1=false end elseif jo=="brake"then if not BrakeToggleStatus then if BrakeIsOn then BrakeToggle()else BrakeIsOn=false end end elseif jo=="lalt"then if o()==0 and freeLookToggle then if v then if system.isViewLocked()==1 then system.lockView(0)else system.lockView(1)end else v=true end elseif o()==0 and not freeLookToggle and userControlScheme=="keyboard"then system.lockView(0)end end end;function script.onActionLoop(jo)if jo=="groundaltitudeup"then if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitude<HoldAltitude+10 and AntigravTargetAltitude>HoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude+N;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude+N end;N=N*1.05;BrakeIsOn=false else AntigravTargetAltitude=desiredBaseAltitude+100;BrakeIsOn=false end elseif AltitudeHold then HoldAltitude=HoldAltitude+M;M=M*1.05 else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(1.0)end elseif jo=="groundaltitudedown"then if antigrav and not ExternalAGG and antigrav.getState()==1 then if AntigravTargetAltitude~=nil then if AltitudeHold and AntigravTargetAltitude<HoldAltitude+10 and AntigravTargetAltitude>HoldAltitude-10 then AntigravTargetAltitude=AntigravTargetAltitude-N;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end;HoldAltitude=AntigravTargetAltitude else AntigravTargetAltitude=AntigravTargetAltitude-N;if AntigravTargetAltitude<1000 then AntigravTargetAltitude=1000 end end;N=N*1.05;BrakeIsOn=false else AntigravTargetAltitude=desiredBaseAltitude-100;BrakeIsOn=false end elseif AltitudeHold then HoldAltitude=HoldAltitude-M;M=M*1.05 else Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(-1.0)end elseif jo=="speedup"then if not J then Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal,speedChangeSmall)end elseif jo=="speeddown"then if not J then Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal,-speedChangeSmall)end end end;function script.onInputText(jp)local i;local jq="/commands /setname /G /agg /addlocation /copydatabank"local jr,js=nil,nil;local jt="Command List:\n/commands \n/setname <newname> - Updates current selected saved position name\n/G VariableName newValue - Updates global variable to new value\n".."/G dump - shows all updatable variables with /G\n/agg <targetheight> - Manually set agg target height\n".."/addlocation savename ::pos{0,2,46.4596,-155.1799,22.6572} - adds a saved location by waypoint, not as accurate as making one at location\n".."/copydatabank - copies dbHud databank to a blank databank"i=string.find(jp," ")jr=jp;if i~=nil then jr=string.sub(jp,0,i-1)js=string.sub(jp,i+1)elseif not string.find(jq,jr)then for fy in string.gmatch(jt,"([^\n]+)")do c(fy)end;return end;if jr=="/setname"then if js==nil or js==""then K="Usage: /setname Newname"return end;if AutopilotTargetIndex>0 and CustomTarget~=nil then UpdatePosition(js)else K="Select a saved target to rename first"end elseif jr=="/addlocation"then if js==nil or js==""or string.find(js,"::")==nil then K="Usage: /addlocation savename ::pos{0,2,46.4596,-155.1799,22.6572}"return end;i=string.find(js,"::")local c0=string.sub(js,1,i-2)local bV=string.sub(js,i)local p=' *([+-]?%d+%.?%d*e?[+-]?%d*)'local bW='::pos{'..p..','..p..','..p..','..p..','..p..'}'local bX,bY,bS,bT,bR=string.match(bV,bW)local planet=aS[tonumber(bX)][tonumber(bY)]AddNewLocationByWaypoint(c0,planet,bV)K="Added "..c0 .." to saved locations,\nplanet "..planet.name.." at "..bV;a2=5 elseif jr=="/agg"then if js==nil or js==""then K="Usage: /agg targetheight"return end;js=tonumber(js)if js<1000 then js=1000 end;AntigravTargetAltitude=js;K="AGG Target Height set to "..js elseif jr=="/G"then if js==nil or js==""then K="Usage: /G VariableName variablevalue\n/G dump - shows all variables"return end;if js=="dump"then for bg,bh in pairs(a)do if type(_G[bh])=="boolean"then if _G[bh]==true then c(bh.." true")else c(bh.." false")end elseif _G[bh]==nil then c(bh.." nil")else c(bh.." ".._G[bh])end end;return end;i=string.find(js," ")local ju=string.sub(js,0,i-1)local jv=string.sub(js,i+1)for bg,bh in pairs(a)do if bh==ju then K="Variable "..ju.." changed to "..jv;local jw=type(_G[bh])if jw=="number"then jv=tonumber(jv)elseif jw=="boolean"then if string.lower(jv)=="true"then jv=true else jv=false end end;_G[bh]=jv;return end end;K="No such global variable: "..ju elseif jr=="/copydatabank"then if dbHud_2 then SaveDataBank(true)else K="Databank required to copy databank"end end 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
inputText(text):
lua: |
if not __wrap_lua__stopped and script.onInputText then
local ok, message = xpcall(script.onInputText,__wrap_lua__traceback,text,system)
if not ok then __wrap_lua__error(message) end
end