Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // !runscript 5kbYLJTV
- ship:controlpart:controlfrom().
- lock liquidmatched to min(ship:oxidizer * 9 / 11, ship:liquidfuel).
- lock nukeLiquid to max(0, ship:liquidfuel-liquidmatched).
- lock x to body:geopositionof(ship:facing:vector):heading.
- lock p to 0.
- lock b to 0.
- lock ralt to altitude - ship:geoposition:terrainheight.
- lock twr to ship:availablethrust/ship:mass/body:mu*body:position:sqrmagnitude.
- function displayDV {
- set oxidizermatched to min(ship:oxidizer, ship:liquidfuel * 11 / 9).
- set nukesfirstdv to Round(800 * 9.81 * ln(ship:mass / (ship:mass - (nukeLiquid * 0.005))), 5).
- set vectorsfirstdv to Round(315 * 9.81 * ln(ship:mass / (ship:mass - (liquidmatched * 0.005) - (oxidizermatched * 0.005))), 5).
- set nukeslastdv to Round(800 * 9.81 * ln((ship:mass - (oxidizermatched * 0.005 + liquidmatched * 0.005)) / (ship:mass - (oxidizermatched * 0.005 + liquidmatched * 0.005) - (nukeLiquid * 0.005))), 5).
- set vectorlastdv to Round(315 * 9.81 * ln((ship:mass - (nukeLiquid * 0.005)) / (ship:mass - (liquidmatched * 0.005) - (oxidizermatched * 0.005) - (nukeLiquid * 0.005))), 5).
- for res in ship:resources {
- if res:name = "liquidfuel"
- set lqcap to res:capacity.
- if res:name = "oxidizer"
- set oxcap to res:capacity.
- }
- set oxmass to oxcap * 0.005.
- set lqmatchmass to oxcap * 9 / 11 * 0.005.
- set nukesmaxdv to Round(800 * 9.81 * ln((ship:drymass + (lqcap * 0.005) ) / ship:drymass), 5).
- set vectormaxdv to Round(315 * 9.81 * ln((ship:drymass + lqmatchmass + oxmass ) / ship:drymass), 5).
- set justnukesdv to Round(800 * 9.81 * ln(ship:mass / (ship:mass - (ship:liquidfuel * 0.005))), 5).
- info(" nukes only: " + justnukesdv).
- info("").
- info(" vectors first: " + vectorsfirstdv).
- info(" nukes last: " + nukeslastdv).
- info("").
- info(" nukes first: " + nukesfirstdv).
- info(" vectors last: " + vectorlastdv).
- info("").
- info("nukes then vectors: " + (nukesfirstdv + vectorlastdv)).
- }
- set vectors to ship:partsdubbedpattern("vector").
- set nukes to ship:partsdubbedpattern("nuc").
- set turbos to ship:partsdubbedpattern("turbofan").
- set servos to ship:modulesnamed("ModuleRoboticRotationServo").
- set proprad to 5.8.
- for rap in ship:partsdubbedpattern("rapier") turbos:add(rap).
- set rotormods to ship:modulesnamed("ModuleRoboticServoRotor").
- set rotors to list().
- for rm in rotormods {
- local rotor to lexicon().
- if(rm:getfield("motor") <> "Unpowered")
- {
- set rotor["part"] to rm:part.
- set rotor["mod"] to rm.
- set rotor["blades"] to list().
- for bm in rm:part:ModulesNamed("ModuleControlSurface") {
- local bpart to bm:part.
- local blade to lexicon().
- set blade["mod"] to bm.
- set blade["offset"] to vdot(-bpart:Facing:starvector, bpart:position - bpart:parent:position).
- set blade["proprad"] to proprad.
- bm:setfield("deploy", true).
- rotor["blades"]:add(blade).
- }
- rotors:add(rotor).
- if rm:hasfield("torque limit(%)") rm:setfield("torque limit(%)", 0).
- }
- }
- function ImaRocket {
- props off.
- setangle(0).
- ship:dockingports[0]:controlfrom().
- startup(vectors).
- shutoff(nukes).
- shutoff(turbos).
- }
- function ImaJet {
- parameter resetengines is true.
- props off.
- ship:partsdubbedpattern("HathiCockpit")[0]:controlfrom().
- if resetengines shutoff(ship:engines).
- startup(turbos).
- }
- function ImaRocketPlane {
- props off.
- ship:partsdubbedpattern("HathiCockpit")[0]:controlfrom().
- startup(vectors).
- shutoff(turbos).
- shutoff(nukes).
- }
- function ImtheRedBaron {
- set steeringmanager:rollcontrolanglerange to 180.
- parameter resetengines is true.
- if resetengines shutoff(ship:engines).
- ship:partsdubbedpattern("HathiCockpit")[0]:controlfrom().
- for rotor in rotors {
- if rotor:mod:hasfield("torque limit(%)") rotor:mod:setfield("torque limit(%)", 100).
- if rotor:part:parent:name:contains("bay") {
- set baymod to rotor:part:parent:getmodule("ModuleAnimateGeneric").
- if baymod:hasevent("open") baymod:doevent("open").
- }
- }
- set props to true.
- lock rpmtarget to min(459,max(0, throttle * 460)).
- set props to true.
- for m in ship:modulesnamed("WBIModuleGeneratorFX") if m:hasevent("activate fusion power") m:doevent("activate fusion power").
- on round(time:seconds * 20) {
- if props {
- set rpmcopy to rpmtarget.
- for rotor in rotors {
- rotor:mod:setfield("rpm limit", rpmcopy ).
- set calcAirspeed to (2 * constant:pi * (rotor:blades[0]:proprad + rotor:blades[0]:offset) * rpmcopy/60).
- set deploycopy to max(3, 4.5 + arctan2(airspeed, calcAirspeed)).
- for blade in rotor:blades {
- blade:mod:setfield("deploy angle", deploycopy).
- }
- }
- } else {
- for rotor in rotors {
- if rotor:mod:hasfield("torque limit(%)") rotor:mod:setfield("torque limit(%)", 0).
- if rotor:part:parent:name:contains("bay") {
- set baymod to rotor:part:parent:getmodule("ModuleAnimateGeneric").
- if baymod:hasevent("close") baymod:doevent("close").
- }
- }
- for m in ship:modulesnamed("WBIModuleGeneratorFX") if m:hasevent("deactivate fusion power") m:doevent("deactivate fusion power").
- }
- return props.
- }
- }
- function GoToSleep {
- lock steering to "kill".
- gear on.
- setangle(90).
- wait 1.
- unlock steering.
- fuelCells off.
- radiators off.
- isru off.
- gear off.
- lights off.
- sas off.
- rcs off.
- set ev to "stop".
- for m in ship:modulesnamed("ModuleResourceConverter")
- for nn in m:allactionnames
- if nn:contains(ev)
- m:doaction(nn,true).
- for m in ship:modulesnamed("WBIModuleGeneratorFX")
- if m:hasevent("deactivate fusion power")
- m:doevent("deactivate fusion power").
- bays off.
- }
- function LevelUp {
- ship:modulesnamed("ModuleExperienceManagement")[0]:doevent("level up crew").
- }
- function SetEngines {
- parameter targetMode to "Activate Engine".
- parameter engines to ship:partsdubbedpattern("vector").
- for engine in engines {
- if engine:hasmodule("ModuleEnginesFx") set m to engine:getmodule("ModuleEnginesFx").
- if engine:hasmodule("ModuleEngines") set m to engine:getmodule("ModuleEngines").
- if m:hasaction(targetMode) m:doaction(targetMode, true).
- }
- }
- function shutoff {
- parameter engines to ship:partsdubbedpattern("vector").
- SetEngines("Shutdown Engine", engines).
- }
- function startup {
- parameter engines to ship:partsdubbedpattern("vector").
- SetEngines("Activate Engine", engines).
- }
- function ThrustLimit {
- parameter targetEngines.
- parameter targetThrust.
- for eng in targetEngines set eng:thrustlimit to targetThrust.
- }
- function SetAngle {
- parameter targetangle.
- for s in servos if s:hasfield("target angle") s:setfield("target angle", targetangle).
- }
- function info {
- parameter message.
- set logmessage to round(missionTime,1):ToString():padleft(6) + ": " + message.
- print logmessage.
- }
- function powertakeoffatmo {
- parameter h to 90.
- parameter runwayheight to round(altitude + 21).
- parameter initialPitch to 6.
- lock x to h.
- lock b to 0.
- lock p to initialPitch.
- lock aoa to arcsin(srfprograde:topvector*facing:vector).
- info("preparing for takeoff at runway height of " + runwayheight).
- ship:dockingports[0]:controlfrom().
- set angleup to false.
- lights on.
- shutoff(ship:engines).
- startup(vectors).
- thrustlimit(vectors, 100).
- setangle(0).
- wait 3.
- gear off.
- wait 1.
- info("hold position").
- lock steering to lookdirup(up:Vector*10-ship:Velocity:surface*0.03,ship:facing:topvector).
- for vec in vectors set vec:gimbal:limit to 6.
- rcs on.
- lock angletarget to 0.
- lock throttle to 1.
- when altitude > runwayheight then rcs off.
- when altitude > runwayheight - 7 then {
- info("rotate").
- gear off.
- brakes off.
- lock steering to lookdirup(up:Vector*10-ship:Velocity:surface*0.03,heading(h+180,0):vector).
- }
- when altitude > runwayheight - 1 and abs(steeringManager:angleerror) < 1 and abs(steeringManager:rollerror) < 1 and ship:angularvel:mag < 0.3 then {
- info("Prep flight steering").
- ship:partsdubbedpattern("cockpit")[0]:controlfrom().
- lock steering to heading(x,p,-b).
- set steeringmanager:rollcontrolanglerange to 180.
- lock angletarget to arcsin(up:vector*facing:vector).
- set angleup to true.
- wait 0.5.
- }
- when angleup and abs(steeringManager:angleerror) < 1 then {
- info("Switch to boosted plane flight").
- for vec in vectors set vec:gimbal:limit to 2.
- ImaJet(false).
- ImtheRedBaron(false).
- lock rpmtarget to 460.
- info("engage dynamic servo").
- lock angletarget to max(0, min(90,arcsin(up:vector*facing:vector)+verticalspeed*90)).
- }
- info("initialize vtols").
- // lock vlimit to max(50-(altitude - ship:geoposition:terrainheight),(-verticalspeed + (runwayheight-altitude))*100).
- // set vlimitcopy to vlimit.
- set anglecopy to angletarget.
- set autovector to true.
- when true then {
- set anglecopy to angletarget.
- SetAngle(anglecopy).
- print " servo angle: " + anglecopy at (0,1).
- print " p: " + p at (0,2).
- print " runwayheight: " + runwayheight at (0,3).
- print " twr:" + twr at (0,4).
- return autovector.
- }
- when airspeed > 150 then {
- info("storing vectors").
- shutoff(vectors).
- ThrustLimit(vectors, 100).
- SetAngle(90).
- set autovector to false.
- lock p to initialPitch.
- }
- }
- function takeoffatmo {
- parameter h to 90.
- parameter runwayheight to round(altitude + 21).
- parameter initialPitch to 10.
- lock x to h.
- lock b to 0.
- lock p to initialPitch.
- lock aoa to arcsin(srfprograde:topvector*facing:vector).
- info("preparing for takeoff at runway height of " + runwayheight).
- ship:dockingports[0]:controlfrom().
- set angleup to false.
- lights on.
- shutoff(ship:engines).
- startup(vectors).
- setangle(0).
- wait 3.
- info("hold position").
- set steeringmanager:rollcontrolanglerange to 180.
- lock steering to lookdirup(up:Vector*10-ship:Velocity:surface*0.03,ship:facing:topvector).
- for vec in vectors set vec:gimbal:limit to 6.
- rcs on.
- lock angletarget to 0.
- when ralt > runwayheight then rcs off.
- lock throttle to 1.
- when ralt > 3 then {
- info("rotate").
- gear off.
- brakes off.
- lock steering to lookdirup(up:Vector*10-ship:Velocity:surface*0.03,heading(h+180,0):vector).
- }
- when altitude > runwayheight-2 and abs(steeringManager:angleerror) < 1 and abs(steeringManager:rollerror) < 1 and ship:angularvel:mag < 0.1 then {
- info("Prep flight steering").
- ship:partsdubbedpattern("cockpit")[0]:controlfrom().
- lock steering to heading(x,p,-b).
- lock angletarget to arcsin(up:vector*facing:vector).
- set angleup to true.
- wait 0.5.
- }
- when angleup and abs(steeringManager:angleerror) < 1 then {
- info("Switch to boosted plane flight").
- for vec in vectors set vec:gimbal:limit to 2.
- ImaJet(false).
- ImtheRedBaron(false).
- info("engage dynamic servo").
- lock angletarget to max(0, min(90,arcsin(up:vector*facing:vector) + 100 - ((-verticalspeed + (runwayheight-altitude)/1.5)*100))).
- }
- info("initialize vtols").
- lock vlimit to max(50-(altitude - ship:geoposition:terrainheight),(-verticalspeed + (runwayheight-altitude))*100).
- set vlimitcopy to vlimit.
- set anglecopy to angletarget.
- when true then {
- set vlimitcopy to vlimit.
- set anglecopy to angletarget.
- ThrustLimit(vectors, vlimitcopy).
- SetAngle(anglecopy).
- print " v thrust: " + vlimitcopy at (0,0).
- print " servo angle: " + anglecopy at (0,1).
- print " p: " + p at (0,2).
- print " runwayheight: " + runwayheight at (0,3).
- print " twr:" + twr at (0,4).
- return altitude < runwayheight + 20.
- }
- when altitude > runwayheight + 20 then {
- info("storing vectors").
- shutoff(vectors).
- ThrustLimit(vectors, 100).
- SetAngle(90).
- }
- }
- function powerlandatmo {
- set navmode to "surface".
- props off.
- lock steering to srfprograde.
- set x to body:geopositionof(srfprograde:vector):heading.
- set p to 0.
- ship:partsdubbedpattern("cockpit")[0]:controlfrom().
- shutoff(ship:engines).
- thrustlimit(vectors, 0).
- startup(vectors).
- lock throttle to 1.
- set landing to true.
- on time:seconds {
- set vthrottle to 100*(-verticalspeed-2)-sqrt(2*max(1,(max(0.1,vdot(up:vector,vectors[0]:facing:vector))* availablethrust*0.85)/mass-body:mu/(body:radius^2))*max(altitude-geoposition:terrainheight-50+verticalspeed*0.5,0.1)).
- thrustlimit(vectors, vthrottle).
- print (" Thrust Limit:" + round(vthrottle)):padright(terminal:width) at (0,0).
- set vangle to max(-45,min(45,-groundspeed*vdot(ship:facing:vector, velocity:surface))).
- setangle(vangle).
- print (" Angle:" + round(vangle)):padright(terminal:width) at (0,1).
- print ("Alt above Ground:" + round(altitude - ship:geoposition:terrainheight)):padright(terminal:width) at (0,2).
- return landing.
- }
- when airspeed < 10 then {
- lock steering to heading(x,p).
- gear on.
- brakes on.
- }
- when ship:verticalspeed > 0 and altitude - ship:geoposition:terrainheight < 1000 and groundspeed < 10 then
- {
- lock throttle to 0.
- set landing to false.
- }
- }
- function landnukeonly {
- parameter targetgroundspeed is 200.
- list engines in es. for e in es e:shutdown().
- SetEngines("Activate Engine", nukes).
- info("reducing groundspeed to under " + targetgroundspeed).
- lock steering to -velocity:surface+vxcl(up:vector,-velocity:surface*0.3)+up:vector*5.
- lock throttle to choose groundspeed - targetgroundspeed if abs(steeringmanager:angleerror) < 5 else 0.
- wait until groundspeed < targetgroundspeed + 1.
- brakes on.
- gear on.
- lights on.
- wait until abs(steeringmanager:angleerror) < 5.
- set complete to false.
- info("begin final landing sequence").
- lock throttle to (-verticalspeed-1)-sqrt(2*max(1,(max(0.1,vdot(up:vector,ship:facing:vector))* availablethrust*0.7)/mass-body:mu/(body:radius^2))*max(altitude-geoposition:terrainheight-50+verticalspeed*0.5,0.1)).
- when verticalspeed > -2 and ralt < 45 and verticalspeed < 0 then {
- lock throttle to 0.
- lock steering to heading(90,0).
- set complete to true.
- }
- lock steering to lookdirup(-velocity:surface+vxcl(up:vector,-velocity:surface*0.3)+up:vector*5,heading(270,0):vector).
- when ship:status = "Landed" then info("welcome to " + body:name).
- }
- function landnoatmo {
- parameter targetgroundspeed is groundspeed / 2.
- info("reducing groundspeed to under " + targetgroundspeed).
- lock steering to -velocity:surface+vxcl(up:vector,-velocity:surface*0.3)+up:vector*5.
- lock throttle to choose groundspeed - targetgroundspeed if abs(steeringmanager:angleerror) < 5 else 0.
- when ship:liquidfuel < (ship:oxidizer * 9 / 11) + 0.4 then
- {
- info("switching to rockets").
- list engines in es. for e in es e:shutdown().
- SetEngines("Activate Engine", vectors).
- }
- wait until groundspeed < targetgroundspeed + 1.
- info("preparing final form").
- lock throttle to 0.
- list engines in es. for e in es e:shutdown().
- SetEngines("Activate Engine", vectors).
- SetAngle(0).
- rcs on.
- ship:dockingports[0]:controlfrom().
- brakes on.
- gear on.
- lights on.
- wait until abs(steeringmanager:angleerror) < 5.
- set complete to false.
- info("begin final landing sequence").
- lock throttle to (-verticalspeed-1)-sqrt(2*max(1,(max(0.1,vdot(up:vector,ship:facing:vector))* availablethrust*0.75)/mass-body:mu/(body:radius^2))*max(altitude-geoposition:terrainheight-60+verticalspeed*0.5,0.1)).
- when verticalspeed>0 and ralt < 1000 then {
- lock throttle to 0.
- lock steering to heading(90,90).
- set complete to true.
- }
- lock steering to lookdirup(-velocity:surface+vxcl(up:vector,-velocity:surface*0.3)+up:vector*5,heading(270,0):vector).
- wait until complete.
- info("welcome to " + body:name).
- }
- function takeoffnoatmo {
- parameter targetalt is 15e3.
- parameter targetpitch is 20.
- set steeringmanager:rollcontrolanglerange to 180.
- SetAngle (0).
- lights on.
- list engines in es. for e in es e:shutdown().
- SetEngines("Activate Engine", vectors).
- ship:dockingports[0]:controlfrom().
- rcs on.
- lock steering to heading(90,90).
- lock throttle to -verticalspeed + 5.
- when ralt > 100 and abs(steeringmanager:angleerror) < 5 then {
- lock throttle to 0.
- gear off.
- lights off.
- SetAngle(90).
- ship:partsdubbedpattern("HathiCockpit")[0]:controlfrom().
- lock steering to heading(90,targetpitch).
- wait 0.
- when abs(steeringmanager:angleerror) < 5 then lock throttle to targetalt - apoapsis.
- if nukeLiquid > 1 {
- SetEngines("Activate Engine", nukes).
- when nukeLiquid < 1 then SetEngines("Shutdown Engine", nukes).
- }
- }
- when apoapsis > targetalt -500 then {
- print "takeoff complete".
- lock throttle to 0.
- }
- }
- function takeoffnoatmo2 {
- parameter targetalt is 20e3.
- parameter climbangle is 20.
- ship:partsdubbedpattern("HathiCockpit")[0]:controlfrom().
- set steeringmanager:rollcontrolanglerange to 180.
- set autoangle to true. when autoangle then { setangle(90-vang(up:vector, ship:facing:vector)). return autoangle. }
- lights on.
- list engines in es. for e in es e:shutdown().
- SetEngines("Activate Engine", vectors).
- ThrustLimit(vectors, 100).
- rcs on.
- lock steering to heading(90,0).
- lock throttle to -verticalspeed + 5.
- brakes off.
- when ralt > 26 and abs(steeringmanager:angleerror) < 5 then {
- gear off.
- lights off.
- lock steering to heading(90,climbangle).
- wait 0.
- wait 0.
- when 90-vang(up:vector, ship:facing:vector) > climbangle then {
- lock throttle to targetalt - apoapsis.
- set autoangle to false. wait 0.
- SetAngle(90).
- }
- if nukeLiquid > 0 {
- SetEngines("Activate Engine", nukes).
- when nukeLiquid < 1 then SetEngines("Shutdown Engine", nukes).
- }
- }
- when apoapsis > targetalt -500 then {
- print "takeoff complete".
- lock throttle to 0.
- }
- }
- function powertakeoff {
- set steeringmanager:rollcontrolanglerange to 180.
- set x to 90.
- parameter targetalt is body:atm:height + 10e3.
- set climbangle to 85.
- lock p to max(0, 90*(1-(apoapsis/targetalt)^0.5)).
- ship:partsdubbedpattern("HathiCockpit")[0]:controlfrom().
- set steeringmanager:rollcontrolanglerange to 180.
- set autoangle to true.
- when autoangle then { setangle(90-vang(up:vector, ship:facing:vector)). return autoangle. }
- lights on.
- for en in ship:engines en:shutdown().
- SetEngines("Activate Engine", vectors).
- ThrustLimit(ship:engines, 100).
- rcs on.
- lock steering to heading(x,0).
- lock throttle to (targetalt-apoapsis+5e3)/10.
- brakes off.
- when ralt > 26 and abs(steeringmanager:angleerror) < 5 then {
- gear off.
- lights off.
- lock steering to heading(x,p).
- wait 0.
- wait 0.
- when 90-vang(up:vector, ship:facing:vector) > p-10 then {
- lock steering to heading(90,p).
- lock throttle to (targetalt-apoapsis+5e3)/1000.
- set autoangle to false. wait 0.
- SetAngle(90).
- if altitude < body:atm:height and airspeed < 300 {
- ImtheRedBaron(false).
- when airspeed > 300 then props off.
- }
- }
- if nukeLiquid > 1 {
- SetEngines("Activate Engine", nukes).
- when nukeLiquid < 1 then SetEngines("Shutdown Engine", nukes).
- }
- if body:atm:oxygen {startup(turbos).}
- }
- when apoapsis > targetalt -500 then {
- print "takeoff complete".
- lock throttle to 0.
- lock steering to srfprograde.
- }
- }
- function fuelfordvtarget {
- parameter targetRocketDv.
- parameter rocketisp to 315.
- set orewiggle to 0.1.
- fuelcells on.
- if ship:status = "landed" { deploydrills on. wait 3. drills on. }
- set res to gui(200, 100).
- Set res:x to -40.
- set res:y to 5.
- res:show.
- set reslist to list().
- for rs in ship:resources {
- set l to res:addlabel().
- Set l:style:fontsize to 20.
- reslist:add(l).
- }
- on time:seconds {
- set i to 0.
- for rs in ship:resources {
- set reslist[i]:text to rs:name + " " + round(rs:amount,1) + " / " + rs:capacity.
- set reslist[i]:style:textcolor to rgb(1 - rs:amount/rs:capacity, rs:amount/rs:capacity, 0.3).
- set i to i + 1.
- }
- return res:visible.
- }
- radiators on.
- lock liquidmatched to min(ship:oxidizer * 9 / 11, ship:liquidfuel).
- lock oxidizermatched to min(ship:oxidizer, ship:liquidfuel * 11 / 9).
- lock vectordv to Round(rocketisp * 9.81 * ln(ship:mass / (ship:mass - (liquidmatched * 0.005) - (oxidizermatched * 0.005))), 5).
- print vectordv.
- set isrs to ship:modulesnamed("ModuleResourceConverter").
- set warp to 1. wait 1. set warp to 6.
- if(vectordv < targetRocketDv and ship:oxidizer * 9 / 11 <= ship:liquidfuel)
- {
- print "refilling ox to match liquid".
- for isr in isrs { if isr:hasaction("start isru [ox]") isr:doaction("start isru [ox]",true).}
- set warp to 1. wait 1. set warp to 5.
- wait until ship:oxidizer * 9 / 11 >= ship:liquidfuel or vectordv >= targetRocketDv or ship:ore < orewiggle.
- }
- isru off.
- if(vectordv < targetRocketDv)
- {
- print "refilling lf + o to match dv target".
- for isr in isrs { if isr:hasaction("start isru [lf+ox]") isr:doaction("start isru [lf+ox]",true).}
- wait until vectordv >= targetRocketDv or (ship:ore < orewiggle and ship:status <> "Landed").
- }
- isru off.
- for isr in isrs { if isr:hasaction("start isru [lqdfuel]") isr:doaction("start isru [lqdfuel]",true).}
- print "converting remaining ore to liquidfuel".
- wait until choose ship:ore > 550 if ship:status = "landed" else ship:ore < orewiggle and ship:liquidfuel > 38e3.
- isru off.
- set warp to 0.
- if ship:status = "landed" { deploydrills off. }
- radiators off.
- fuelcells off.
- print "Fuel Converted".
- res:hide.
- }
- function fuelmaxvectors{
- set orewiggle to 0.1.
- fuelcells on.
- if ship:status = "landed" { deploydrills on. wait 3. drills on. }
- set res to gui(200, 100).
- Set res:x to -40.
- set res:y to 5.
- res:show.
- set reslist to list().
- for rs in ship:resources {
- set l to res:addlabel().
- Set l:style:fontsize to 20.
- reslist:add(l).
- if rs:name:contains("oxidizer") set oxmax to rs:capacity.
- }
- on time:seconds {
- set i to 0.
- for rs in ship:resources {
- set reslist[i]:text to rs:name + " " + round(rs:amount,1) + " / " + rs:capacity.
- set reslist[i]:style:textcolor to rgb(1 - rs:amount/rs:capacity, rs:amount/rs:capacity, 0.3).
- set i to i + 1.
- }
- return res:visible.
- }
- radiators on.
- lock liquidmatched to min(ship:oxidizer * 9 / 11, ship:liquidfuel).
- lock oxidizermatched to min(ship:oxidizer, ship:liquidfuel * 11 / 9).
- set isrs to ship:modulesnamed("ModuleResourceConverter").
- set warp to 1. wait 1. set warp to 6.
- if(ship:oxidizer * 9 / 11 <= ship:liquidfuel)
- {
- print "refilling ox to match liquid".
- for isr in isrs { if isr:hasaction("start isru [ox]") isr:doaction("start isru [ox]",true).}
- set warp to 1. wait 1. set warp to 6.
- wait until ship:oxidizer * 9 / 11 >= ship:liquidfuel or ship:oxidizer >= oxmax.
- }
- isru off.
- print "refilling lf + o to match dv target".
- for isr in isrs { if isr:hasaction("start isru [lf+ox]") isr:doaction("start isru [lf+ox]",true).}
- wait until ship:oxidizer >= oxmax.
- isru off.
- set warp to 0.
- if ship:status = "landed" { deploydrills off. }
- radiators off.
- fuelcells off.
- print "Fuel Converted".
- res:hide.
- }
- clearscreen. wait 0.
- print "Welcome to " + ship:name.
- for i in range(terminal:height-3) Print "":padright(terminal:width).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement