Set up code for quickly handling antennas and solar panels.
This commit is contained in:
@ -2,11 +2,15 @@
|
||||
// Assumes stage 0 contains only parachutes.
|
||||
// Primarily written for small science payload probes.
|
||||
|
||||
RunOncePath("lib/systems").
|
||||
|
||||
function PerformReentry {
|
||||
parameter retractAntennae is true.
|
||||
|
||||
SAS off.
|
||||
|
||||
print "Reentry mode activated. Control permanently locked.".
|
||||
|
||||
// stage until only stage 0 remains.
|
||||
until STAGE:NUMBER <= 1 {
|
||||
stage.
|
||||
@ -15,11 +19,7 @@ function PerformReentry {
|
||||
lock STEERING to SHIP:SRFRETROGRADE.
|
||||
|
||||
if retractAntennae {
|
||||
for p in SHIP:PARTS {
|
||||
if p:MODULES:Find("ModuleRTAntenna") > -1 and p:GetModule("ModuleRTAntenna"):ALLEVENTNAMES:Find("Deactivate") > -1 {
|
||||
p:GetModule("ModuleRTAntenna"):DoEvent("Deactivate").
|
||||
}
|
||||
}
|
||||
Antennas(false).
|
||||
}
|
||||
|
||||
when SHIP:ALTITUDE - SHIP:GEOPOSITION:TERRAINHEIGHT < 2500 then {
|
||||
|
25
lib/systems.ks
Normal file
25
lib/systems.ks
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
function Antennas {
|
||||
parameter enable is true.
|
||||
|
||||
local eventName is "Activate".
|
||||
if not enable {
|
||||
set eventName to "Deactivate".
|
||||
}
|
||||
|
||||
for p in SHIP:PARTS {
|
||||
if p:MODULES:Find("ModuleRTAntenna") > -1 and p:GetModule("ModuleRTAntenna"):ALLEVENTNAMES:Find(eventName) > -1 {
|
||||
p:GetModule("ModuleRTAntenna"):DoEvent(eventName).
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function SolarPanels {
|
||||
parameter enable is true.
|
||||
|
||||
if enable {
|
||||
PANELS on.
|
||||
} else {
|
||||
PANELS off.
|
||||
}
|
||||
}
|
17
lib/ui.ks
17
lib/ui.ks
@ -13,6 +13,17 @@ function MakeButton {
|
||||
return b.
|
||||
}
|
||||
|
||||
function MakeToggle {
|
||||
parameter p.
|
||||
parameter l.
|
||||
parameter f.
|
||||
|
||||
local btn is p:AddButton(l).
|
||||
set btn:TOGGLE to true.
|
||||
set btn:onClick to f.
|
||||
return btn.
|
||||
}
|
||||
|
||||
function MakeMenu {
|
||||
parameter stack. // the stack where menu stuff goes
|
||||
parameter btn. // the button that should show this menu
|
||||
@ -58,9 +69,7 @@ function AddStockButtons {
|
||||
parameter row.
|
||||
parameter bootname.
|
||||
|
||||
local btn is row:AddButton("Term").
|
||||
set btn:TOGGLE to true.
|
||||
set btn:ONTOGGLE to {
|
||||
MakeToggle(row, "Term", {
|
||||
parameter d.
|
||||
|
||||
if d {
|
||||
@ -68,7 +77,7 @@ function AddStockButtons {
|
||||
} else {
|
||||
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Close Terminal").
|
||||
}
|
||||
}.
|
||||
}).
|
||||
|
||||
MakeButton(row, "Update", {
|
||||
switch to 0.
|
||||
|
Reference in New Issue
Block a user