kOS/rocket/init.ks
2021-07-23 21:40:46 +00:00

111 lines
2.6 KiB
Plaintext

runoncepath("/lib/navigation").
function launchButtonPressed {
// adjust torque settings here...
local oldEpsilon is STEERINGMANAGER:TORQUEEPSILONMAX.
set STEERINGMANAGER:TORQUEEPSILONMAX to maxEpsilon:TEXT:ToNumber().
local oldStopTime is STEERINGMANAGER:MAXSTOPPINGTIME.
set STEERINGMANAGER:MAXSTOPPINGTIME to maxStopTime:TEXT:ToNumber().
run "/launch"(
targetApo:TEXT:ToNumber(),
gravTurnStart:TEXT:ToNumber(),
gravPitch:TEXT:ToNumber(),
initialPitch:TEXT:ToNumber(),
minimumPitch:TEXT:ToNumber()
).
set STEERINGMANAGER:TORQUEEPSILONMAX to oldEpsilon.
set STEERINGMANAGER:MAXSTOPPINGTIME to oldStopTime..
}
// 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("LNCH"):onClick to {
stk:ShowOnly(launchmenu).
}.
set x:AddButton("NODE"):onClick to {
run "/execnode".
}.
local stk is interface:AddStack().
// Build launch menu
local launchMenu is stk:AddVLayout().
set btn to launchMenu:AddButton("Execute").
set btn:onClick to launchButtonPressed@.
local launchConfig is box: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").
launchConfig:AddSpacing(5).
set sbox to launchConfig:AddHLayout().
sbox:AddLabel("Torque Epsilon Max").
local maxEpsilon is sbox:AddTextField("0.001").
set sbox to launchConfig:AddHLayout().
sbox:AddLabel("Max Stopping Time").
local maxStopTime is sbox:AddTextField("2.0").
// End Launch Menu
// Build conf menu
// end conf menu
interface:show().
wait until false.