Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

Advice i would give anyone trying to do this:

Start with the very simplest and smallest form first. If there is enough interest in that then you can expand it to cover more and more cases. I am excited to see this :)

Is there any way to easily hook into the screen buffer, or will I have to create a new class to handle multiple buffers? Specifically, I'm thinking of just displaying the screen, but I don't want to lock out (or be locked out by) the default terminal window. And since there's only one shared.Screen... :P

I suppose a wrapper class that taps into the output would be easy enough. I think...

Link to comment
Share on other sites

Could you change the docs/wiki to remove that Top of the Page box and button? That box takes up like a 1/10th of my already limited screen and it very, very annoying and frustrating. Not to mention if someone REALLY needed to go to the top of the page, they could just scroll up. Or move it to a small box on the top left/right corners so its not covering any test?

Link to comment
Share on other sites

Could you change the docs/wiki to remove that Top of the Page box and button?

Oh please yes. I took up the task of writing much of the docs but that styling was there before I started. I dislike it especially as when I link direct to the middle of a page with an HTML anchor tag, the annoying banner covers up the header line of the section I'm linking to.

Link to comment
Share on other sites

Is there any way to easily hook into the screen buffer, or will I have to create a new class to handle multiple buffers? Specifically, I'm thinking of just displaying the screen, but I don't want to lock out (or be locked out by) the default terminal window. And since there's only one shared.Screen... :P

I suppose a wrapper class that taps into the output would be easy enough. I think...

This is an excellent idea, but I'd warn you of a couple of things.

1 - There is more than one screen. There is one PER SCS part. If you have 2 parts on the craft, there will be 2 screens because each SCS part has its own "shared" block of stuff.

2 - Be careful about the screen buffer method, because one far-flung future thing I want to do is stop it with this annoying direct-to-screenbuffer style of terminal interaction the mod has. People have wanted to make the terminal remotable with things like ssh and in my opinion the very first step of that has to be to first divorce the terminal entirely from the rest of kOS such that kOS is forced to talk to the terminal via a stream interface - translating key events into streams of chars, and doing all screen manipulations with a common well known set of character control codes like ANSII or VT100 (so that you can attach a terminal emulator program like Putty or a UNIX Bash shell in a terminal window to it). As this is a thing I'd like to do, relying on the screenbuffer technique may not be a good idea. (In fact for what you're doing, maybe getting the terminal divorced from kOS like that might be the first thing you have to do.)

Edited by Steven Mading
Link to comment
Share on other sites

I need help from KOS gurus to understand what I'm doing wrong... The rocket doesn't keep the apoapsis at 100Km on last burn to establish the orbit (11 seconds on eta:apoapsis) ... it always end up with periapsis of 99Km and with apoapsis of 1,800,000Km :/

Thanks

LIGHTS ON.
RAS OFF.
SAS OFF.
SET alt1 TO 100000. // Target Orbit.
SET heading1 TO 90. // Launch Heading. Usage 0-360 where 0=North.
SET rollalt TO 8000. // Altitude at which to perform the initial roll
SET CountDown TO -10. // Countdown value
SET curFace to SHIP:Facing.
SET totallf TO SHIP:LIQUIDFUEL. // Set total liquidfuel in the ship
SET boosterslf TO 2*(3*180). // set total liquidfuel in the two boosters
SET X TO 0.
SET Y TO 1.
SET flag_ditch_boosters TO 0.
SET flag_jettison_fairings TO 0.

CLEARSCREEN.
PRINT "Orbit altitude set to [" + alt1 + "m]" at (X-1,Y).
//**Begin Countdown.
PRINT MISSIONTIME + " Count down: " at (X,Y).
UNTIL CountDown = -3 {
PRINT "..." + CountDown + " " at (X,Y).
SET CountDown TO CountDown + 1.
WAIT 1.
}.
//**Ignition.
LOCK THROTTLE TO 1.
LOCK STEERING TO UP.
WAIT 2.

SET msg TO round(missiontime,0) + "s Ignition!!! ".
UNTIL SHIP:MAXTHRUST > 0 {

LOCK STEERING TO UP + R(0,0,180).
run screen(X,Y,msg).

STAGE.
}.
PRINT "-2 " at (X,Y).
wait 1.
PRINT "-1 " at (X,Y). wait 1.
CLEARSCREEN.

//**Release the clamps.
STAGE.

//**To make a rotation relative to ships current direction.
//LOCK STEERING TO curFace + R(30,0,0).
//LOCK foreDir to SHIP:FACING * V(0,0,1).
//LOCK foreUnit to foreDir:VECTOR.
//**In flight.

SET msg TO "Launch!!! ".
LOCK STEERING TO UP + R(0,0,180).
UNTIL ALTITUDE > rollalt {

run screen(X,Y,msg).

IF ship:liquidfuel < (totallf - boosterslf) AND flag_ditch_boosters = 0 {
SET msg TO "Release boosters ".
STAGE.
SET flag_ditch_boosters TO 1.
}

}.

SET msg TO "Beginning gravity turn ".
LOCK STEERING TO UP + R(0,0,180) + R(0,-50,0).
//LOCK STEERING TO HEADING (90,40).

UNTIL APOAPSIS >= alt1 {

IF ship:liquidfuel < (totallf - boosterslf) AND flag_ditch_boosters = 0 {
SET msg TO "Release boosters ".
STAGE.
SET flag_ditch_boosters TO 1.
}.

run screen(X,Y,msg).



IF apoapsis < alt1 {
LOCK THROTTLE TO 1.
}.
IF apoapsis > alt1 - 500 {
LOCK THROTTLE TO 0.
LOCK STEERING TO PROGRADE.
}.

IF altitude > 40000 AND flag_jettison_fairings = 0 {
SAS ON.
SET msg TO "Jettison fairings... ".
STAGE.
SET flag_jettison_fairings TO 1.
LOCK STEERING TO PROGRADE.
TOGGLE AG9.
SAS OFF.
}.

IF stage:liquidfuel < 10 {
STAGE.
}.


}.
SET msg TO "Waiting for circularization burn. ".
UNTIL eta:apoapsis < 11 {

LOCK THROTTLE TO 0.
//LOCK STEERING TO PROGRADE.
LOCK STEERING TO UP + R(0,-90,-90).

//SET msg TO "Burn... ".
run screen(X,Y,msg).

//WAIT UNTIL ETA:APOAPSIS < 15.
}.
LOCK THROTTLE TO 1.
LOCK STEERING TO PROGRADE.
SET msg TO "Burn... ".

run screen(X,Y,msg).

WHEN periapsis > alt1 - 500 {
LOCK THROTTLE TO 0.
UNLOCK STEERING.
SAS ON.
SET msg TO "Orbit established!!! ".
run screen(X,Y,msg).

}
//WAIT UNTIL periapsis > alt1 - 500.
SET msg TO "Orbit established!!! ".

run screen(X,Y,msg).

Link to comment
Share on other sites

This is an excellent idea, but I'd warn you of a couple of things.

1 - There is more than one screen. There is one PER SCS part. If you have 2 parts on the craft, there will be 2 screens because each SCS part has its own "shared" block of stuff.

2 - Be careful about the screen buffer method, because one far-flung future thing I want to do is stop it with this annoying direct-to-screenbuffer style of terminal interaction the mod has. People have wanted to make the terminal remotable with things like ssh and in my opinion the very first step of that has to be to first divorce the terminal entirely from the rest of kOS such that kOS is forced to talk to the terminal via a stream interface - translating key events into streams of chars, and doing all screen manipulations with a common well known set of character control codes like ANSII or VT100 (so that you can attach a terminal emulator program like Putty or a UNIX Bash shell in a terminal window to it). As this is a thing I'd like to do, relying on the screenbuffer technique may not be a good idea. (In fact for what you're doing, maybe getting the terminal divorced from kOS like that might be the first thing you have to do.)

Yes, the need to handle multiple SCS parts is in my head already... Possibly even a way to interact at a basic level with kOS parts that don't have a processor (you are planning on storage-only parts, aren't you?).

Now, on to the fun bits... In order to decouple the kOSProcessor from the screen buffer in that way, you'll (we'll?) need to create a terminal class that supports whatever control code set is chosen (I'm thinking "whatever's easiest") as an interface for the GUI terminal, and I'll have to do the same for the RPM screens.

Maybe that's where I should start focusing my efforts. On developing/finding a terminal emulator for some control set...

Link to comment
Share on other sites

Maybe that's where I should start focusing my efforts. On developing/finding a terminal emulator for some control set...

I would prefer for it to be something very common and universally used. I don't want to have to say "you must get THIS particular terminal emulator from THIS particular vendor..." to people trying to use putty or a bash command line to get to it. If it supported something like VT220 codes or ANSI codes then most terminal emulator systems would handle it out-of-the-box.

I'd love for this to work some day:

User is playing the game on Whatever OS - Let's say Windows.

User clicks an option on one of the kOS SCS parts and enables "allow ssh on this part", and types a password for it.

User on some other computer, say Linux or MacOS or even a crude terminal attached to a Raspberry Pi opens a native terminal window and gets the default bash prompt.

User at the bash prompt enters command "ssh [email protected]", goes through password stuff, and now their native terminal window *BECOMES* the kOS terminal window.

Link to comment
Share on other sites

I need help from KOS gurus to understand what I'm doing wrong... The rocket doesn't keep the apoapsis at 100Km on last burn to establish the orbit (11 seconds on eta:apoapsis) ... it always end up with periapsis of 99Km and with apoapsis of 1,800,000Km :/

Thanks

LIGHTS ON.
RAS OFF.
SAS OFF.
SET alt1 TO 100000. // Target Orbit.
SET heading1 TO 90. // Launch Heading. Usage 0-360 where 0=North.
SET rollalt TO 8000. // Altitude at which to perform the initial roll
SET CountDown TO -10. // Countdown value
SET curFace to SHIP:Facing.
SET totallf TO SHIP:LIQUIDFUEL. // Set total liquidfuel in the ship
SET boosterslf TO 2*(3*180). // set total liquidfuel in the two boosters
SET X TO 0.
SET Y TO 1.
SET flag_ditch_boosters TO 0.
SET flag_jettison_fairings TO 0.

CLEARSCREEN.
PRINT "Orbit altitude set to [" + alt1 + "m]" at (X-1,Y).
//**Begin Countdown.
PRINT MISSIONTIME + " Count down: " at (X,Y).
UNTIL CountDown = -3 {
PRINT "..." + CountDown + " " at (X,Y).
SET CountDown TO CountDown + 1.
WAIT 1.
}.
//**Ignition.
LOCK THROTTLE TO 1.
LOCK STEERING TO UP.
WAIT 2.

SET msg TO round(missiontime,0) + "s Ignition!!! ".
UNTIL SHIP:MAXTHRUST > 0 {

LOCK STEERING TO UP + R(0,0,180).
run screen(X,Y,msg).

STAGE.
}.
PRINT "-2 " at (X,Y).
wait 1.
PRINT "-1 " at (X,Y). wait 1.
CLEARSCREEN.

//**Release the clamps.
STAGE.

//**To make a rotation relative to ships current direction.
//LOCK STEERING TO curFace + R(30,0,0).
//LOCK foreDir to SHIP:FACING * V(0,0,1).
//LOCK foreUnit to foreDir:VECTOR.
//**In flight.

SET msg TO "Launch!!! ".
LOCK STEERING TO UP + R(0,0,180).
UNTIL ALTITUDE > rollalt {

run screen(X,Y,msg).

IF ship:liquidfuel < (totallf - boosterslf) AND flag_ditch_boosters = 0 {
SET msg TO "Release boosters ".
STAGE.
SET flag_ditch_boosters TO 1.
}

}.

SET msg TO "Beginning gravity turn ".
LOCK STEERING TO UP + R(0,0,180) + R(0,-50,0).
//LOCK STEERING TO HEADING (90,40).

UNTIL APOAPSIS >= alt1 {

IF ship:liquidfuel < (totallf - boosterslf) AND flag_ditch_boosters = 0 {
SET msg TO "Release boosters ".
STAGE.
SET flag_ditch_boosters TO 1.
}.

run screen(X,Y,msg).



IF apoapsis < alt1 {
LOCK THROTTLE TO 1.
}.
IF apoapsis > alt1 - 500 {
LOCK THROTTLE TO 0.
LOCK STEERING TO PROGRADE.
}.

IF altitude > 40000 AND flag_jettison_fairings = 0 {
SAS ON.
SET msg TO "Jettison fairings... ".
STAGE.
SET flag_jettison_fairings TO 1.
LOCK STEERING TO PROGRADE.
TOGGLE AG9.
SAS OFF.
}.

IF stage:liquidfuel < 10 {
STAGE.
}.


}.
SET msg TO "Waiting for circularization burn. ".
UNTIL eta:apoapsis < 11 {

LOCK THROTTLE TO 0.
//LOCK STEERING TO PROGRADE.
LOCK STEERING TO UP + R(0,-90,-90).

//SET msg TO "Burn... ".
run screen(X,Y,msg).

//WAIT UNTIL ETA:APOAPSIS < 15.
}.
LOCK THROTTLE TO 1.
LOCK STEERING TO PROGRADE.
SET msg TO "Burn... ".

run screen(X,Y,msg).

WHEN periapsis > alt1 - 500 {
LOCK THROTTLE TO 0.
UNLOCK STEERING.
SAS ON.
SET msg TO "Orbit established!!! ".
run screen(X,Y,msg).

}
//WAIT UNTIL periapsis > alt1 - 500.
SET msg TO "Orbit established!!! ".

run screen(X,Y,msg).

I assume you never see the "Orbit Established!!!" message? I think your trouble is that getting within 500 meters of circulation is not happening.

The circularization burn is trying to reduce your eccentricity to as close to 0 as possible right?

so a simple fix for this that i have used is to have the code watch your eccentricity and stop burning when eccentricity starts to rise again. It gets you pretty close.

Link to comment
Share on other sites

Answer: not yet, it is in our backlog to allow it.

You can use action groups for input instead. Of course realize hat while doing so you only have 10 and each one you use takes it away from the user being able to use without accidentally triggering something in your script as well.

Link to comment
Share on other sites

You can use action groups for input instead. Of course realize hat while doing so you only have 10 and each one you use takes it away from the user being able to use without accidentally triggering something in your script as well.

And the other messy thing is that to use action groups you have to let the keypress be handled by KSP and NOT by the terminal window so KSP will trigger the action group when you press '1' or '2' etc. That means that this technique, rather bizzarely, requires that you have the terminal window unclicked (partly transparent) at the time you press the key, which is really non-inituitive.

Link to comment
Share on other sites

I need help from KOS gurus to understand what I'm doing wrong... The rocket doesn't keep the apoapsis at 100Km on last burn to establish the orbit (11 seconds on eta:apoapsis) ... it always end up with periapsis of 99Km and with apoapsis of 1,800,000Km :/

Thanks

LIGHTS ON.
RAS OFF.
SAS OFF.
SET alt1 TO 100000. // Target Orbit.
SET heading1 TO 90. // Launch Heading. Usage 0-360 where 0=North.
SET rollalt TO 8000. // Altitude at which to perform the initial roll
SET CountDown TO -10. // Countdown value
SET curFace to SHIP:Facing.
SET totallf TO SHIP:LIQUIDFUEL. // Set total liquidfuel in the ship
SET boosterslf TO 2*(3*180). // set total liquidfuel in the two boosters
SET X TO 0.
SET Y TO 1.
SET flag_ditch_boosters TO 0.
SET flag_jettison_fairings TO 0.

CLEARSCREEN.
PRINT "Orbit altitude set to [" + alt1 + "m]" at (X-1,Y).
//**Begin Countdown.
PRINT MISSIONTIME + " Count down: " at (X,Y).
UNTIL CountDown = -3 {
PRINT "..." + CountDown + " " at (X,Y).
SET CountDown TO CountDown + 1.
WAIT 1.
}.
//**Ignition.
LOCK THROTTLE TO 1.
LOCK STEERING TO UP.
WAIT 2.

SET msg TO round(missiontime,0) + "s Ignition!!! ".
UNTIL SHIP:MAXTHRUST > 0 {

LOCK STEERING TO UP + R(0,0,180).
run screen(X,Y,msg).

STAGE.
}.
PRINT "-2 " at (X,Y).
wait 1.
PRINT "-1 " at (X,Y). wait 1.
CLEARSCREEN.

//**Release the clamps.
STAGE.

//**To make a rotation relative to ships current direction.
//LOCK STEERING TO curFace + R(30,0,0).
//LOCK foreDir to SHIP:FACING * V(0,0,1).
//LOCK foreUnit to foreDir:VECTOR.
//**In flight.

SET msg TO "Launch!!! ".
LOCK STEERING TO UP + R(0,0,180).
UNTIL ALTITUDE > rollalt {

run screen(X,Y,msg).

IF ship:liquidfuel < (totallf - boosterslf) AND flag_ditch_boosters = 0 {
SET msg TO "Release boosters ".
STAGE.
SET flag_ditch_boosters TO 1.
}

}.

SET msg TO "Beginning gravity turn ".
LOCK STEERING TO UP + R(0,0,180) + R(0,-50,0).
//LOCK STEERING TO HEADING (90,40).

UNTIL APOAPSIS >= alt1 {

IF ship:liquidfuel < (totallf - boosterslf) AND flag_ditch_boosters = 0 {
SET msg TO "Release boosters ".
STAGE.
SET flag_ditch_boosters TO 1.
}.

run screen(X,Y,msg).



IF apoapsis < alt1 {
LOCK THROTTLE TO 1.
}.
IF apoapsis > alt1 - 500 {
LOCK THROTTLE TO 0.
LOCK STEERING TO PROGRADE.
}.

IF altitude > 40000 AND flag_jettison_fairings = 0 {
SAS ON.
SET msg TO "Jettison fairings... ".
STAGE.
SET flag_jettison_fairings TO 1.
LOCK STEERING TO PROGRADE.
TOGGLE AG9.
SAS OFF.
}.

IF stage:liquidfuel < 10 {
STAGE.
}.


}.
SET msg TO "Waiting for circularization burn. ".
UNTIL eta:apoapsis < 11 {

LOCK THROTTLE TO 0.
//LOCK STEERING TO PROGRADE.
LOCK STEERING TO UP + R(0,-90,-90).

//SET msg TO "Burn... ".
run screen(X,Y,msg).

//WAIT UNTIL ETA:APOAPSIS < 15.
}.
LOCK THROTTLE TO 1.
LOCK STEERING TO PROGRADE.
SET msg TO "Burn... ".

run screen(X,Y,msg).

WHEN periapsis > alt1 - 500 {
LOCK THROTTLE TO 0.
UNLOCK STEERING.
SAS ON.
SET msg TO "Orbit established!!! ".
run screen(X,Y,msg).

}
//WAIT UNTIL periapsis > alt1 - 500.
SET msg TO "Orbit established!!! ".

run screen(X,Y,msg).

The problem is that the apses become degenerate (ambiguous) when the orbit is circular. I.e. your apoapsis moves when you are burning strictly prograde. The usual solution to this is to burn until the proper orbital speed is attained. This prevents pushing the apoapsis to the other side of the planet. It's easy to calculate:

[FONT=courier new]SET target_speed TO SQRT(KERBIN:MU / (target_altitude + KERBIN:RADIUS)).[/FONT]

Also, I found the best burn direction to be prograde at apoapsis, not your ship's current prograde:

[FONT=courier new]LOCK velocity_at_apo TO VELOCITYAT(SHIP, TIME:SECONDS + ETA:APOAPSIS):ORBIT.[/FONT]
[FONT=courier new]LOCK heading_at_apo TO velocity_at_apo:DIRECTION.[/FONT]

Finally, if your TWR is high, I recommend to reduce your throttle in the last 5% of the burn to really get an accurate cut-off. Hope this helps!

Edited by Lorentz
equation correction (missing paren), added quote to original post
Link to comment
Share on other sites

Is there a way to trigger on a staging event? Something like:

ON STAGE { PRINT "Staging.". }

Or perhaps a way to get the ship's current stage number?


SET stage_number TO SHIP:STAGE.
WHEN SHIP:STAGE < stage_number {
PRINT "Staging.".
SET stage_number TO SHIP:STAGE.
}

Link to comment
Share on other sites

Just a quick question... and I've only been able to find information on older versions.

I have a water drone repeater that I built last night, the KOs code works great, however when I get out of signal range all controll from KOs is lost.

Is that a known bug? Currently at work and can't access Github, but when I experienced the issue it was 2am last night so I gave up and went to sleep :P

Mods I'm using - All the mods are the latest available.

KOs v0.14.2

RemoteTech2 1.5.1

Near Future - Electrical/Construction

Karbonite

USI MKS Colonization

RosterProp

KWRocketry

Infernal Robotics

Snacks.

I was thinking about adding in the ModuleManager code to add in the ModuleSPU to the KOs Parts config, but figured I'd check while I'm still at work.

Any help would be great.

Link to comment
Share on other sites

The problem is that the apses become degenerate (ambiguous) when the orbit is circular. I.e. your apoapsis moves when you are burning strictly prograde. The usual solution to this is to burn until the proper orbital speed is attained. This prevents pushing the apoapsis to the other side of the planet. It's easy to calculate:

[FONT=courier new]SET target_speed TO SQRT(KERBIN:MU / (target_altitude + KERBIN:RADIUS)).[/FONT]

Also, I found the best burn direction to be prograde at apoapsis, not your ship's current prograde:

[FONT=courier new]LOCK velocity_at_apo TO VELOCITYAT(SHIP, TIME:SECONDS + ETA:APOAPSIS):ORBIT.[/FONT]
[FONT=courier new]LOCK heading_at_apo TO velocity_at_apo:DIRECTION.[/FONT]

Finally, if your TWR is high, I recommend to reduce your throttle in the last 5% of the burn to really get an accurate cut-off. Hope this helps!

Many thanks for this... I'm rewriting the script to simplifying and with menus... it managed to reach stable orbit for few times but it is a hit-and-miss still.

Eccentricity: 0.164 orbital speed over 2200ms and it shuts engine off from 44-50km alt till 100km

Edited by DomDiaemus
Link to comment
Share on other sites

The problem is that the apses become degenerate (ambiguous) when the orbit is circular. I.e. your apoapsis moves when you are burning strictly prograde. The usual solution to this is to burn until the proper orbital speed is attained. This prevents pushing the apoapsis to the other side of the planet. It's easy to calculate:

A method I've used is to detect when I'm halfway between apoapsis and periapsis altitude. At the start of the circularization burn periapsis is far a way and I'm near apoapsis, meaning my altitude is closer to AP alt than to PE alt. When I reach the point where AP has spun to the other side and PE has spun to my side, that will mean my altitude is closer to PE than AE.

So burn until (altitude - periapsis) < (apoapsis - altitude). The moment where that first happens will be the spot where PE and AP have spun round so I'm half way between them.

Link to comment
Share on other sites

Just a quick question... and I've only been able to find information on older versions.

I have a water drone repeater that I built last night, the KOs code works great, however when I get out of signal range all controll from KOs is lost.

Is that a known bug? Currently at work and can't access Github, but when I experienced the issue it was 2am last night so I gave up and went to sleep :P

.....

I was thinking about adding in the ModuleManager code to add in the ModuleSPU to the KOs Parts config, but figured I'd check while I'm still at work.

Any help would be great.

I tried adding in the ModuleSPU, but doesn't seem to act any different. Once signal is lost the script stops communicating and controlling the ship.

The only way around it right now has been to add in local control with KOs modules... which is not what I want but if its the only work around right now, guess I'll just deal :P.

Link to comment
Share on other sites

I tried adding in the ModuleSPU, but doesn't seem to act any different. Once signal is lost the script stops communicating and controlling the ship.

The only way around it right now has been to add in local control with KOs modules... which is not what I want but if its the only work around right now, guess I'll just deal :P.

Have you turned on remote tech compatability in the config?

Config documentation here:

http://ksp-kos.github.io/KOS_DOC/structure/config/index.html

Edit: also are you running the program from the archive or local storage? If it is from the archive then when RT losses connection to KSC then kOS losses connection with the archive and he programme stops.

Edited by TDW
Link to comment
Share on other sites

Am I doing something wrong? SEALEVELPRESSURE always returns a value of "1" no matter what I select as the body. Here's the simple code I'm using to test:

PRINT "Kerbin Sea Level Pressure is " + BODY("Kerbin"):ATM:SEALEVELPRESSURE.

PRINT "Eve Sea Level Pressure is " + BODY("Eve"):ATM:SEALEVELPRESSURE.

PRINT "Duna Sea Level Pressure is " + BODY("Duna"):ATM:SEALEVELPRESSURE.

Link to comment
Share on other sites

Am I doing something wrong? SEALEVELPRESSURE always returns a value of "1" no matter what I select as the body. Here's the simple code I'm using to test:

PRINT "Kerbin Sea Level Pressure is " + BODY("Kerbin"):ATM:SEALEVELPRESSURE.

PRINT "Eve Sea Level Pressure is " + BODY("Eve"):ATM:SEALEVELPRESSURE.

PRINT "Duna Sea Level Pressure is " + BODY("Duna"):ATM:SEALEVELPRESSURE.

The bodies are all available in the global scope as it were:

print kerbin:atm:sealevelpressure.
1

EDIT: oops! I can confirm this:

print eve:atm:sealevelpressure.
1

Edited by Lorentz
can't spell.
Link to comment
Share on other sites

I'm trying to find out if this mod is compatible with Real Tech. I want to do mission like NASA rover to Mars. I want to have to deal with signal delay until time for kOS to run a landing script, then have to deal with the delay again for moving the rover around.

Is this possible?

I will be posting this in RT2 forum also.

Edited by notsorightstuph
miss placed mod name
Link to comment
Share on other sites

Hi guys. I just needed a little help with my first program for kOS (I assume this is the right place to post this?). I know it's a little rough...


// #########################################
// ##### LAUNCH TO ORBIT. #####
// #########################################

clearscreen.

// VARIABLE DECLARATION
declare status. // program status

declare mt. // mission time

declare svel. // ship surface velocity
declare alt. // ship altitude
declare tlf. // total liquid fuel left
declare slf. // current stage liquid fuel left
declare steer. // the direction the ship is steering to
declare thr. // throttle percentage

declare tvel. // ship terminal velocity

// INITIAL VARIABLE SETTING
set mt to missiontime -11.
set status to "Status: Idle.".
set thr to 1.
set tvel to 100.9.


// MAIN LOOP
until ship:altitude > 250000 {

set mt to mt + 1. // Counting down.
set svel to round(velocity:surface:mag).
set alt to round(ship:altitude).
set slf to round(stage:liquidfuel).
set tlf to round(ship:liquidfuel).

// ASCENTION INITIATION.
if mt = -6 {
set status to "Status: Throttled engines to 100%.".
lock throttle to thr.
}.

if mt = -4 {
set status to "Status: Locked steering to upwards direction".
lock steering to up + R(0,0,-180).
}.

if mt = -2 or mt = -1 {
set status to "Status: Ready to go in... " + abs(mt).
}.

if mt = 0 {
set status to "Status: Lift off!".
stage.
}.

// VERTICAL ASCENT
if mt = 1 {
set status to "Status: Vertical ascent.".
}.

// MAINTAIN TERMINAL VELOCITY
lock throttle to thr.

if tvel < svel {
set thr to 0.
}
else {
set thr to 1.
}.

if alt < 1000 {
set tvel to 110.5.
}
else if alt > 1000 and alt < 2000 {
set tvel to 121.9.
}
else if alt > 2000 and alt < 3000 {
set tvel to 134.5.
}
else if alt > 3000 and alt < 4000 {
set tvel to 148.4.
}
else if alt > 4000 and alt < 5000 {
set tvel to 163.7.
}
else if alt > 5000 and alt < 6000 {
set tvel to 180.6.
}
else if alt > 6000 and alt < 7000 {
set tvel to 199.3.
}
else if alt > 7000 and alt < 8000 {
set tvel to 219.9.
}
else if alt > 8000 and alt < 9000 {
set tvel to 242.6.
}
else if alt > 9000 and alt < 10000 {
set tvel to 267.7.
}
else if alt > 10000 and alt < 12500 {
set tvel to 342.4.
}
else if alt > 12500 and alt < 15000 {
set tvel to 437.8.
}
else if alt > 15000 and alt < 20000 {
set tvel to 716.
}
else {
set tvel to 2332.
}.

// STAGING


// SCREEN PRINTING
clearscreen.
print "##### ASCENTION PROTOCOL v 0.1 #####" at (7,1).
print "####################################" at (7,2).

print "--------------------------------------------------" at (0,4).
print "|" at (0,5).
print status at (5,5).
print "|" at (50,5).
print "--------------------------------------------------" at (0,6).

print " -----------------------------------" at (0,8).
print "|" at (15,9).
print "|" at (50,9).
print " -----------------------------------" at (0,10).
print "Mission time: " + mt at (19,9).

print "--------------------DATA TRACK--------------------" at (0,16).
print "|" at (0,17).
print "|" at (50,17).
print "|" at (0,18).
print "Surface vel.: " + svel at (5,18).
print "Terminal vel.: " + tvel at (25,18).
print "|" at (50,18).
print "|" at (0,19).
print "|" at (50,19).
print "|" at (0,20).
print "Altitude: " + alt at (5,20).
print "Thrust: " + thr at (25,20).
print "|" at (50,20).
print "|" at (0,21).
print "|" at (50,21).
print "|" at (0,22).
print "Stage Fuel: " + slf at (5,22).
print "Total Fuel: " + tlf at (25,22).
print "|" at (50,22).
print "--------------------------------------------------" at (0,23).

wait 1.
}.

My problem is that I can't do the auto-staging cause kOS doesn't recognize the stage fuel left. It prints the total fuel left as the same amount as the stage fuel left. So I don't know what condition to give for it to work.

Any help?

Link to comment
Share on other sites

Wish we had resizable windows, sometimes the terminal feels like a speck on my screen, and it doesn't look right.

I use Sublime Text for all my code, and I felt the lack of syntax with KOS disturbing:

E1HsX0q.png

KerboScript

Drag the KerboScript folder into your Sublime Text 2/3 (I don't have 3, but it should probably work on it) packages folder. It uses a .KOS file extension for your backup needs/automatic syntax detection.

Also, GOD DAMN THAT FONT. It's so bold that after a few minutes of looking, it hurts my eyes, not to mention it makes it slightly harder to read. I edited the font image so the letters were thinner, and not bold. Here you go:

VqM0kZu.png

Lighter Font

Drag it into your gamedata folder and let it override the KOS folder. It replaces the original font_sml.png so make a backup if you want to go back to the bold font later.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...