@lazyglobal off. runoncepath("/lib/ui"). runoncepath("/lib/navigation"). runoncepath("/lib/throttle"). runoncepath("/lib/node"). runoncepath("/lib/stabilize_rocket"). runoncepath("/lib/launch_rocket"). clearguis(). global done is false. on AG9 { set done to true. return true. } // Main UI. local iface is gui(250, 300). set iface:X to 200. set iface:Y to 700. // Main menu elements in here. local top is iface:AddVLayout(). local row is makeRow(top). local btn is row:AddButton("TERM"). set btn:TOGGLE to true. set btn:ONTOGGLE to { parameter d. if d { CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Open Terminal"). } else { CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Close Terminal"). } }. makeButton(row, "CONF", { stk:ShowOnly(panes["conf"]). }). set row to makeRow(top). makeButton(row, "HOVER", { Hover(). }). makeButton(row, "LAND", { Land(). }). set row to makeRow(top). makeButton(row, "LNCH", { stk:ShowOnly(panes["launch"]). }). makeButton(row, "NODE", { if HASNODE { set nodeDV:TEXT to NEXTNODE:DELTAV:MAG:ToString. set nodeBT:TEXT to BurnTime(NEXTNODE:DELTAV:MAG):ToString. } else { set nodeDV:TEXT to "No Node". set nodeBT:TEXT to "No Node". } stk:ShowOnly(panes["node"]). }). makeButton(row, "TWR", { stk:ShowOnly(panes["twr"]). }). local stk is iface:AddStack(). local panes is Lex(). // Build launch menu local top is stk:AddVLayout(). panes:Add("launch", top). local box is top:AddScrollBox(). set row to makeRow(box). row:AddLabel("Target Apoapsis"). local targetApo is row:AddTextField("80000"). // todo: config params should go into a nested lexicon set row to makeRow(box). row:AddLabel("Atmo TWR"). local targetTWR is row:AddTextField("1.6"). set row to makeRow(box). row:AddLabel("Initial Pitch"). local initialPitch is row:AddTextField("85"). set row to makeRow(box). row:AddLabel("Minimum Pitch"). local minimumPitch is row:AddTextField("5"). set row to makeRow(box). row:AddLabel("Gravity Turn Alt"). local gravTurnStart is row:AddTextField("8000"). set row to makeRow(box). row:AddLabel("Gravity Turn Pitch"). local gravPitch is row:AddTextField("75"). makeButton(top, "Execute", { Launch( targetApo:TEXT:ToNumber(), gravTurnStart:TEXT:ToNumber(), gravPitch:TEXT:ToNumber(), initialPitch:TEXT:ToNumber(), minimumPitch:TEXT:ToNumber() ). }). // End Launch Menu // Build conf menu local top is stk:AddVLayout(). panes:Add("conf", top). set box to top:AddScrollbox(). set row to makeRow(box). row:AddLabel("Torque Epsilon Max"). local maxEpsilon is row:AddTextField("0.001"). set row to makeRow(box). row:AddLabel("Max Stopping Time"). local maxStopTime is row:AddTextField("2.0"). makeButton(top, "Apply", { set STEERINGMANAGER:TORQUEEPSILONMAX to maxEpsilon:TEXT:ToNumber(). set STEERINGMANAGER:MAXSTOPPINGTIME to maxStopTime:TEXT:ToNumber(). }). // end conf menu // twr menu local top is stk:AddVLayout(). panes:Add("twr", top). set row to makeRow(top). row:AddLabel("Target TWR"). local twrLock is row:AddTextField("1.6"). makeButton(top, "Lock TWR", { 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 top is stk:AddVLayout(). panes:Add("node", top). set row to makeRow(top). row:AddLabel("Node dV"). local nodeDV is row:AddLabel(). set row to makeRow(top). row:AddLabel("Node Burn Time"). local nodeBT is row:AddLabel(). makeButton(top, "Execute", { ExecNode(). }). // end node menu iface:show(). wait until false.