Add inter-processor signalling to automate entire launch process.

This commit is contained in:
Anna Rose 2021-08-29 04:05:56 -04:00
parent 6be96ebf8a
commit 9623a4a869
2 changed files with 49 additions and 6 deletions

View File

@ -4,11 +4,13 @@
// to the main ship computer. // to the main ship computer.
// //
// The launchpad object should have the "launchpad" tag. // The launchpad object should have the "launchpad" tag.
// The ship's main CPU (the one with launch functionality" should be tagged "shipcpu".
// Fuel tanks with the "nofuel" tag will have *all* resources temporarily disabled during this // Fuel tanks with the "nofuel" tag will have *all* resources temporarily disabled during this
// sequence. The main ship computer must re-enable them after staging. NoFuelResources in lib/systems is ideal // sequence. The main ship computer must re-enable them after staging. NoFuelResources in lib/systems is ideal
// for this. // for this.
RunOncePath("/lib/systems"). RunOncePath("/lib/systems").
RunOncePath("/lib/ui").
ClearGuis(). ClearGuis().
@ -28,21 +30,31 @@ function enableLaunchpadFlow {
} }
function preLaunch { function preLaunch {
parameter options.
print "Beginning pre-launch sequence.". print "Beginning pre-launch sequence.".
NoFuelResources(false). NoFuelResources(false).
// turn on generator and fuel flow // turn on generator and fuel flow
enableLaunchpadFlow(). enableLaunchpadFlow().
local duration is options["Spool-up Time"]:TEXT:ToNumber().
lock THROTTLE to 0. lock THROTTLE to 0.
stage. stage.
local startTime is TIME:SECONDS. local startTime is TIME:SECONDS.
lock THROTTLE to (TIME:SECONDS-startTime)/15. lock THROTTLE to (TIME:SECONDS-startTime)/duration.
wait 15. wait duration.
set SHIP:CONTROL:PILOTMAINTHROTTLE to 1.0. set SHIP:CONTROL:PILOTMAINTHROTTLE to 1.0.
unlock THROTTLE. unlock THROTTLE.
print "Pre-launch sequence complete.". print "Pre-launch sequence complete. Initiating launch.".
local msg is Lex(
"command", "launch",
"angle", options["Kick Angle"]:TEXT:ToNumber(),
"time", options["Kick Time"]:TEXT:ToNumber()
).
Processor("shipcpu"):CONNECTION:SendMessage(msg).
iface:Hide(). iface:Hide().
shutdown. shutdown.
} }
@ -51,8 +63,20 @@ global iface is gui(250, 300).
set iface:X to 200. set iface:X to 200.
set iface:Y to 500. set iface:Y to 500.
local top is iface:AddVLayout(). local top is iface:AddVLayout().
local row is iface:AddHLayout().
local stk is iface:AddStack().
MakeMenu(
stk,
MakeButton(row, "Launch Sequence"),
List(
List("Spool-up Time", "SCALAR", "15"),
List("Kick Angle", "SCALAR", "30"),
List("Kick Time", "SCALAR", "45")
),
"Execute",
preLaunch@
).
local btn is top:AddButton("Pre-Launch").
set btn:onClick to preLaunch@.
iface:Show(). iface:Show().
wait until false. wait until false.

View File

@ -172,6 +172,25 @@ MakeMenu(
). ).
iface:show(). iface:show().
until SHIP:STATUS <> "PRELAUNCH" {
if not CORE:MESSAGES:EMPTY {
local msg is CORE:MESSAGES:Pop().
local data is msg:CONTENT.
if data["command"] = "launch" {
Launch(
80000,
2.0,
5.0,
data["angle"],
data["time"],
true
).
}
}
wait 0.001.
}
wait until false. wait until false.
function refreshSensors { function refreshSensors {