···11+# This is a file describing a standard autoconfiguration, do not edit.
22+# See custom/sample.conf for a more generic template and explanation on the syntax.
33+44+name: ui_cu_autoconf_pvp_ecu
55+66+slots:
77+ core:
88+ class: CoreUnit
99+ antigrav:
1010+ class: AntiGravityGeneratorUnit
1111+ container:
1212+ class: FuelContainer
1313+ select: all
1414+ gyro:
1515+ class: GyroUnit
1616+1717+handlers:
1818+ unit:
1919+ start:
2020+ lua: |
2121+ Nav = Navigator.new(system, core, unit)
2222+ planetInfluenceThreshold = 0.6
2323+ if antigrav ~= nil then
2424+ antigrav.activate()
2525+ antigrav.show()
2626+ end
2727+ system:
2828+ flush:
2929+ lua: |
3030+ local verticalAutoLandingSpeed = 20 --export: Vertical auto landing speec in km/h
3131+ local power = 3
3232+ local worldUp = vec3(core.getConstructWorldOrientationUp())
3333+ local worldForward = vec3(core.getConstructWorldOrientationForward())
3434+ local worldRight = vec3(core.getConstructWorldOrientationRight())
3535+ local worldVertical = vec3(core.getWorldVertical())
3636+3737+ -- are we in deep space or are we near a planet ?
3838+ local planetInfluence = Nav.control.getClosestPlanetInfluence()
3939+ if planetInfluence > 0
4040+ then
4141+ -- stabilize orientation along the gravity
4242+ if (rollPID == nil) then
4343+ rollPID = pid.new(0.2, 0, 10)
4444+ pitchPID = pid.new(0.2, 0, 10)
4545+ end
4646+4747+ local yawVelocity = vec3(core.getWorldAngularVelocity()):dot(worldUp)
4848+ local currentRoll = getRoll(worldVertical, worldForward, worldRight)
4949+ local currentPitch = -math.asin(worldForward:dot(worldVertical)) * constants.rad2deg
5050+ rollPID:inject(-currentRoll)
5151+ pitchPID:inject(-currentPitch)
5252+ local yawAcceleration = - power * yawVelocity
5353+ angularAcceleration = rollPID:get() * worldForward + pitchPID:get() * worldRight + yawAcceleration * worldUp
5454+ else
5555+ -- cancel rotation
5656+ local worldAngularVelocity = vec3(core.getWorldAngularVelocity())
5757+ angularAcceleration = - power * worldAngularVelocity
5858+ end
5959+6060+ if planetInfluence > planetInfluenceThreshold
6161+ then
6262+ -- go down at verticalTargetSpeed when very close to a planet
6363+ targetVelocity = (verticalAutoLandingSpeed / 3.6) * worldVertical
6464+ else
6565+ -- immobilize ship when not
6666+ targetVelocity = vec3()
6767+ end
6868+ Nav:setEngineCommand('torque', vec3(), angularAcceleration)
6969+ stabilization = power * (targetVelocity - vec3(core.getWorldVelocity()))
7070+ Nav:setEngineCommand('vertical, brake, horizontal', stabilization -vec3(core.getWorldGravity()), vec3(), false)
7171+ update:
7272+ lua: |
7373+ local accelThreshold = 0.1
7474+ local speedThreshold = 0.1
7575+7676+ -- auto stopping mechanism when immobile and close to planet
7777+ local accel = vec3(Nav.core.getWorldAcceleration()):len()
7878+ local speed = vec3(Nav.core.getWorldVelocity()):len()
7979+ if accel < accelThreshold
8080+ and speed < speedThreshold
8181+ and Nav.control.getClosestPlanetInfluence() > planetInfluenceThreshold
8282+ then
8383+ unit.exit()
8484+ end
+431
conf/flying_construct.conf
···11+# This is a file describing a standard autoconfiguration, do not edit.
22+# See custom/sample.conf for a more generic template and explanation on the syntax.
33+44+name: ui_cu_autoconf_construct_flying
55+66+slots:
77+ core:
88+ class: CoreUnit
99+ antigrav:
1010+ class: AntiGravityGeneratorUnit
1111+ warpdrive:
1212+ class: WarpDriveUnit
1313+ atmofueltank:
1414+ class: AtmoFuelContainer
1515+ select: all
1616+ spacefueltank:
1717+ class: SpaceFuelContainer
1818+ select: all
1919+ rocketfueltank:
2020+ class: RocketFuelContainer
2121+ select: all
2222+ gyro:
2323+ class: GyroUnit
2424+ shield:
2525+ class: ShieldGeneratorUnit
2626+ weapon:
2727+ class: WeaponUnit
2828+ select: manual
2929+ radar:
3030+ class: RadarPVPUnit
3131+ select: manual
3232+3333+handlers:
3434+ unit:
3535+ start:
3636+ lua: |
3737+ pitchInput = 0
3838+ rollInput = 0
3939+ yawInput = 0
4040+ brakeInput = 0
4141+4242+ Nav = Navigator.new(system, core, unit)
4343+ Nav.axisCommandManager:setupCustomTargetSpeedRanges(axisCommandId.longitudinal, {1000, 5000, 10000, 20000, 30000})
4444+ Nav.axisCommandManager:setTargetGroundAltitude(4)
4545+4646+ -- Parenting widget
4747+ parentingPanelId = system.createWidgetPanel("Docking")
4848+ parentingWidgetId = system.createWidget(parentingPanelId,"parenting")
4949+ system.addDataToWidget(unit.getDataId(),parentingWidgetId)
5050+5151+ -- Combat stress widget
5252+ coreCombatStressPanelId = system.createWidgetPanel("Core combat stress")
5353+ coreCombatStressgWidgetId = system.createWidget(coreCombatStressPanelId,"core_stress")
5454+ system.addDataToWidget(core.getDataId(),coreCombatStressgWidgetId)
5555+5656+ -- element widgets
5757+ -- For now we have to alternate between PVP and non-PVP widgets to have them on the same side.
5858+ _autoconf.displayCategoryPanel(weapon, weapon_size, L_TEXT("ui_lua_widget_weapon", "Weapons"), "weapon", true)
5959+ core.show()
6060+ _autoconf.displayCategoryPanel(radar, radar_size, L_TEXT("ui_lua_widget_periscope", "Periscope"), "periscope")
6161+ placeRadar = true
6262+ if atmofueltank_size > 0 then
6363+ _autoconf.displayCategoryPanel(atmofueltank, atmofueltank_size, L_TEXT("ui_lua_widget_atmofuel", "Atmo Fuel"), "fuel_container")
6464+ if placeRadar then
6565+ _autoconf.displayCategoryPanel(radar, radar_size, L_TEXT("ui_lua_widget_radar", "Radar"), "radar")
6666+ placeRadar = false
6767+ end
6868+ end
6969+ if spacefueltank_size > 0 then
7070+ _autoconf.displayCategoryPanel(spacefueltank, spacefueltank_size, L_TEXT("ui_lua_widget_spacefuel", "Space Fuel"), "fuel_container")
7171+ if placeRadar then
7272+ _autoconf.displayCategoryPanel(radar, radar_size, L_TEXT("ui_lua_widget_radar", "Radar"), "radar")
7373+ placeRadar = false
7474+ end
7575+ end
7676+ _autoconf.displayCategoryPanel(rocketfueltank, rocketfueltank_size, L_TEXT("ui_lua_widget_rocketfuel", "Rocket Fuel"), "fuel_container")
7777+ if placeRadar then -- We either have only rockets or no fuel tanks at all, uncommon for usual vessels
7878+ _autoconf.displayCategoryPanel(radar, radar_size, L_TEXT("ui_lua_widget_radar", "Radar"), "radar")
7979+ placeRadar = false
8080+ end
8181+ if antigrav ~= nil then antigrav.show() end
8282+ if warpdrive ~= nil then warpdrive.show() end
8383+ if gyro ~= nil then gyro.show() end
8484+ if shield ~= nil then shield.show() end
8585+8686+ -- freeze the player in he is remote controlling the construct
8787+ if Nav.control.isRemoteControlled() == 1 then
8888+ system.freeze(1)
8989+ end
9090+9191+ -- landing gear
9292+ -- make sure every gears are synchonized with the first
9393+ gearExtended = (Nav.control.isAnyLandingGearExtended() == 1) -- make sure it's a lua boolean
9494+ if gearExtended then
9595+ Nav.control.extendLandingGears()
9696+ else
9797+ Nav.control.retractLandingGears()
9898+ end
9999+ stop:
100100+ lua: |
101101+ _autoconf.hideCategoryPanels()
102102+ if antigrav ~= nil then antigrav.hide() end
103103+ if warpdrive ~= nil then warpdrive.hide() end
104104+ if gyro ~= nil then gyro.hide() end
105105+ core.hide()
106106+ Nav.control.switchOffHeadlights()
107107+108108+ system:
109109+ flush:
110110+ lua: |
111111+ -- constants: use 'myvar = defaultValue --export: description' to expose the variable in context menu
112112+113113+ local pitchSpeedFactor = 0.8 --export: This factor will increase/decrease the player input along the pitch axis<br>(higher value may be unstable)<br>Valid values: Superior or equal to 0.01
114114+ local yawSpeedFactor = 1 --export: This factor will increase/decrease the player input along the yaw axis<br>(higher value may be unstable)<br>Valid values: Superior or equal to 0.01
115115+ local rollSpeedFactor = 1.5 --export: 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
116116+117117+ local brakeSpeedFactor = 3 --export: When braking, this factor will increase the brake force by brakeSpeedFactor * velocity<br>Valid values: Superior or equal to 0.01
118118+ local brakeFlatFactor = 1 --export: 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
119119+120120+ local autoRoll = false --export: [Only in atmosphere]<br>When the pilot stops rolling, flight model will try to get back to horizontal (no roll)
121121+ local autoRollFactor = 2 --export: [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
122122+123123+ local turnAssist = true --export: [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
124124+ local turnAssistFactor = 2 --export: [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
125125+126126+ local torqueFactor = 2 -- Force factor applied to reach rotationSpeed<br>(higher value may be unstable)<br>Valid values: Superior or equal to 0.01
127127+128128+ -- validate params
129129+ pitchSpeedFactor = math.max(pitchSpeedFactor, 0.01)
130130+ yawSpeedFactor = math.max(yawSpeedFactor, 0.01)
131131+ rollSpeedFactor = math.max(rollSpeedFactor, 0.01)
132132+ torqueFactor = math.max(torqueFactor, 0.01)
133133+ brakeSpeedFactor = math.max(brakeSpeedFactor, 0.01)
134134+ brakeFlatFactor = math.max(brakeFlatFactor, 0.01)
135135+ autoRollFactor = math.max(autoRollFactor, 0.01)
136136+ turnAssistFactor = math.max(turnAssistFactor, 0.01)
137137+138138+ -- final inputs
139139+ local finalPitchInput = pitchInput + system.getControlDeviceForwardInput()
140140+ local finalRollInput = rollInput + system.getControlDeviceYawInput()
141141+ local finalYawInput = yawInput - system.getControlDeviceLeftRightInput()
142142+ local finalBrakeInput = brakeInput
143143+144144+ -- Axis
145145+ local worldVertical = vec3(core.getWorldVertical()) -- along gravity
146146+ local constructUp = vec3(core.getConstructWorldOrientationUp())
147147+ local constructForward = vec3(core.getConstructWorldOrientationForward())
148148+ local constructRight = vec3(core.getConstructWorldOrientationRight())
149149+ local constructVelocity = vec3(core.getWorldVelocity())
150150+ local constructVelocityDir = vec3(core.getWorldVelocity()):normalize()
151151+ local currentRollDeg = getRoll(worldVertical, constructForward, constructRight)
152152+ local currentRollDegAbs = math.abs(currentRollDeg)
153153+ local currentRollDegSign = utils.sign(currentRollDeg)
154154+155155+ -- Rotation
156156+ local constructAngularVelocity = vec3(core.getWorldAngularVelocity())
157157+ local targetAngularVelocity = finalPitchInput * pitchSpeedFactor * constructRight
158158+ + finalRollInput * rollSpeedFactor * constructForward
159159+ + finalYawInput * yawSpeedFactor * constructUp
160160+161161+ -- In atmosphere?
162162+ if worldVertical:len() > 0.01 and unit.getAtmosphereDensity() > 0.0 then
163163+ local autoRollRollThreshold = 1.0
164164+ -- autoRoll on AND currentRollDeg is big enough AND player is not rolling
165165+ if autoRoll == true and currentRollDegAbs > autoRollRollThreshold and finalRollInput == 0 then
166166+ local targetRollDeg = utils.clamp(0,currentRollDegAbs-30, currentRollDegAbs+30); -- we go back to 0 within a certain limit
167167+ if (rollPID == nil) then
168168+ rollPID = pid.new(autoRollFactor * 0.01, 0, autoRollFactor * 0.1) -- magic number tweaked to have a default factor in the 1-10 range
169169+ end
170170+ rollPID:inject(targetRollDeg - currentRollDeg)
171171+ local autoRollInput = rollPID:get()
172172+173173+ targetAngularVelocity = targetAngularVelocity + autoRollInput * constructForward
174174+ end
175175+ local turnAssistRollThreshold = 20.0
176176+ -- turnAssist AND currentRollDeg is big enough AND player is not pitching or yawing
177177+ if turnAssist == true and currentRollDegAbs > turnAssistRollThreshold and finalPitchInput == 0 and finalYawInput == 0 then
178178+ local rollToPitchFactor = turnAssistFactor * 0.1 -- magic number tweaked to have a default factor in the 1-10 range
179179+ local rollToYawFactor = turnAssistFactor * 0.025 -- magic number tweaked to have a default factor in the 1-10 range
180180+181181+ -- rescale (turnAssistRollThreshold -> 180) to (0 -> 180)
182182+ local rescaleRollDegAbs = ((currentRollDegAbs - turnAssistRollThreshold) / (180 - turnAssistRollThreshold)) * 180
183183+ local rollVerticalRatio = 0
184184+ if rescaleRollDegAbs < 90 then
185185+ rollVerticalRatio = rescaleRollDegAbs / 90
186186+ elseif rescaleRollDegAbs < 180 then
187187+ rollVerticalRatio = (180 - rescaleRollDegAbs) / 90
188188+ end
189189+190190+ rollVerticalRatio = rollVerticalRatio * rollVerticalRatio
191191+192192+ local turnAssistYawInput = - currentRollDegSign * rollToYawFactor * (1.0 - rollVerticalRatio)
193193+ local turnAssistPitchInput = rollToPitchFactor * rollVerticalRatio
194194+195195+ targetAngularVelocity = targetAngularVelocity
196196+ + turnAssistPitchInput * constructRight
197197+ + turnAssistYawInput * constructUp
198198+ end
199199+ end
200200+201201+ -- Engine commands
202202+ local keepCollinearity = 1 -- for easier reading
203203+ local dontKeepCollinearity = 0 -- for easier reading
204204+ local tolerancePercentToSkipOtherPriorities = 1 -- if we are within this tolerance (in%), we don't go to the next priorities
205205+206206+ -- Rotation
207207+ local angularAcceleration = torqueFactor * (targetAngularVelocity - constructAngularVelocity)
208208+ local airAcceleration = vec3(core.getWorldAirFrictionAngularAcceleration())
209209+ angularAcceleration = angularAcceleration - airAcceleration -- Try to compensate air friction
210210+ Nav:setEngineTorqueCommand('torque', angularAcceleration, keepCollinearity, 'airfoil', '', '', tolerancePercentToSkipOtherPriorities)
211211+212212+ -- Brakes
213213+ local brakeAcceleration = -finalBrakeInput * (brakeSpeedFactor * constructVelocity + brakeFlatFactor * constructVelocityDir)
214214+ Nav:setEngineForceCommand('brake', brakeAcceleration)
215215+216216+ -- AutoNavigation regroups all the axis command by 'TargetSpeed'
217217+ local autoNavigationEngineTags = ''
218218+ local autoNavigationAcceleration = vec3()
219219+ local autoNavigationUseBrake = false
220220+221221+ -- Longitudinal Translation
222222+ local longitudinalEngineTags = 'thrust analog longitudinal'
223223+ local longitudinalCommandType = Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)
224224+ if (longitudinalCommandType == axisCommandType.byThrottle) then
225225+ local longitudinalAcceleration = Nav.axisCommandManager:composeAxisAccelerationFromThrottle(longitudinalEngineTags,axisCommandId.longitudinal)
226226+ Nav:setEngineForceCommand(longitudinalEngineTags, longitudinalAcceleration, keepCollinearity)
227227+ elseif (longitudinalCommandType == axisCommandType.byTargetSpeed) then
228228+ local longitudinalAcceleration = Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.longitudinal)
229229+ autoNavigationEngineTags = autoNavigationEngineTags .. ' , ' .. longitudinalEngineTags
230230+ autoNavigationAcceleration = autoNavigationAcceleration + longitudinalAcceleration
231231+ if (Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal) == 0 or -- we want to stop
232232+ Nav.axisCommandManager:getCurrentToTargetDeltaSpeed(axisCommandId.longitudinal) < - Nav.axisCommandManager:getTargetSpeedCurrentStep(axisCommandId.longitudinal) * 0.5) -- if the longitudinal velocity would need some braking
233233+ then
234234+ autoNavigationUseBrake = true
235235+ end
236236+237237+ end
238238+239239+ -- Lateral Translation
240240+ local lateralStrafeEngineTags = 'thrust analog lateral'
241241+ local lateralCommandType = Nav.axisCommandManager:getAxisCommandType(axisCommandId.lateral)
242242+ if (lateralCommandType == axisCommandType.byThrottle) then
243243+ local lateralStrafeAcceleration = Nav.axisCommandManager:composeAxisAccelerationFromThrottle(lateralStrafeEngineTags,axisCommandId.lateral)
244244+ Nav:setEngineForceCommand(lateralStrafeEngineTags, lateralStrafeAcceleration, keepCollinearity)
245245+ elseif (lateralCommandType == axisCommandType.byTargetSpeed) then
246246+ local lateralAcceleration = Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.lateral)
247247+ autoNavigationEngineTags = autoNavigationEngineTags .. ' , ' .. lateralStrafeEngineTags
248248+ autoNavigationAcceleration = autoNavigationAcceleration + lateralAcceleration
249249+ end
250250+251251+ -- Vertical Translation
252252+ local verticalStrafeEngineTags = 'thrust analog vertical'
253253+ local verticalCommandType = Nav.axisCommandManager:getAxisCommandType(axisCommandId.vertical)
254254+ if (verticalCommandType == axisCommandType.byThrottle) then
255255+ local verticalStrafeAcceleration = Nav.axisCommandManager:composeAxisAccelerationFromThrottle(verticalStrafeEngineTags,axisCommandId.vertical)
256256+ Nav:setEngineForceCommand(verticalStrafeEngineTags, verticalStrafeAcceleration, keepCollinearity, 'airfoil', 'ground', '', tolerancePercentToSkipOtherPriorities)
257257+ elseif (verticalCommandType == axisCommandType.byTargetSpeed) then
258258+ local verticalAcceleration = Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.vertical)
259259+ autoNavigationEngineTags = autoNavigationEngineTags .. ' , ' .. verticalStrafeEngineTags
260260+ autoNavigationAcceleration = autoNavigationAcceleration + verticalAcceleration
261261+ end
262262+263263+ -- Auto Navigation (Cruise Control)
264264+ if (autoNavigationAcceleration:len() > constants.epsilon) then
265265+ if (brakeInput ~= 0 or autoNavigationUseBrake or math.abs(constructVelocityDir:dot(constructForward)) < 0.95) -- if the velocity is not properly aligned with the forward
266266+ then
267267+ autoNavigationEngineTags = autoNavigationEngineTags .. ', brake'
268268+ end
269269+ Nav:setEngineForceCommand(autoNavigationEngineTags, autoNavigationAcceleration, dontKeepCollinearity, '', '', '', tolerancePercentToSkipOtherPriorities)
270270+ end
271271+272272+ -- Rockets
273273+ Nav:setBoosterCommand('rocket_engine')
274274+275275+ update:
276276+ lua: Nav:update()
277277+278278+ actionStart:
279279+ args: [gear]
280280+ lua: |
281281+ gearExtended = not gearExtended
282282+ if gearExtended then
283283+ Nav.control.extendLandingGears()
284284+ else
285285+ Nav.control.retractLandingGears()
286286+ end
287287+288288+ actionStart:
289289+ args: [light]
290290+ lua: |
291291+ if Nav.control.isAnyHeadlightSwitchedOn() == 1 then
292292+ Nav.control.switchOffHeadlights()
293293+ else
294294+ Nav.control.switchOnHeadlights()
295295+ end
296296+297297+ actionStart:
298298+ args: [forward]
299299+ lua: pitchInput = pitchInput - 1
300300+ actionStop:
301301+ args: [forward]
302302+ lua: pitchInput = pitchInput + 1
303303+ actionStart:
304304+ args: [backward]
305305+ lua: pitchInput = pitchInput + 1
306306+ actionStop:
307307+ args: [backward]
308308+ lua: pitchInput = pitchInput - 1
309309+ actionStart:
310310+ args: [left]
311311+ lua: rollInput = rollInput - 1
312312+ actionStop:
313313+ args: [left]
314314+ lua: rollInput = rollInput + 1
315315+ actionStart:
316316+ args: [right]
317317+ lua: rollInput = rollInput + 1
318318+ actionStop:
319319+ args: [right]
320320+ lua: rollInput = rollInput - 1
321321+322322+ actionStart:
323323+ args: [straferight]
324324+ lua: Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.lateral, 1.0)
325325+ actionStop:
326326+ args: [straferight]
327327+ lua: Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral, -1.0)
328328+329329+ actionStart:
330330+ args: [strafeleft]
331331+ lua: Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.lateral, -1.0)
332332+ actionStop:
333333+ args: [strafeleft]
334334+ lua: Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral, 1.0)
335335+336336+ actionStart:
337337+ args: [up]
338338+ lua: |
339339+ Nav.axisCommandManager:deactivateGroundEngineAltitudeStabilization()
340340+ Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.vertical, 1.0)
341341+ actionStop:
342342+ args: [up]
343343+ lua: |
344344+ Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical, -1.0)
345345+ Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(currentGroundAltitudeStabilization)
346346+ actionStart:
347347+ args: [down]
348348+ lua: |
349349+ Nav.axisCommandManager:deactivateGroundEngineAltitudeStabilization()
350350+ Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.vertical, -1.0)
351351+ actionStop:
352352+ args: [down]
353353+ lua: |
354354+ Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical, 1.0)
355355+ Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(currentGroundAltitudeStabilization)
356356+357357+ actionStart:
358358+ args: [groundaltitudeup]
359359+ lua: Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(1.0)
360360+361361+ actionLoop:
362362+ args: [groundaltitudeup]
363363+ lua: Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(1.0)
364364+365365+366366+ actionStart:
367367+ args: [groundaltitudedown]
368368+ lua: Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(-1.0)
369369+370370+ actionLoop:
371371+ args: [groundaltitudedown]
372372+ lua: Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(-1.0)
373373+374374+ actionStart:
375375+ args: [yawright]
376376+ lua: yawInput = yawInput - 1
377377+ actionStop:
378378+ args: [yawright]
379379+ lua: yawInput = yawInput + 1
380380+ actionStart:
381381+ args: [yawleft]
382382+ lua: yawInput = yawInput + 1
383383+ actionStop:
384384+ args: [yawleft]
385385+ lua: yawInput = yawInput - 1
386386+ actionStart:
387387+ args: [brake]
388388+ lua: |
389389+ brakeInput = brakeInput + 1
390390+ local longitudinalCommandType = Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)
391391+ if (longitudinalCommandType == axisCommandType.byTargetSpeed) then
392392+ local targetSpeed = Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)
393393+ if (math.abs(targetSpeed) > constants.epsilon) then
394394+ Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal, - utils.sign(targetSpeed))
395395+ end
396396+ end
397397+ actionStop:
398398+ args: [brake]
399399+ lua: brakeInput = brakeInput - 1
400400+401401+ actionLoop:
402402+ args: [brake]
403403+ lua: |
404404+ local longitudinalCommandType = Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)
405405+ if (longitudinalCommandType == axisCommandType.byTargetSpeed) then
406406+ local targetSpeed = Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)
407407+ if (math.abs(targetSpeed) > constants.epsilon) then
408408+ Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal, - utils.sign(targetSpeed))
409409+ end
410410+ end
411411+ actionStart:
412412+ args: [booster]
413413+ lua: Nav:toggleBoosters()
414414+ actionStart:
415415+ args: [stopengines]
416416+ lua: Nav.axisCommandManager:resetCommand(axisCommandId.longitudinal)
417417+ actionStart:
418418+ args: [speedup]
419419+ lua: Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal, 5.0)
420420+ actionLoop:
421421+ args: [speedup]
422422+ lua: Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal, 1.0)
423423+ actionStart:
424424+ args: [speeddown]
425425+ lua: Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal, -5.0)
426426+ actionLoop:
427427+ args: [speeddown]
428428+ lua: Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal, -1.0)
429429+ actionStart:
430430+ args: [antigravity]
431431+ lua: if antigrav ~= nil then antigrav.toggle() end
+557
conf/ground_construct.conf
···11+# This is a file describing a standard autoconfiguration, do not edit.
22+# See custom/sample.conf for a more generic template and explanation on the syntax.
33+44+name: ui_cu_autoconf_construct_ground
55+66+slots:
77+ core:
88+ class: CoreUnit
99+ antigrav:
1010+ class: AntiGravityGeneratorUnit
1111+ atmofueltank:
1212+ class: AtmoFuelContainer
1313+ select: all
1414+ spacefueltank:
1515+ class: SpaceFuelContainer
1616+ select: all
1717+ rocketfueltank:
1818+ class: RocketFuelContainer
1919+ select: all
2020+ gyro:
2121+ class: GyroUnit
2222+ weapon:
2323+ class: WeaponUnit
2424+ select: manual
2525+ radar:
2626+ class: RadarPVPUnit
2727+ select: manual
2828+2929+handlers:
3030+ unit:
3131+ start:
3232+ lua: |
3333+ pitchInput = 0
3434+ pitchInputFromDevice = 0
3535+ rollInput = 0
3636+ yawInput = 0
3737+ verticalStrafeInput = 0
3838+ lateralStrafeInput = 0
3939+ brakeInput = 0
4040+ goingBack = false
4141+ goingForward = false
4242+ shiftPressed = false
4343+ jumpDelta = 0
4444+ baseAcceleration = 0.8 --export: Acceleration provided when 'forward' is hit, expressed in g
4545+4646+ Nav = Navigator.new(system, core, unit)
4747+ Nav.axisCommandManager:setupCustomTargetSpeedRanges(axisCommandId.longitudinal, {100, 500, 1000, 5000})
4848+ Nav.axisCommandManager:setTargetGroundAltitude(6)
4949+5050+ -- Parenting widget
5151+ parentingPanelId = system.createWidgetPanel("Docking")
5252+ parentingWidgetId = system.createWidget(parentingPanelId,"parenting")
5353+ system.addDataToWidget(unit.getDataId(),parentingWidgetId)
5454+5555+ -- Combat stress widget
5656+ coreCombatStressPanelId = system.createWidgetPanel("Core combat stress")
5757+ coreCombatStressgWidgetId = system.createWidget(coreCombatStressPanelId,"core_stress")
5858+ system.addDataToWidget(core.getDataId(),coreCombatStressgWidgetId)
5959+6060+ -- element widgets
6161+ -- For now we have to alternate between PVP and non-PVP widgets to have them on the same side.
6262+ _autoconf.displayCategoryPanel(weapon, weapon_size, L_TEXT("ui_lua_widget_weapon", "Weapons"), "weapon", true)
6363+ core.show()
6464+ _autoconf.displayCategoryPanel(radar, radar_size, L_TEXT("ui_lua_widget_periscope", "Periscope"), "periscope")
6565+ placeRadar = true
6666+ if atmofueltank_size > 0 then
6767+ _autoconf.displayCategoryPanel(atmofueltank, atmofueltank_size, L_TEXT("ui_lua_widget_atmofuel", "Atmo Fuel"), "fuel_container")
6868+ if placeRadar then
6969+ _autoconf.displayCategoryPanel(radar, radar_size, L_TEXT("ui_lua_widget_radar", "Radar"), "radar")
7070+ placeRadar = false
7171+ end
7272+ end
7373+ if spacefueltank_size > 0 then
7474+ _autoconf.displayCategoryPanel(spacefueltank, spacefueltank_size, L_TEXT("ui_lua_widget_spacefuel", "Space Fuel"), "fuel_container")
7575+ if placeRadar then
7676+ _autoconf.displayCategoryPanel(radar, radar_size, L_TEXT("ui_lua_widget_radar", "Radar"), "radar")
7777+ placeRadar = false
7878+ end
7979+ end
8080+ _autoconf.displayCategoryPanel(rocketfueltank, rocketfueltank_size, L_TEXT("ui_lua_widget_rocketfuel", "Rocket Fuel"), "fuel_container")
8181+ if placeRadar then -- We either have only rockets or no fuel tanks at all, uncommon for usual vessels
8282+ _autoconf.displayCategoryPanel(radar, radar_size, L_TEXT("ui_lua_widget_radar", "Radar"), "radar")
8383+ placeRadar = false
8484+ end
8585+ if antigrav ~= nil then antigrav.show() end
8686+ if gyro ~= nil then gyro.show() end
8787+8888+ throttleStep = 0.25 --export: When pressing the SpeedUp/SpeedDown buttons, this step will be using to increment/decrement the throttle<br>Valid values: From 0.01 to 1
8989+ throttleStep = utils.clamp(throttleStep, 0.01, 1)
9090+9191+ -- freeze the player in he is remote controlling the construct
9292+ if Nav.control.isRemoteControlled() == 1 then
9393+ system.freeze(1)
9494+ end
9595+9696+ -- landing gear
9797+ -- make sure every gears are synchonized with the first
9898+ gearExtended = (Nav.control.isAnyLandingGearExtended() == 1) -- make sure it's a lua boolean
9999+ if gearExtended then
100100+ Nav.control.extendLandingGears()
101101+ else
102102+ Nav.control.retractLandingGears()
103103+ end
104104+105105+ -- forward/backward functions
106106+ startForward = function ()
107107+ if Nav:isTravelMode() then
108108+ brakeInput = 0
109109+ local throttle = 1
110110+ if not shiftPressed then
111111+ local maxGForward = Nav:maxForceForward() / (self.core.getConstructMass() * 9.81)
112112+ throttle = utils.clamp(baseAcceleration / maxGForward, 0, 1)
113113+ end
114114+115115+ Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal, throttle)
116116+ goingForward = true
117117+ end
118118+ end
119119+120120+ stopForward = function ()
121121+ if Nav:isTravelMode() then
122122+ pitchInput = 0
123123+ Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal, 0)
124124+ brakeInput = 0.5
125125+ goingForward = false
126126+ if goingBackward then
127127+ startBackward()
128128+ end
129129+ end
130130+ end
131131+132132+ direction = {forward=1, backward = -1}
133133+ loopDirection = function (direction)
134134+ if Nav:isTravelMode() then
135135+ local currentVelocity = vec3(self.core.getVelocity())
136136+ local axisCRefDirection = vec3(self.core.getConstructOrientationForward())
137137+138138+ lastCurrentSpeed = currentVelocity:dot(axisCRefDirection)
139139+140140+ if (lastCurrentSpeed * direction < 0) then
141141+ brakeInput = 1
142142+ autobrake = true
143143+ else
144144+ if autobrake == true then
145145+ autobrake = false
146146+ brakeInput = 0
147147+ end
148148+ end
149149+ else
150150+ Nav.axisCommandManager.axisCommands[axisCommandId.longitudinal]:updateCommandFromActionLoop(direction)
151151+ end
152152+ end
153153+154154+ startBackward = function ()
155155+ if Nav:isTravelMode() then
156156+ pitchInput = 0
157157+ brakeInput = 0
158158+159159+ local maxGBackward = Nav:maxForceBackward() / (self.core.getConstructMass() * 9.81)
160160+ local throttle = utils.clamp(baseAcceleration / maxGBackward, -1, 0)
161161+162162+ Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal, throttle)
163163+ goingBack = true
164164+ end
165165+ end
166166+167167+ stopBackward = function ()
168168+ if Nav:isTravelMode() then
169169+ pitchInput = 0
170170+ Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal, 0)
171171+ brakeInput = 0.5
172172+ goingBack = false
173173+ if goingForward then
174174+ startForward()
175175+ end
176176+ end
177177+ end
178178+179179+ stop:
180180+ lua: |
181181+ _autoconf.hideCategoryPanels()
182182+ if antigrav ~= nil then antigrav.hide() end
183183+ if gyro ~= nil then gyro.hide() end
184184+ core.hide()
185185+ Nav.control.switchOffHeadlights()
186186+187187+ system:
188188+ flush:
189189+ lua: |
190190+ -- constants: use 'myvar = defaultValue --export: description' to expose the variable in context menu<br>in degree<br>Valid values: Superior or equal to 1
191191+ local rollAmplitude = 30 --export: When turning, the auto roll won't go over or under rollAmplitude<br>in degree<br>Valid values: Superior or equal to 1
192192+ local pitchAmplitude = 25 --export: When pitching, the pitch won't go over or under pitchAmplitude (in degree)
193193+ local yawSpeedFactor = 1.5 --export When turning, the inputs will be multiplied by this factor<br>Valid values: Superior or equal to 0.01
194194+ local yawAccelerationFactor = 3 --export: When turning, the yaw response will be multiplied by this factor<br>Valid values: Superior or equal to 0.01
195195+196196+ local lateralAntiDriftFactor = 1 --export: When compensating for drift, this factor will increase/decrease the drift force requested to engines<br>Valid values: Superior or equal to 0.01
197197+ local lateralStrafeFactor = 5 --export: This factor will increase/decrease the player input along the horizontal strafe axis axis<br>Valid values: Superior or equal to 0.01
198198+199199+ local brakeSpeedFactor = 1 --export: When braking, this factor will increase the brake force by brakeSpeedFactor * velocity<br>Valid values: Superior or equal to 0.01
200200+ local brakeFlatFactor = 4 --export: 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
201201+ local autoBrakeSpeed = 15 --export: Auto brake when speed is below that value (in m/s), with no thrust
202202+203203+ -- validate params
204204+ brakeSpeedFactor = math.max(brakeSpeedFactor, 0.01)
205205+ brakeFlatFactor = math.max(brakeFlatFactor, 0.01)
206206+ rollAmplitude = math.max(rollAmplitude, 1)
207207+ pitchAmplitude = math.max(pitchAmplitude, 1)
208208+ yawSpeedFactor = math.max(yawSpeedFactor, 0.01)
209209+ yawAccelerationFactor = math.max(yawAccelerationFactor, 0.01)
210210+211211+ if (rollPID == nil) then
212212+ rollPID = pid.new(0.2, 0, 10)
213213+ pitchPID = pid.new(0.2, 0, 10)
214214+ end
215215+216216+ -- final inputs
217217+ if Nav.control.isMouseDirectControlActivated() then
218218+ -- in direct control, we tweak the pitch to behave inbetween virtual joystick and direct control
219219+ -- this helps a lot for ground construct control
220220+ pitchInputFromDevice = utils.clamp(pitchInputFromDevice + system.getControlDeviceForwardInput() * system.getActionUpdateDeltaTime(), -1.0, 1.0)
221221+ else
222222+ pitchInputFromDevice = system.getControlDeviceForwardInput()
223223+ end
224224+ local finalPitchInput = pitchInput + pitchInputFromDevice
225225+ local finalRollInput = rollInput + system.getControlDeviceYawInput()
226226+ local finalYawInput = yawInput - system.getControlDeviceLeftRightInput()
227227+ local combinedRollYawInput = utils.clamp(finalRollInput - finalYawInput, -1.0, 1.0);
228228+ local finalVerticalStrafeInput = verticalStrafeInput
229229+ local finalLateralStrafeInput = lateralStrafeInput;
230230+ local finalBrakeInput = brakeInput
231231+232232+ -- Axis
233233+ local worldVertical = vec3(core.getWorldVertical())
234234+ local constructUp = vec3(core.getConstructWorldOrientationUp())
235235+ local constructForward = vec3(core.getConstructWorldOrientationForward())
236236+ local constructRight = vec3(core.getConstructWorldOrientationRight())
237237+ local constructVelocity = vec3(core.getWorldVelocity())
238238+ local constructVelocityDir = vec3(core.getWorldVelocity()):normalize()
239239+ local constructAngularVelocity = vec3(core.getWorldAngularVelocity())
240240+ local constructYawVelocity = constructAngularVelocity:dot(constructUp)
241241+242242+ -- Engine commands
243243+ local keepCollinearity = 0 -- for easier reading
244244+ local dontKeepCollinearity = 1 -- for easier reading
245245+ local tolerancePercentToSkipOtherPriorities = 1 -- if we are within this tolerance (in%), we don't go to the next priorities
246246+247247+ -- Rotation
248248+ local currentRollDeg = getRoll(worldVertical, constructForward, constructRight)
249249+ local currentPitchDeg = -math.asin(constructForward:dot(worldVertical)) * constants.rad2deg
250250+ local targetRollDeg = utils.clamp(combinedRollYawInput * rollAmplitude, -rollAmplitude, rollAmplitude)
251251+ local targetPitchDeg = utils.clamp(finalPitchInput * pitchAmplitude, -pitchAmplitude, pitchAmplitude)
252252+ rollPID:inject(targetRollDeg - currentRollDeg)
253253+ pitchPID:inject(targetPitchDeg - currentPitchDeg)
254254+255255+ local constructYawTargetVelocity = -combinedRollYawInput * yawSpeedFactor
256256+ local constructYawTargetAcceleration = yawAccelerationFactor * (constructYawTargetVelocity - constructYawVelocity)
257257+258258+ local constructTargetAngularVelocity = rollPID:get() * constructForward
259259+ + pitchPID:get() * constructRight
260260+ + constructYawTargetAcceleration * constructUp
261261+262262+ Nav:setEngineTorqueCommand('torque', constructTargetAngularVelocity, keepCollinearity, 'airfoil', '', '', tolerancePercentToSkipOtherPriorities)
263263+264264+ -- Brakes
265265+ if (finalBrakeInput == 0 and autoBrakeSpeed > 0 and Nav.axisCommandManager.throttle == 0 and constructVelocity:len() < autoBrakeSpeed) then
266266+ finalBrakeInput = 1
267267+ end
268268+ local brakeAcceleration = -finalBrakeInput * (brakeSpeedFactor * constructVelocity + brakeFlatFactor * constructVelocityDir)
269269+ Nav:setEngineForceCommand('brake', brakeAcceleration)
270270+271271+ -- AutoNavigation regroups all the axis command by 'TargetSpeed'
272272+ local autoNavigationEngineTags = ''
273273+ local autoNavigationAcceleration = vec3()
274274+ local autoNavigationUseBrake = false
275275+276276+ -- Longitudinal Translation
277277+ local longitudinalEngineTags = 'thrust analog longitudinal'
278278+ local longitudinalCommandType = Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)
279279+ if (longitudinalCommandType == axisCommandType.byThrottle) then
280280+ local longitudinalAcceleration = Nav.axisCommandManager:composeAxisAccelerationFromThrottle(longitudinalEngineTags,axisCommandId.longitudinal)
281281+ Nav:setEngineForceCommand(longitudinalEngineTags, longitudinalAcceleration, keepCollinearity)
282282+ elseif (longitudinalCommandType == axisCommandType.byTargetSpeed) then
283283+ local longitudinalAcceleration = Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.longitudinal)
284284+ autoNavigationEngineTags = autoNavigationEngineTags .. ' , ' .. longitudinalEngineTags
285285+ autoNavigationAcceleration = autoNavigationAcceleration + longitudinalAcceleration
286286+ if (Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal) == 0 or -- we want to stop
287287+ Nav.axisCommandManager:getCurrentToTargetDeltaSpeed(axisCommandId.longitudinal) < - Nav.axisCommandManager:getTargetSpeedCurrentStep(axisCommandId.longitudinal) * 0.5) -- if the longitudinal velocity would need some braking
288288+ then
289289+ autoNavigationUseBrake = true
290290+ end
291291+292292+ end
293293+294294+ -- Lateral Translation
295295+ local lateralStrafeEngineTags = 'thrust analog lateral'
296296+ local lateralCommandType = Nav.axisCommandManager:getAxisCommandType(axisCommandId.lateral)
297297+ if (lateralCommandType == axisCommandType.byThrottle) then
298298+ local lateralStrafeAcceleration = Nav.axisCommandManager:composeAxisAccelerationFromThrottle(lateralStrafeEngineTags,axisCommandId.lateral)
299299+ Nav:setEngineForceCommand(lateralStrafeEngineTags, lateralStrafeAcceleration, keepCollinearity)
300300+ elseif (lateralCommandType == axisCommandType.byTargetSpeed) then
301301+ local lateralAcceleration = Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.lateral)
302302+ autoNavigationEngineTags = autoNavigationEngineTags .. ' , ' .. lateralStrafeEngineTags
303303+ autoNavigationAcceleration = autoNavigationAcceleration + lateralAcceleration
304304+ end
305305+306306+ -- Vertical Translation
307307+ local verticalStrafeEngineTags = 'thrust analog vertical'
308308+ local verticalCommandType = Nav.axisCommandManager:getAxisCommandType(axisCommandId.vertical)
309309+ if (verticalCommandType == axisCommandType.byThrottle) then
310310+ local verticalStrafeAcceleration = Nav.axisCommandManager:composeAxisAccelerationFromThrottle(verticalStrafeEngineTags,axisCommandId.vertical)
311311+ Nav:setEngineForceCommand(verticalStrafeEngineTags, verticalStrafeAcceleration, keepCollinearity, 'airfoil', 'ground', '', tolerancePercentToSkipOtherPriorities)
312312+ elseif (verticalCommandType == axisCommandType.byTargetSpeed) then
313313+ local verticalAcceleration = Nav.axisCommandManager:composeAxisAccelerationFromTargetSpeed(axisCommandId.vertical)
314314+ autoNavigationEngineTags = autoNavigationEngineTags .. ' , ' .. verticalStrafeEngineTags
315315+ autoNavigationAcceleration = autoNavigationAcceleration + verticalAcceleration
316316+ end
317317+318318+ -- Auto Navigation (Cruise Control)
319319+ if (autoNavigationAcceleration:len() > constants.epsilon) then
320320+ if (brakeInput ~= 0 or autoNavigationUseBrake or math.abs(constructVelocityDir:dot(constructForward)) < 0.95) -- if the velocity is not properly aligned with the forward
321321+ then
322322+ autoNavigationEngineTags = autoNavigationEngineTags .. ', brake'
323323+ end
324324+ Nav:setEngineForceCommand(autoNavigationEngineTags, autoNavigationAcceleration, dontKeepCollinearity, '', '', '', tolerancePercentToSkipOtherPriorities)
325325+ end
326326+327327+ -- Rockets
328328+ Nav:setBoosterCommand('rocket_engine')
329329+ update:
330330+ lua: |
331331+ Nav:update()
332332+ if system.getThrottleInputFromMouseWheel() ~= 0.0 then
333333+ brakeInput = 0
334334+ end
335335+336336+ if unit.isMouseControlActivated() == 0 then
337337+ local currentVelocity = vec3(self.core.getVelocity())
338338+ local axisCRefDirection = vec3(self.core.getConstructOrientationForward())
339339+ local v = currentVelocity:dot(axisCRefDirection)
340340+ local minv = 20
341341+ local maxPitch = 0.4
342342+ if v < minv or not goingForward then
343343+ pitchInput = 0
344344+ else
345345+ if not goingBack and goingForward then
346346+ pitchInput = utils.clamp((maxPitch/minv) * (v - minv), 0, maxPitch)
347347+ end
348348+ end
349349+ end
350350+351351+ pitchInput = pitchInput + jumpDelta
352352+353353+ actionStart:
354354+ args: [gear]
355355+ lua: |
356356+ gearExtended = not gearExtended
357357+ if gearExtended then
358358+ Nav.control.extendLandingGears()
359359+ else
360360+ Nav.control.retractLandingGears()
361361+ end
362362+363363+ actionStart:
364364+ args: [light]
365365+ lua: |
366366+ if Nav.control.isAnyHeadlightSwitchedOn() == 1 then
367367+ Nav.control.switchOffHeadlights()
368368+ else
369369+ Nav.control.switchOnHeadlights()
370370+ end
371371+372372+ actionLoop:
373373+ args: [backward]
374374+ lua: loopDirection(direction.backward)
375375+376376+ actionStart:
377377+ args: [backward]
378378+ lua: startBackward()
379379+380380+ actionStop:
381381+ args: [backward]
382382+ lua: stopBackward()
383383+384384+ actionLoop:
385385+ args: [forward]
386386+ lua: loopDirection(direction.forward)
387387+388388+ actionStart:
389389+ args: [forward]
390390+ lua: startForward()
391391+392392+ actionStop:
393393+ args: [forward]
394394+ lua: stopForward()
395395+396396+ actionStart:
397397+ args: [lshift]
398398+ lua: |
399399+ shiftPressed = true
400400+ if goingForward then
401401+ Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal, 1)
402402+ end
403403+ actionStop:
404404+ args: [lshift]
405405+ lua: |
406406+ shiftPressed = false
407407+ if goingForward then
408408+ local maxGForward = Nav:maxForceForward() / (self.core.getConstructMass() * 9.81)
409409+ local throttle = utils.clamp(baseAcceleration / maxGForward, 0, 1)
410410+ Nav.axisCommandManager:setThrottleCommand(axisCommandId.longitudinal, throttle)
411411+ end
412412+413413+ actionStart:
414414+ args: [left]
415415+ lua: rollInput = rollInput - 1
416416+ actionStop:
417417+ args: [left]
418418+ lua: rollInput = rollInput + 1
419419+ actionStart:
420420+ args: [right]
421421+ lua: rollInput = rollInput + 1
422422+ actionStop:
423423+ args: [right]
424424+ lua: rollInput = rollInput - 1
425425+426426+ actionStart:
427427+ args: [straferight]
428428+ lua: Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.lateral, 1.0)
429429+ actionStop:
430430+ args: [straferight]
431431+ lua: Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral, -1.0)
432432+433433+ actionStart:
434434+ args: [strafeleft]
435435+ lua: Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.lateral, -1.0)
436436+ actionStop:
437437+ args: [strafeleft]
438438+ lua: Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.lateral, 1.0)
439439+440440+ actionStart:
441441+ args: [up]
442442+ lua: |
443443+ baseAltitude = Nav:getTargetGroundAltitude()
444444+ Nav.axisCommandManager:setTargetGroundAltitude(baseAltitude + 4)
445445+ actionLoop:
446446+ args: [up]
447447+ lua: |
448448+ if unit.isMouseControlActivated() == 0 then
449449+ jumpDelta = utils.clamp(jumpDelta + 0.01, 0, 0.6)
450450+ end
451451+ actionStop:
452452+ args: [up]
453453+ lua: |
454454+ Nav.axisCommandManager:setTargetGroundAltitude(baseAltitude)
455455+ if unit.isMouseControlActivated() == 0 then
456456+ jumpDelta = 0
457457+ end
458458+ actionStart:
459459+ args: [down]
460460+ lua: |
461461+ Nav.axisCommandManager:deactivateGroundEngineAltitudeStabilization()
462462+ Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.vertical, -1.0)
463463+ actionStop:
464464+ args: [down]
465465+ lua: |
466466+ Nav.axisCommandManager:updateCommandFromActionStop(axisCommandId.vertical, 1.0)
467467+ Nav.axisCommandManager:activateGroundEngineAltitudeStabilization(defaultGroundAltitudeStabilization)
468468+469469+ actionStart:
470470+ args: [groundaltitudeup]
471471+ lua: Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(1.0)
472472+473473+ actionLoop:
474474+ args: [groundaltitudeup]
475475+ lua: |
476476+ Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(1.0)
477477+ jumpDelta = 0
478478+479479+ actionStart:
480480+ args: [groundaltitudedown]
481481+ lua: Nav.axisCommandManager:updateTargetGroundAltitudeFromActionStart(-1.0)
482482+483483+ actionLoop:
484484+ args: [groundaltitudedown]
485485+ lua: Nav.axisCommandManager:updateTargetGroundAltitudeFromActionLoop(-1.0)
486486+ actionStart:
487487+ args: [yawright]
488488+ lua: yawInput = yawInput - 1
489489+ actionStop:
490490+ args: [yawright]
491491+ lua: yawInput = yawInput + 1
492492+ actionStart:
493493+ args: [yawleft]
494494+ lua: yawInput = yawInput + 1
495495+ actionStop:
496496+ args: [yawleft]
497497+ lua: yawInput = yawInput - 1
498498+ actionStart:
499499+ args: [brake]
500500+ lua: |
501501+ brakeInput = brakeInput + 1
502502+ local longitudinalCommandType = Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)
503503+ if (longitudinalCommandType == axisCommandType.byTargetSpeed) then
504504+ local targetSpeed = Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)
505505+ if (math.abs(targetSpeed) > constants.epsilon) then
506506+ Nav.axisCommandManager:updateCommandFromActionStart(axisCommandId.longitudinal, - utils.sign(targetSpeed))
507507+ end
508508+ end
509509+ actionStop:
510510+ args: [brake]
511511+ lua: brakeInput = 0
512512+513513+ actionLoop:
514514+ args: [brake]
515515+ lua: |
516516+ local longitudinalCommandType = Nav.axisCommandManager:getAxisCommandType(axisCommandId.longitudinal)
517517+ if (longitudinalCommandType == axisCommandType.byTargetSpeed) then
518518+ local targetSpeed = Nav.axisCommandManager:getTargetSpeed(axisCommandId.longitudinal)
519519+ if (math.abs(targetSpeed) > constants.epsilon) then
520520+ Nav.axisCommandManager:updateCommandFromActionLoop(axisCommandId.longitudinal, - utils.sign(targetSpeed))
521521+ end
522522+ end
523523+ actionStart:
524524+ args: [booster]
525525+ lua: Nav:toggleBoosters()
526526+ actionStart:
527527+ args: [stopengines]
528528+ lua: Nav.axisCommandManager:resetCommand(axisCommandId.longitudinal)
529529+530530+ actionLoop:
531531+ args: [speedup]
532532+ lua: loopDirection(direction.forward)
533533+534534+ actionStart:
535535+ args: [speedup]
536536+ lua: startForward()
537537+538538+ actionStop:
539539+ args: [speedup]
540540+ lua: stopForward()
541541+542542+ actionStart:
543543+ args: [speeddown]
544544+ lua: startBackward()
545545+546546+ actionStop:
547547+ args: [speeddown]
548548+ lua: stopBackward()
549549+550550+ actionLoop:
551551+ args: [speeddown]
552552+ lua: loopDirection(direction.backward)
553553+554554+555555+ actionStart:
556556+ args: [antigravity]
557557+ lua: if antigrav ~= nil then antigrav.toggle() end
+17
conf/pvp_seat.conf
···11+# This is a file describing a standard autoconfiguration, do not edit.
22+# See custom/sample.conf for a more generic template and explanation on the syntax.
33+44+name: ui_cu_autoconf_pvp_seat
55+pvp: true
66+77+slots:
88+ core:
99+ class: CoreUnit
1010+ weapon:
1111+ class: WeaponUnit
1212+ select: manual
1313+ radar:
1414+ class: RadarPVPUnit
1515+ select: manual
1616+1717+handlers: