Jump to content

kos script help


Recommended Posts

I want make my scrip to perform actions depend on ship name. When rocket is on launch pad  I programing lower kos processor with kos tag "Booster" to perform for example step "launch", then when its staging, using command "kuniverse:forcesetactivevessel" I wanna switch to Upper Stage of my rocket with kos processor tag "UpperStage"  and make him run step "Orbit", with construction like this:

"if Ship("Booster") {

runstep ("launch")"

}

"if Ship("UpperStage") {

runstep ("Orbit")"

}

Can someone help please?

Thanks 

 

 

Edited by Ev1I_
Link to comment
Share on other sites

15 hours ago, Ev1I_ said:

I want make my scrip to perform actions depend on ship name. When rocket is on launch pad  I programing lower kos processor with kos tag "Booster" to perform for example step "launch", then when its staging, using command "kuniverse:forcesetactivevessel" I wanna switch to Upper Stage of my rocket with kos processor tag "UpperStage"  and make him run step "Orbit", with construction like this:

"if Ship("Booster") {

runstep ("launch")"

}

"if Ship("UpperStage") {

runstep ("Orbit")"

}

Can someone help please?

Thanks 

 

 

I don't know how to answer the specific question you asked, but I do know how to use KOS to get a ship into orbit.

First, why are you using multiple kOS processors when just one (on the upper stage) would work fine?

Second, I think KSP treats a vessel as a single vessel when it's joined together, so forcesetactivevessel might not work.

Third, it's easier if you can put all your "steps" in one file, and make use of the WAIT UNTIL control before the next step happens.  As in:

DECLARE FUNCTION launch {
  // some code goes here
}
DECLARE FUNCTION orbit {
  // some code goes here
}

launch.
WAIT UNTIL ALTITUDE > 70000.
orbit.

Or you could make them run sequentially like:

set launching_is_done to FALSE.
DECLARE FUNCTION launch {
  // some code goes here
  return(TRUE).
}
DECLARE FUNCTION orbit {
  // some code goes here
}

WAIT UNTIL launch. // won't proceed until the last line of launch is executed, which returns TRUE
orbit.

My kOS launching code is set up like:

DECLARE some_constants.
DECLARE some_logging_functions.
WHEN ALTITUDE > 70000 then { stage fairings, etc. } // this won't trigger until much later
SET some_steering_parameters.
LOCK steering to some_steering_parameters.
stage. // launches ship
WHEN stage:liquidfuel < 0.1 THEN { 
                           stage. 
                           and do some other things. 
                           PRESERVE. // allows the WHEN to repeat next time youre out of fuel
                           }
WHEN ALTITUDE > 25000 THEN { lock steering to different_steering_parameters. }
WAIT UNTIL APOAPSIS > target_apoapsis.
set throttle to 0.
unlock steering.
run circularize_high // a different file that creates a maneuver node for circularization burn
run burnnode // a different file that executes the next maneuver node
// end of file; the real version is about 450 lines long, not counting circularize_high and burnnode

 

Link to comment
Share on other sites

6 hours ago, MrSystems said:

I don't know how to answer the specific question you asked, but I do know how to use KOS to get a ship into orbit.

First, why are you using multiple kOS processors when just one (on the upper stage) would work fine?

Second, I think KSP treats a vessel as a single vessel when it's joined together, so forcesetactivevessel might not work.

Third, it's easier if you can put all your "steps" in one file, and make use of the WAIT UNTIL control before the next step happens.  As in:


DECLARE FUNCTION launch {
  // some code goes here
}
DECLARE FUNCTION orbit {
  // some code goes here
}

launch.
WAIT UNTIL ALTITUDE > 70000.
orbit.

Or you could make them run sequentially like:


set launching_is_done to FALSE.
DECLARE FUNCTION launch {
  // some code goes here
  return(TRUE).
}
DECLARE FUNCTION orbit {
  // some code goes here
}

WAIT UNTIL launch. // won't proceed until the last line of launch is executed, which returns TRUE
orbit.

My kOS launching code is set up like:


DECLARE some_constants.
DECLARE some_logging_functions.
WHEN ALTITUDE > 70000 then { stage fairings, etc. } // this won't trigger until much later
SET some_steering_parameters.
LOCK steering to some_steering_parameters.
stage. // launches ship
WHEN stage:liquidfuel < 0.1 THEN { 
                           stage. 
                           and do some other things. 
                           PRESERVE. // allows the WHEN to repeat next time youre out of fuel
                           }
WHEN ALTITUDE > 25000 THEN { lock steering to different_steering_parameters. }
WAIT UNTIL APOAPSIS > target_apoapsis.
set throttle to 0.
unlock steering.
run circularize_high // a different file that creates a maneuver node for circularization burn
run burnnode // a different file that executes the next maneuver node
// end of file; the real version is about 450 lines long, not counting circularize_high and burnnode

 

Yeh I know how to get to orbit with single processor and script. But I want land my booster back to Earth/Kerbin, and here's the catch. 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...