Skip to content

Instantly share code, notes, and snippets.

@darkbushido
Created February 27, 2017 17:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkbushido/e8197aff208491c9739bd37350606ae0 to your computer and use it in GitHub Desktop.
Save darkbushido/e8197aff208491c9739bd37350606ae0 to your computer and use it in GitHub Desktop.
function highlight_part {
parameter SP, SM.
if not SM:HASDATA and not SM:INOPERABLE { HIGHLIGHT(SP, BLUE). return true. }
else if SM:HASDATA { HIGHLIGHT(SP, GREEN). }
else { HIGHLIGHT(SP, YELLOW). return false. }
}
function collect_science {
local SL to lex(). local SMS to lex().
local DMMS to list("ModuleScienceExperiment", "DMModuleScienceAnimate", "DMBathymetry").
for module_name in DMMS {
for SM in SHIP:ModulesNamed(module_name) {
local SP to SM:PART.
if NOT SMS:HASKEY(SP:NAME) {
if highlight_part(SP, SM) SMS:ADD(SP:NAME, LIST(SM)).
} else if SMS:HASKEY(SP:NAME) AND NOT SMS[SP:NAME]:CONTAINS(SP) {
if highlight_part(SP, SM) SMS[SP:NAME]:ADD(SM).
}
}}
for SM_name in SMS:KEYS {
print "Collecting Science From: "+SM_name.
if SM_name = "dmUSPresTemp" {for SM in SMS[SM_name] { do_science(SM). }}
else { SET SM to SMS[SM_name][0]. do_science(SM).}
}
wait 5.
transfer_science().
wait 5.
}
function do_science {
parameter SM.
if not SM:HASDATA and not SM:INOPERABLE {
local t to time:seconds.
HIGHLIGHT(SM:PART, RED). SM:DEPLOY.
until (SM:HASDATA or (time:seconds > t+10)) {
print ".". wait 1.
}
}}
function transfer_science {
for sc in ship:modulesnamed("ModuleScienceContainer") {
print "Transfering Science".
sc:doaction("collect all", true).
wait 0.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment