Add aircraft automation code, including flap control and stable autopilot flight.
This commit is contained in:
parent
a99912e3ae
commit
376629354b
9 changed files with 204 additions and 19 deletions
32
lib/flap_control.ks
Normal file
32
lib/flap_control.ks
Normal file
|
@ -0,0 +1,32 @@
|
|||
|
||||
function SetFlapAngle {
|
||||
parameter angle.
|
||||
|
||||
local flaps is getFlaps().
|
||||
if flaps:LENGTH = 0 { return. }
|
||||
for flap in flaps {
|
||||
flap:GetModule("ModuleControlSurface"):SetField("deploy angle", angle).
|
||||
print("DEBUG: Set flap angle to " + angle).
|
||||
}
|
||||
}
|
||||
|
||||
function SetFlaps {
|
||||
parameter extend is true.
|
||||
local flaps is getFlaps().
|
||||
if flaps:LENGTH = 0 { return. }
|
||||
for flap in flaps {
|
||||
flap:GetModule("ModuleControlSurface"):SetField("deploy", extend).
|
||||
print("DEBUG: Set flap deployment to " + extend).
|
||||
}
|
||||
}
|
||||
|
||||
function getFlaps {
|
||||
local flaps is SHIP:PartsTagged("flap").
|
||||
for flap in flaps {
|
||||
if flap:MODULES:Find("ModuleControlSurface") = -1 {
|
||||
print "WARNING: Flap is not a control surface. Aborting operation.".
|
||||
return List().
|
||||
}
|
||||
}
|
||||
return flaps.
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue