kOS/prog/rocket.ks

128 lines
2.9 KiB
Plaintext
Raw Normal View History

2021-08-02 01:34:19 +00:00
@lazyglobal off.
2021-08-02 04:20:19 +00:00
runoncepath("/lib/ui").
2021-07-21 09:24:46 +00:00
runoncepath("/lib/navigation").
runoncepath("/lib/throttle").
2021-08-02 01:46:17 +00:00
runoncepath("/lib/node").
2021-08-01 05:23:39 +00:00
runoncepath("/lib/stabilize_rocket").
2021-08-02 04:20:19 +00:00
runoncepath("/lib/launch_rocket").
2021-07-21 09:24:46 +00:00
clearguis().
2021-08-01 05:23:39 +00:00
global done is false.
on AG9 {
set done to true.
return true.
}
2021-07-21 09:24:46 +00:00
2021-08-08 04:15:28 +00:00
// Top-level menu structure.
local iface is gui(250, 300).
set iface:X to 200.
set iface:Y to 700.
local top is iface:AddVLayout().
2021-08-08 04:15:28 +00:00
local rows is list(MakeRow(top), MakeRow(top), MakeRow(top)).
local stk is iface:AddStack().
2021-08-08 04:15:28 +00:00
// Buttons and menus.
local btn is rows[0]:AddButton("TERM").
2021-07-21 09:24:46 +00:00
set btn:TOGGLE to true.
set btn:ONTOGGLE to {
parameter d.
if d {
2021-07-21 09:24:46 +00:00
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Open Terminal").
} else {
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Close Terminal").
2021-07-22 22:29:18 +00:00
}
2021-07-21 09:24:46 +00:00
}.
2021-08-08 04:15:28 +00:00
MakeMenu(
stk,
MakeButton(rows[0], "CONF"),
List(
List("Torque Epsilon Max", "SCALAR", "0.001"),
List("Max Stopping Time", "SCALAR", "2.0")
),
"Apply",
{
parameter options.
set STEERINGMANAGER:TORQUEEPSILONMAX to options["Torque Epsilon Max"]:TEXT:ToNumber().
set STEERINGMANAGER:MAXSTOPPINGTIME to options["Max Stopping Time"]:TEXT:ToNumber().
2021-08-02 01:37:42 +00:00
}
2021-08-08 04:15:28 +00:00
).
MakeButton(rows[1], "ZERO", { ZeroVelocity(). }).
2021-08-08 04:15:28 +00:00
MakeButton(rows[1], "HOVER", { Hover(). }).
MakeButton(rows[1], "LAND", { Land(). }).
MakeMenu(
stk,
MakeButton(rows[2], "LNCH"),
List(
List("Target Apoapsis", "SCALAR", "80000"),
List("Atmo TWR", "SCALAR", "1.8"),
List("Initial Pitch", "SCALAR", "85"),
List("Minimum Pitch", "SCALAR", "5"),
List("Gravity Turn Alt", "SCALAR", "8000"),
List("Gravity Turn Pitch", "SCALAR", "75")
),
"Execute",
{
parameter options.
Launch(
options["Target Apoapsis"]:TEXT:ToNumber(),
options["Atmo TWR"]:TEXT:ToNumber(),
options["Gravity Turn Alt"]:TEXT:ToNumber(),
options["Gravity Turn Pitch"]:TEXT:ToNumber(),
options["Initial Pitch"]:TEXT:ToNumber(),
options["Minimum Pitch"]:TEXT:ToNumber()
).
}
2021-08-08 04:15:28 +00:00
).
MakeMenu(
stk,
MakeButton(rows[2], "NODE"),
List(
List("Node dV", "RO", "0"),
List("Node Burn Time", "RO", "0")
),
"Execute",
{
parameter options.
ExecNode().
},
{
parameter options.
if HASNODE {
set options["Node dV"]:TEXT to NEXTNODE:DELTAV:MAG:ToString.
set options["Node Burn Time"]:TEXT to BurnTime(NEXTNODE:DELTAV:MAG):ToString.
} else {
set options["Node dV"]:TEXT to "No Node".
set options["Node Burn Time"]:TEXT to "No Node".
}
}
).
MakeMenu(
stk,
MakeButton(rows[2], "TWR"),
List(
List("Target TWR", "SCALAR", "1.6")
),
"Lock TWR",
{
parameter options.
local done is false.
print "Locking throttle to target TWR.".
local tgt is options["Target TWR"]:TEXT:ToNumber().
lock THROTTLE to ThrottleToTWR(tgt).
wait until done.
print "Throttle unlocked.".
set done to false.
}
).
2021-08-01 05:23:39 +00:00
iface:show().
wait until false.