Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //create access to all the parts
- set hichute to ship:partstagged("hi")[0].
- set lochute to ship:partstagged("lo")[0].
- set comms to ship:partstagged("antenna")[0].
- set probe to ship:partstagged("core")[0].
- set decoupler to ship:partstagged("drop")[0].
- set battlist to ship:partsdubbed("z-200 rechargeable battery bank").
- set caplist to ship:partsdubbed("cap-101 capacitor").
- set goolist to ship:partstagged("goo").
- // program behavior variables
- set deployalt to 25000.
- set deployupperheight to 24000.
- set loweratmosphere to 18000.
- set deploylowerheight to 3000.
- set maxdropspeed to 12.
- set commtimeout to 30.
- set transmissiontimeout to 15.
- set lowbattlvl to 25. // for when no data is being transmitted
- set lowbattlvltrans to 150. // for when data is being transmitted
- set capactive to -1.
- set discharged to false.
- lock transtime to time:seconds.
- clearscreen.
- abort off.
- print "[" + time:clock + "] Program running... confirming systems".
- log "[" + time:clock + "] Program running... confirming systems" to droplog.
- copy droplog to 0.
- print "[" + time:clock + "] " + battlist:length + " Battery(s) found".
- log "[" + time:clock + "] " + battlist:length + " Battery(s) found" to droplog.
- copy droplog to 0.
- print "[" + time:clock + "] " + caplist:length + " Capacitor(s) found".
- log "[" + time:clock + "] " + caplist:length + " Capacitor(s) found" to droplog.
- copy droplog to 0.
- print "[" + time:clock + "] " + goolist:length + " Goo canister(s) found".
- log "[" + time:clock + "] " + goolist:length + " Goo canister(s) found" to droplog.
- copy droplog to 0.
- print "[" + time:clock + "] Operational systems confirmed, awaiting deployment altitude".
- log "[" + time:clock + "] Operational systems confirmed, awaiting deployment altitude" to droplog.
- copy droplog to 0.
- // no need to monitor systems as we are conected to power of mothership
- until ship:altitude > deployalt { wait 0.001. }.
- // drop and begin
- decoupler:getmodule("moduleanchoreddecoupler"):doevent("decouple").
- print "[" + time:clock + "] 25km reached - deploying!".
- log "[" + time:clock + "] 25km reached - deploying!" to droplog.
- copy droplog to 0.
- hichute:getmodule("realchutemodule"):doevent("deploy chute").
- lochute:getmodule("realchutemodule"):doevent("deploy chute").
- print "[" + time:clock + "] chutes armed".
- log "[" + time:clock + "] chutes armed" to droplog.
- copy droplog to 0.
- for batt in battlist {
- set batt:resources[0]:enabled to true.
- }.
- print "[" + time:clock + "] All batteries enabled".
- log "[" + time:clock + "] All batteries enabled" to droplog.
- copy droplog to 0.
- print "[" + time:clock + "] Awaiting chute deployment".
- log "[" + time:clock + "] Awaiting chute deployment" to droplog.
- copy droplog to 0.
- // it is possible that when calling ship:resources[0], even though additional batteries were enabled,
- // it was before a tick update that changed the ship:resources[0] value, so it was still the 25EC
- // of just the drop pod probe core that was the value returned (already slightly less than 25), which is
- // what triggered an unneccessary capacitor discharge at the start of the program. So wait for tick update.
- wait 0.1.
- until hichute:getmodule("realchutemodule"):hasevent("cut chute") {
- if not discharged and ship:resources[0]:amount < lowbattlvl {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- wait 0.001.
- }.
- Print "[" + time:clock + "] Chute deployment confirmed. Awaiting full deployment".
- log "[" + time:clock + "] Chute deployment confirmed. Awaiting full deployment" to droplog.
- copy droplog to 0.
- // we don't care how fast we are dropping - air is too thin to rip off antenna at any speed once chute is deployed
- until alt:radar < deployupperheight {
- if not discharged and ship:resources[0]:amount < lowbattlvl {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- wait 0.001.
- }.
- Print "[" + time:clock + "] Full chute deployment confirmed".
- log "[" + time:clock + "] Full chute deployment confirmed" to droplog.
- copy droplog to 0.
- comms:getmodule("modulertantenna"):doevent("activate").
- Print "[" + time:clock + "] Communications antenna deployed. Awaiting connection".
- log "[" + time:clock + "] Communications antenna deployed. Awaiting connection" to droplog.
- copy droplog to 0.
- set timer to time:seconds.
- until probe:getmodule("modulespu"):getfield("spu") = "operational." {
- if not discharged and ship:resources[0]:amount < lowbattlvl {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- if time:seconds - timer > commtimeout {
- Print "[" + time:clock + "] Communications link failed!".
- log "[" + time:clock + "] Communications link failed!" to droplog.
- copy droplog to 0.
- shutdown.
- }
- wait 0.001.
- }.
- Print "[" + time:clock + "] Communications link established".
- log "[" + time:clock + "] Communications link established" to droplog.
- copy droplog to 0.
- Print "[" + time:clock + "] First upper atmospheric experiment run commencing".
- log "[" + time:clock + "] First upper atmospheric experiment run commencing" to droplog.
- copy droplog to 0.
- toggle AG4.
- // goo containers are only run once per atmosphere level (upper/lower)
- for goo in goolist {
- // we don't care which goo pod is run - if a goo container is unused, it will have an event available
- if goo:getmodule("modulescienceexperiment"):hasevent("observe mystery goo") {
- goo:getmodule("modulescienceexperiment"):doevent("observe mystery goo").
- break.
- }.
- }.
- Print "[" + time:clock + "] Awaiting data transmission".
- log "[" + time:clock + "] Awaiting data transmission" to droplog.
- copy droplog to 0.
- set timer to time:seconds.
- set nodata to false.
- // until the comms message changes from "idle", nothing is being transmitted
- until comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
- // keep tabs on our power status - release capcitor charge as necessary
- if not discharged and ship:resources[0]:amount < lowbattlvl {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- // keeps tabs on our connection to Mission Control
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- // if the user recycles all experiments, no data will be sent
- if time:seconds - timer > commtimeout {
- set nodata to true.
- break.
- }
- wait 0.001.
- }.
- if nodata {
- // aborts the second run as well - no data means no data for this entire biome level
- Print "[" + time:clock + "] Aborting upper atmospheric runs due to no data to transmit".
- log "[" + time:clock + "] Aborting upper atmospheric runs due to no data to transmit" to droplog.
- copy droplog to 0.
- } else {
- Print "[" + time:clock + "] Data transmission has begun".
- log "[" + time:clock + "] Data transmission has begun" to droplog.
- copy droplog to 0.
- until time:seconds - transtime > transmissiontimeout {
- if not discharged and ship:resources[0]:amount < lowbattlvltrans {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- if transtime < time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
- lock transtime to time:seconds.
- }.
- if transtime = time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "idle" {
- set transtime to time:seconds.
- }.
- wait 0.001.
- }.
- lock transtime to time:seconds.
- Print "[" + time:clock + "] Data transmission has ended".
- log "[" + time:clock + "] Data transmission has ended" to droplog.
- copy droplog to 0.
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- // if we haven't reached the lower atmosphere yet, take a second run for additional data
- if alt:radar > loweratmosphere {
- Print "[" + time:clock + "] Second upper atmospheric experiment run commencing".
- log "[" + time:clock + "] Second upper atmospheric experiment run commencing" to droplog.
- copy droplog to 0.
- toggle AG4.
- for goo in goolist {
- if goo:getmodule("modulescienceexperiment"):allevents:length > 0 {
- goo:getmodule("modulescienceexperiment"):doevent("observe mystery goo").
- break.
- }.
- }.
- Print "[" + time:clock + "] Awaiting data transmission".
- log "[" + time:clock + "] Awaiting data transmission" to droplog.
- copy droplog to 0.
- set timer to time:seconds.
- set nodata to false.
- until comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
- if not discharged and ship:resources[0]:amount < lowbattlvl {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- if time:seconds - timer > commtimeout {
- set nodata to true.
- break.
- }
- wait 0.001.
- }.
- if nodata {
- Print "[" + time:clock + "] Aborting second upper atmospheric run due to no data to transmit".
- log "[" + time:clock + "] Aborting second upper atmospheric run due to no data to transmit" to droplog.
- copy droplog to 0.
- } else {
- Print "[" + time:clock + "] Data transmission has begun".
- log "[" + time:clock + "] Data transmission has begun" to droplog.
- copy droplog to 0.
- until time:seconds - transtime > transmissiontimeout {
- if not discharged and ship:resources[0]:amount < lowbattlvltrans {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- if transtime < time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
- lock transtime to time:seconds.
- }.
- if transtime = time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "idle" {
- set transtime to time:seconds.
- }.
- wait 0.01.
- }.
- lock transtime to time:seconds.
- Print "[" + time:clock + "] Data transmission has ended".
- log "[" + time:clock + "] Data transmission has ended" to droplog.
- copy droplog to 0.
- }.
- } else {
- Print "[" + time:clock + "] Aborting second upper atmospheric run due to altitude".
- log "[" + time:clock + "] Aborting second upper atmospheric run due to altitude" to droplog.
- copy droplog to 0.
- }.
- }.
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- Print "[" + time:clock + "] Advancing to lower atmosphere".
- log "[" + time:clock + "] Advancing to lower atmosphere" to droplog.
- copy droplog to 0.
- comms:getmodule("modulertantenna"):doevent("deactivate").
- Print "[" + time:clock + "] Communications antenna retracted".
- log "[" + time:clock + "] Communications antenna retracted" to droplog.
- copy droplog to 0.
- hichute:getmodule("realchutemodule"):doevent("cut chute").
- Print "[" + time:clock + "] Chute cut".
- log "[" + time:clock + "] Chute cut" to droplog.
- copy droplog to 0.
- Print "[" + time:clock + "] Awaiting chute deployment".
- log "[" + time:clock + "] Awaiting chute deployment" to droplog.
- copy droplog to 0.
- until lochute:getmodule("realchutemodule"):hasevent("cut chute") {
- if not discharged and ship:resources[0]:amount < lowbattlvl {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- wait 0.001.
- }.
- Print "[" + time:clock + "] Chute deployment confirmed. Awaiting full deployment".
- log "[" + time:clock + "] Chute deployment confirmed. Awaiting full deployment" to droplog.
- copy droplog to 0.
- until alt:radar < deploylowerheight and ship:verticalspeed*-1 < maxdropspeed {
- if not discharged and ship:resources[0]:amount < lowbattlvl {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- wait 0.001.
- }.
- Print "[" + time:clock + "] Full chute deployment confirmed".
- log "[" + time:clock + "] Full chute deployment confirmed" to droplog.
- copy droplog to 0.
- comms:getmodule("modulertantenna"):doevent("activate").
- Print "[" + time:clock + "] Communications antenna deployed. Awaiting connection".
- log "[" + time:clock + "] Communications antenna deployed. Awaiting connection" to droplog.
- copy droplog to 0.
- set timer to time:seconds.
- until probe:getmodule("modulespu"):getfield("spu") = "operational." {
- if not discharged and ship:resources[0]:amount < lowbattlvl {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- if time:seconds - timer > commtimeout {
- Print "[" + time:clock + "] Communications link failed!".
- log "[" + time:clock + "] Communications link failed!" to droplog.
- copy droplog to 0.
- shutdown.
- }
- wait 0.001.
- }.
- Print "[" + time:clock + "] Communications link established".
- log "[" + time:clock + "] Communications link established" to droplog.
- copy droplog to 0.
- Print "[" + time:clock + "] First lower atmospheric experiment run commencing".
- log "[" + time:clock + "] First lower atmospheric experiment run commencing" to droplog.
- copy droplog to 0.
- toggle AG4.
- // goo containers are only run once per atmosphere level (upper/lower)
- for goo in goolist {
- // we don't care which goo pod is run - if a goo container is unused, it will have an event available
- if goo:getmodule("modulescienceexperiment"):hasevent("observe mystery goo") {
- goo:getmodule("modulescienceexperiment"):doevent("observe mystery goo").
- break.
- }.
- }.
- Print "[" + time:clock + "] Awaiting data transmission".
- log "[" + time:clock + "] Awaiting data transmission" to droplog.
- copy droplog to 0.
- set timer to time:seconds.
- set nodata to false.
- // until the comms message changes from "idle", nothing is being transmitted
- until comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
- // keep tabs on our power status - release capcitor charge as necessary
- if not discharged and ship:resources[0]:amount < lowbattlvl {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- // keeps tabs on our connection to Mission Control
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- // if the user recycles all experiments, no data will be sent
- if time:seconds - timer > commtimeout {
- set nodata to true.
- break.
- }
- wait 0.001.
- }.
- if nodata {
- // aborts the second run as well - no data means no data for this entire biome level
- Print "[" + time:clock + "] Aborting lower atmospheric runs due to no data to transmit".
- log "[" + time:clock + "] Aborting lower atmospheric runs due to no data to transmit" to droplog.
- copy droplog to 0.
- } else {
- Print "[" + time:clock + "] Data transmission has begun".
- log "[" + time:clock + "] Data transmission has begun" to droplog.
- copy droplog to 0.
- until time:seconds - transtime > transmissiontimeout {
- if not discharged and ship:resources[0]:amount < lowbattlvltrans {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- if transtime < time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
- lock transtime to time:seconds.
- }.
- if transtime = time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "idle" {
- set transtime to time:seconds.
- }.
- wait 0.001.
- }.
- lock transtime to time:seconds.
- Print "[" + time:clock + "] Data transmission has ended".
- log "[" + time:clock + "] Data transmission has ended" to droplog.
- copy droplog to 0.
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- // if we'haven't landed yet, take a second run for additional data
- if ship:verticalspeed < 0 {
- Print "[" + time:clock + "] Second lower atmospheric experiment run commencing".
- log "[" + time:clock + "] Second lower atmospheric experiment run commencing" to droplog.
- copy droplog to 0.
- toggle AG4.
- for goo in goolist {
- if goo:getmodule("modulescienceexperiment"):allevents:length > 0 {
- goo:getmodule("modulescienceexperiment"):doevent("observe mystery goo").
- break.
- }.
- }.
- Print "[" + time:clock + "] Awaiting data transmission".
- log "[" + time:clock + "] Awaiting data transmission" to droplog.
- copy droplog to 0.
- set timer to time:seconds.
- set nodata to false.
- until comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
- if not discharged and ship:resources[0]:amount < lowbattlvl {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- if time:seconds - timer > commtimeout {
- set nodata to true.
- break.
- }
- wait 0.001.
- }.
- if nodata {
- Print "[" + time:clock + "] Aborting second lower atmospheric run due to no data to transmit".
- log "[" + time:clock + "] Aborting second lower atmospheric run due to no data to transmit" to droplog.
- copy droplog to 0.
- } else {
- Print "[" + time:clock + "] Data transmission has begun".
- log "[" + time:clock + "] Data transmission has begun" to droplog.
- copy droplog to 0.
- until time:seconds - transtime > transmissiontimeout {
- if not discharged and ship:resources[0]:amount < lowbattlvltrans {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- if transtime < time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
- lock transtime to time:seconds.
- }.
- if transtime = time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "idle" {
- set transtime to time:seconds.
- }.
- wait 0.001.
- }.
- lock transtime to time:seconds.
- Print "[" + time:clock + "] Data transmission has ended".
- log "[" + time:clock + "] Data transmission has ended" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- // go into a wait state if we haven't landed during the last transmission sequence
- if ship:verticalspeed < 0 {
- Print "[" + time:clock + "] Awaiting landing".
- until ship:verticalspeed >= 0 {
- if not discharged and ship:resources[0]:amount < lowbattlvl {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- wait 0.001.
- }.
- }.
- Print "[" + time:clock + "] Landing confirmed. First ground level experiment run commencing".
- log "[" + time:clock + "] Landing confirmed. First ground level experiment run commencing" to droplog.
- copy droplog to 0.
- toggle AG4.
- for goo in goolist {
- // original line below
- // if goo:getmodule("modulescienceexperiment"):allevents:length > 0 {
- // this is not the proper way to check if an event is available and when this check evaluated to true
- // but the event was not in that list as expected, it ended up throwing an error that killed the program
- // proper check below
- if goo:getmodule("modulescienceexperiment"):hasevent("observe mystery goo") {
- goo:getmodule("modulescienceexperiment"):doevent("observe mystery goo").
- break.
- }.
- }.
- Print "[" + time:clock + "] Awaiting data transmission".
- log "[" + time:clock + "] Awaiting data transmission" to droplog.
- copy droplog to 0.
- set timer to time:seconds.
- set nodata to false.
- until comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
- if not discharged and ship:resources[0]:amount < lowbattlvl {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- if time:seconds - timer > commtimeout {
- set nodata to true.
- break.
- }
- wait 0.001.
- }.
- if nodata {
- Print "[" + time:clock + "] Aborting ground level runs due to no data to transmit".
- log "[" + time:clock + "] Aborting ground level runs due to no data to transmit" to droplog.
- copy droplog to 0.
- } else {
- Print "[" + time:clock + "] Data transmission has begun".
- log "[" + time:clock + "] Data transmission has begun" to droplog.
- copy droplog to 0.
- until time:seconds - transtime > transmissiontimeout {
- if not discharged and ship:resources[0]:amount < lowbattlvltrans {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- if transtime < time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
- lock transtime to time:seconds.
- }.
- if transtime = time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "idle" {
- set transtime to time:seconds.
- }.
- wait 0.001.
- }.
- lock transtime to time:seconds.
- Print "[" + time:clock + "] Data transmission has ended".
- log "[" + time:clock + "] Data transmission has ended" to droplog.
- copy droplog to 0.
- if ship:resources[0]:amount > 0 {
- Print "[" + time:clock + "] Second ground level experiment run commencing".
- log "[" + time:clock + "] Second ground level experiment run commencing" to droplog.
- copy droplog to 0.
- toggle AG4.
- for goo in goolist {
- if goo:getmodule("modulescienceexperiment"):allevents:length > 0 {
- goo:getmodule("modulescienceexperiment"):doevent("observe mystery goo").
- break.
- }.
- }.
- Print "[" + time:clock + "] Awaiting data transmission".
- log "[" + time:clock + "] Awaiting data transmission" to droplog.
- copy droplog to 0.
- set timer to time:seconds.
- set nodata to false.
- until comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
- if not discharged and ship:resources[0]:amount < lowbattlvl {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- if time:seconds - timer > commtimeout {
- set nodata to true.
- break.
- }
- wait 0.001.
- }.
- if nodata {
- Print "[" + time:clock + "] Aborting second ground level run due to no data to transmit".
- log "[" + time:clock + "] Aborting second ground level run due to no data to transmit" to droplog.
- copy droplog to 0.
- } else {
- Print "[" + time:clock + "] Data transmission has begun".
- log "[" + time:clock + "] Data transmission has begun" to droplog.
- copy droplog to 0.
- until time:seconds - transtime > transmissiontimeout {
- if not discharged and ship:resources[0]:amount < lowbattlvltrans {
- // if a capacitor is discharging, check that it is done
- if capactive > -1 {
- if caplist[capactive]:getmodule("dischargecapacitor"):getfield("status") = "discharged!" { set capactive to -1. }.
- } else {
- set capnum to 0.
- until capnum = caplist:length {
- if caplist[capnum]:getmodule("dischargecapacitor"):getfield("status") = "ready" {
- caplist[capnum]:getmodule("dischargecapacitor"):doevent("discharge capacitor").
- set capactive to capnum.
- Print "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag.
- log "[" + time:clock + "] Power levels low, discharging capacitor " + caplist[capnum]:tag to droplog.
- copy droplog to 0.
- break.
- }.
- set capnum to capnum + 1.
- }.
- if capnum = caplist:length {
- set discharged to true.
- Print "[" + time:clock + "] All capacitors drained".
- log "[" + time:clock + "] All capacitors drained" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- if probe:getmodule("modulespu"):getfield("spu") <> "operational." {
- Print "[" + time:clock + "] Connection lost".
- log "[" + time:clock + "] Connection lost" to droplog.
- copy droplog to 0.
- shutdown.
- }.
- if transtime < time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "uploading data..." {
- lock transtime to time:seconds.
- }.
- if transtime = time:seconds and comms:getmodule("modulertdatatransmitter"):getfield("comms") = "idle" {
- set transtime to time:seconds.
- }.
- wait 0.001.
- }.
- lock transtime to time:seconds.
- Print "[" + time:clock + "] Data transmission has ended".
- log "[" + time:clock + "] Data transmission has ended" to droplog.
- copy droplog to 0.
- }.
- }.
- }.
- Print "[" + time:clock + "] All events have executed".
- log "[" + time:clock + "] All events have executed" to droplog.
- copy droplog to 0.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement