Jump to content

stargateat77

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by stargateat77

  1. Hey guys, I have a problem with my second ever script.  It is intended to launch a rocket, circularize in LKO, perform scientific experiments and recover the capsule. I dont know why, but all of a sudden kOS seems to restart when my ship reaches about 75km. The Terminal Window just "reboots", showing the exact same data it does when starting up on the launchpad. Does anybody have a clue why this happens? Or did someone have a similar problem? 

    Thanks so much for your help!

    Finn

    //Test01 REMASTERED 
    //Goal: Launch a Capsule into Orbit, perform experiments and return home safely.
    
    //Set the ship to a known configuration
    SAS off.
    RCS on.
    lights on.
    lock throttle to 0. //Throttle is a decimal from 0.0 to 1.0
    gear off.
    set fuel to 0.
    
    clearscreen.
    
    set targetApoapsis to 80000. //Target apoapsis in meters
    set targetPeriapsis to 80000. //Target periapsis in meters
    
    set runmode to 2. //Safety in case we start mid-flight
    if ALT:RADAR < 100 { //Guess if we are waiting for take off
        set runmode to 1.
        }
    
    print "Initating launch sequence.".
    wait 1.
    print "T-3 to Engine Ignition.".
    wait 1.
    print "T-2".
    wait 1.
    print "T-1".
    wait 1.
    print "Lift off!".
    
    until runmode = 0 { //Run until we end the program
    
        if runmode = 1 { //Ship is on the launchpad
            lock steering to UP.  //Point the rocket straight up
            set TVAL to 1.        //Throttle up to 100%
            stage.                //Same thing as pressing Space-bar
            set runmode to 2.     //Go to the next runmode
        }
    
        else if runmode = 2 { // Fly UP to 10,000m
            lock steering to heading (90,90). //Straight up.
            set TVAL to 1.
            if SHIP:ALTITUDE > 10000 { 
                //Once altitude is higher than 10km, go to Gravity Turn mode
                set runmode to 3.
            }
        }
    
        else if runmode = 3 { //Gravity turn
            set targetPitch to max( 5, 90 * (1 - ALT:RADAR / 50000)).  //Pitch over gradually until levelling out to 5 degrees at 50km
            lock steering to heading ( 90, targetPitch). //Heading 90' (East), then target pitch
            set TVAL to 1.
    		if SHIP:APOAPSIS > targetApoapsis {
                set runmode to 4.
            }
        }
        
        else if runmode = 4 { //Coast to Ap
            lock steering to heading ( 90, 3). //Stay pointing 3 degrees above horizon
            set TVAL to 0. //Engines off.
           	set runmode to 5.
        }
    
        else if runmode = 5 { //Burn to raise Periapsis
            if (ETA:APOAPSIS < 15) or (VERTICALSPEED < 0) { //If we're less then 15 seconds from Ap or loosing altitude
                set TVAL to 1.
            }
            if (SHIP:PERIAPSIS > targetPeriapsis) or (SHIP:PERIAPSIS > targetApoapsis * 0.95) {
                //If the periapsis is high enough or getting close to the apoapsis
                set TVAL to 0.
                set runmode to 6.
            }
        }
    
        else if runmode = 6 { //Final touches
            set TVAL to 0. //Shutdown engine.
            panels on.     //Deploy solar panels
            lights on.
            unlock steering.
            print "Stable Orbit around Kerbin reached.".
            wait 6.
            print "Beginning scientific Experiments.".
            wait 1.
            toggle ag1.
            wait 6.
            print "All data collected!".
            toggle ag2.
            set runmode to 7.
        }
    
        else if runmode = 7 { //Wait for the ship to reach Apoapsis
           if ETA:APOAPSIS < 10{
        		set WARP to 0.
           		wait 2.
           		lock steering to retrograde.
           		wait 3.
           		until SHIP:PERIAPSIS < 28000{
           				lock throttle to 1.
           		}
           	}
           	lock throttle to 0.
           	set runmode to 8.
        }
    
        else if runmode = 8{
           		if ALT:RADAR < 80000 {
           			stage.
           			set runmode to 9.
           		}
        }
    
        else if runmode = 9{
        	if ALT:RADAR < 4500 {
        		stage.
        		unlock steering.
        		set runmode to 10.
        	}
        }
    
        else if runmode = 10{
        	if ALT:RADAR < 2500 {
        		stage.
        		set runmode to 0.
        	}
        }
    
        //Housekeeping
        if stage:Liquidfuel < 1 and fuel < 2 { //Stage if the stage is out of fuel
            lock throttle to 0.
            wait 2.
            stage.
            set fuel to fuel+1.
            wait 3.
            lock throttle to TVAL.
        }
    
        set finalTVAL to TVAL.
        lock throttle to finalTVAL. //Write our planned throttle to the physical throttle
        
    }

     

×
×
  • Create New...