Last active
November 2, 2018 20:20
-
-
Save danielboro/a2cd2379afa7b9aba5def6bab7024fcd to your computer and use it in GitHub Desktop.
collect science
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parameter onlyrerunnable is true. | |
GLOBAL SciP to SHIP:MODULESNAMED("ModuleScienceExperiment"). | |
FOR M IN SHIP:MODULESNAMED("DMModuleScienceAnimate") {SciP:add(M).}. | |
GLOBAL Scicont to SHIP:MODULESNAMED("ModuleScienceContainer"). | |
LOCAL scicrew to ship:CREW(). | |
LOCAL datalistname is "biomelist-"+ship:name+"-"+ship:body:name+".json". | |
GLOBAL allexp to false. | |
GLOBAL BIOME is false. | |
set BIOME to false. | |
GLOBAL VBIOMELIST is list(). | |
for kmem in scicrew if kmem:TRAIT="Scientist" set allexp to true. | |
set biomescanners to SHIP:MODULESNAMED("ModuleGPS"). | |
if not biomescanners:EMPTY { | |
set biomemodule to biomescanners[0]. | |
lock BIOME to biomemodule:GETFIELD("biome"). | |
} | |
GLOBAL oldbiome to true. | |
if EXISTS("getoldbiome.ks") run getoldbiome. | |
if EXISTS(datalistname) set VBIOMELIST to READJSON(datalistname). | |
else set VBIOMELIST to list(BIOME). | |
function get_visited_biomelist{ | |
if EXISTS(datalistname) return READJSON(datalistname). else return list(BIOME). | |
} | |
function get_biome{return BIOME.} | |
function set_oldbiome { | |
parameter mode. | |
log "" to getoldbiome.ks. deletepath("getoldbiome.ks"). | |
log "GLOBAL oldbiome to "+char(34)+ mode +char(34)+"." to getoldbiome.ks. | |
set oldbiome to mode. | |
} | |
function is_biome_new{ | |
if VBIOMELIST:CONTAINS(BIOME) return false. | |
else {VBIOMELIST:add(BIOME). WRITEJSON(VBIOMELIST,datalistname). return true.} | |
} | |
function get_all_science { | |
DECLARE parameter onlyrerunnable is NOT allexp. | |
FOR M IN SciP { | |
if (not m:inoperable) and ( not onlyrerunnable or (onlyrerunnable and m:rerunnable)) { | |
if not M:HASDATA {M:DEPLOY.} else if M:Data[0]:TRANSMITVALUE=0 {M:RESET(). wait 5. M:DEPLOY.} | |
} | |
} | |
} | |
function collect_all_science { | |
if Scicont:length>0 FOR M IN Scicont M:doaction("collect all",true). | |
} | |
function clear_all_science { | |
FOR M IN SciP { | |
if (not m:inoperable) { | |
M:RESET(). | |
if m:part:HASMODULE("DMMagBoomModule") and M:part:GETMODULE("DMMagBoomModule"):hasfield("bt") M:doaction("retract magnetometer",true). | |
} | |
} | |
} | |
function transmit_all_science { | |
DECLARE parameter onlyrerunnable is NOT allexp. | |
if HOMECONNECTION:isconnected | |
FOR M IN SciP { | |
if not m:inoperable if M:HASDATA and M:Data[0]:TRANSMITVALUE>0 and ( not onlyrerunnable or (onlyrerunnable and m:rerunnable)) {M:TRANSMIT.} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment