171 lines
3.7 KiB
Plaintext
171 lines
3.7 KiB
Plaintext
runoncepath("/lib/navigation").
|
|
runoncepath("/lib/throttle").
|
|
runoncepath("/lib/stabilize_rocket").
|
|
|
|
global done is false.
|
|
on AG9 {
|
|
set done to true.
|
|
return true.
|
|
}
|
|
|
|
function launchButtonPressed {
|
|
run "/launch"(
|
|
targetApo:TEXT:ToNumber(),
|
|
gravTurnStart:TEXT:ToNumber(),
|
|
gravPitch:TEXT:ToNumber(),
|
|
initialPitch:TEXT:ToNumber(),
|
|
minimumPitch:TEXT:ToNumber()
|
|
).
|
|
}
|
|
|
|
// Main UI.
|
|
local interface is gui(250, 300).
|
|
set interface:X to 200.
|
|
set interface:Y to 700.
|
|
|
|
// Main menu elements in here.
|
|
local y is interface:AddVLayout().
|
|
local x is y:AddHLayout().
|
|
|
|
local btn is x:AddButton("TERM").
|
|
set btn:TOGGLE to true.
|
|
set btn:ONTOGGLE to {
|
|
parameter activate.
|
|
|
|
if activate {
|
|
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Open Terminal").
|
|
} else {
|
|
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Close Terminal").
|
|
}
|
|
}.
|
|
|
|
set x:AddButton("CONF"):onClick to {
|
|
stk:ShowOnly(confMenu).
|
|
}.
|
|
|
|
set x to y:AddHLayout().
|
|
|
|
set x:AddButton("HOVER"):onClick to {
|
|
Hover().
|
|
}.
|
|
|
|
set x:AddButton("LAND"):onClick to {
|
|
Land().
|
|
}.
|
|
|
|
set x to y:AddHLayout().
|
|
|
|
set x:AddButton("LNCH"):onClick to {
|
|
stk:ShowOnly(launchmenu).
|
|
}.
|
|
set x:AddButton("NODE"):onClick to {
|
|
set nodeDV:TEXT to NEXTNODE:DELTAV:MAG:ToString.
|
|
set nodeBT:TEXT to BurnTime(NEXTNODE:DELTAV:MAG):ToString.
|
|
stk:ShowOnly(nodeMenu).
|
|
}.
|
|
|
|
set x:AddButton("TWR"):onClick to {
|
|
stk:ShowOnly(twrMenu).
|
|
}.
|
|
|
|
local stk is interface:AddStack().
|
|
|
|
// Build launch menu
|
|
local launchMenu is stk:AddVLayout().
|
|
|
|
local launchConfig is launchMenu:AddScrollBox().
|
|
|
|
set sbox to launchConfig:AddHLayout().
|
|
sbox:AddLabel("Target Apoapsis").
|
|
local targetApo is sbox:AddTextField("80000").
|
|
|
|
set sbox to launchConfig:AddHLayout().
|
|
sbox:AddLabel("Atmo TWR").
|
|
local targetTWR is sbox:AddTextField("1.6").
|
|
|
|
set sbox to launchConfig:AddHLayout().
|
|
sbox:AddLabel("Initial Pitch").
|
|
local initialPitch is sBox:AddTextField("85").
|
|
|
|
set sbox to launchConfig:AddHLayout().
|
|
sbox:AddLabel("Minimum Pitch").
|
|
local minimumPitch is sbox:AddTextField("5").
|
|
|
|
set sbox to launchConfig:AddHLayout().
|
|
sbox:AddLabel("Gravity Turn Alt").
|
|
local gravTurnStart is sbox:AddTextField("8000").
|
|
|
|
set sbox to launchConfig:AddHLayout().
|
|
sbox:AddLabel("Gravity Turn Pitch").
|
|
local gravPitch is sbox:AddTextField("75").
|
|
|
|
set btn to launchMenu:AddButton("Execute").
|
|
set btn:onClick to launchButtonPressed@.
|
|
|
|
// End Launch Menu
|
|
|
|
// Build conf menu
|
|
local confMenu is stk:AddVLayout().
|
|
|
|
local confBox is confMenu:AddScrollbox().
|
|
|
|
set sbox to confBox:AddHLayout().
|
|
sbox:AddLabel("Torque Epsilon Max").
|
|
local maxEpsilon is sbox:AddTextField("0.001").
|
|
|
|
set sbox to confBox:AddHLayout().
|
|
sbox:AddLabel("Max Stopping Time").
|
|
local maxStopTime is sbox:AddTextField("2.0").
|
|
|
|
set btn to confMenu:AddButton("Apply").
|
|
set btn:onClick to {
|
|
set STEERINGMANAGER:TORQUEEPSILONMAX to maxEpsilon:TEXT:ToNumber().
|
|
set STEERINGMANAGER:MAXSTOPPINGTIME to maxStopTime:TEXT:ToNumber().
|
|
}.
|
|
|
|
// end conf menu
|
|
|
|
// twr menu
|
|
local twrMenu is stk:AddVLayout().
|
|
|
|
set sbox to twrMenu:AddHLayout().
|
|
sbox:AddLabel("Target TWR").
|
|
local twrLock is sbox:AddTextField("1.6").
|
|
|
|
set twrMenu:AddButton("Lock TWR"):onClick to {
|
|
local done is false.
|
|
on AG9 {
|
|
set done to true.
|
|
}
|
|
|
|
print "Locking throttle to target TWR.".
|
|
local tgt is twrLock:TEXT:ToNumber().
|
|
lock THROTTLE to ThrottleToTWR(tgt).
|
|
wait until done.
|
|
print "Throttle unlocked.".
|
|
}.
|
|
|
|
// end twr menu
|
|
|
|
// node menu
|
|
local nodeMenu is stk:AddVLayout().
|
|
local nodeBox is nodeMenu:AddScrollBox().
|
|
|
|
set sbox to nodeBox:AddHLayout().
|
|
sbox:AddLabel("Node dV").
|
|
local nodeDV is sbox:AddLabel().
|
|
|
|
set sbox to nodeBox:AddHLayout().
|
|
sbox:AddLabel("Node Burn Time").
|
|
local nodeBT is sbox:AddLabel().
|
|
|
|
set nodeMenu:AddButton("Execute"):onClick to {
|
|
run "/execnode".
|
|
}.
|
|
|
|
// end node menu
|
|
|
|
interface:show().
|
|
|
|
wait until false.
|