Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function LogData {
- parameter text.
- // print to both the console and log
- print "[" + time:clock + "] " + text.
- log "[" + time:clock + "] " + text to missionlog.
- // make a copy on the local KSC archive
- copy missionlog to 0.
- }.
- function Launch {
- clearscreen.
- LogData("Sounding Rocket Flight Program initiating...").
- // find all our parts
- set sep to ship:partstagged("sep")[0].
- set exp to ship:partstagged("exp")[0].
- set srb to ship:partstagged("srb")[0].
- set chute to ship:partstagged("chute")[0].
- set clamp to ship:partstagged("clamp")[0].
- set probe to ship:partstitled("Avionics Package")[0].
- set fairings to ship:partstagged("fairing").
- // perform pre-launch checks
- if fairings:length < 2 {
- LogData("Fairing parts missing, only found " + fairings:length).
- return false.
- }.
- list engines in englist.
- for eng in englist {
- if eng:thrustlimit <> 48 {
- LogData("Improper thrust limiter set. Thrust set to " + eng:thrustlimit + "%").
- return false.
- }
- }
- // all good, begin the countdown
- LogData("GO for launch!").
- wait 1.
- LogData("T-10").
- wait 1.
- LogData("T-9").
- wait 1.
- LogData("T-8").
- wait 1.
- LogData("T-7").
- wait 1.
- LogData("T-6").
- wait 1.
- LogData("T-5").
- wait 1.
- LogData("T-4").
- wait 1.
- LogData("T-3").
- wait 1.
- LogData("T-2").
- wait 1.
- LogData("T-1").
- wait 1.
- // fire the engine and detach from the launch stick
- srb:getmodule("ModuleEngines"):doevent("activate engine").
- clamp:getmodule("ModuleAnchoredDecoupler"):doevent("decouple").
- LogData("Liftoff!!").
- // wait until engine expires
- until srb:getmodule("ModuleEngines"):getfield("status") = "flame-out!" {}.
- LogData("SRB flame out detected. Decoupling").
- // ditch the SRB and dump the fairings and then await subsonic velocity
- sep:getmodule("ModuleDecouple"):doevent("decouple").
- LogData("Releasing payload fairings").
- for fairing in fairings {
- fairing:getmodule("ModuleDecouple"):doevent("decouple").
- }
- LogData("Awaiting subsonic velocity for chute deployment").
- until ship:airspeed <= 260 {}.
- // pop the chute
- LogData("Deploying chute").
- chute:getmodule("ModuleParachute"):doevent("deploy chute").
- // confirm chute is open and run science experiments
- until chute:getmodule("ModuleParachute"):hasevent("cut parachute") {}.
- LogData("Chute deployed, running experiments").
- toggle AG1.
- return true.
- }
- // done! All data will be stored for retrieval, as battery power will not last until landing
- if Launch() {
- LogData("All events have executed. Awaiting landing & retrieval").
- }.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement