Git Product home page Git Product logo

kos's Introduction

kOS Mod Overview

kOS is a scriptable autopilot Mod for Kerbal Space Program. It allows you write small programs that automate specific tasks.

Installation

Like other mods, simply merge the contents of the zip file into your Kerbal Space Program folder.

Usage

Add the Compotronix SCS part to your vessel; it’s under the “Control” category in the Vehicle Assembly Building or Space Plane Hanger. After hitting launch, you can right-click on the part and select the “Open Terminal” option. This will give you access to the KerboScript interface where you can begin issuing commands and writing programs.

KerboScript

KerboScript is a programming language that is derived from the language of planet Kerbin, which sounds like gibberish to non-native speakers but for some reason is written exactly like English. As a result, KerboScript is very English-like in its syntax. For example, it uses periods as statement terminators.

The language is designed to be easily accessible to novice programmers, therefore it is case-insensitive, and types are cast automatically whenever possible.

A typical command in KerboScript might look like this:

PRINT “Hello World”.

Expressions

KerboScript uses an expression evaluation system that allows you to perform math operations on variables. Some variables are defined by you. Others are defined by the system.

There are three basic types:

Numbers

You can use mathematical operations on numbers, like this:

SET X TO 4 + 2.5. 
PRINT X.             // Outputs 6.5

The system follows the order of operations, but currently the implementation is imperfect. For example, multiplication will always be performed before division, regardless of the order they come in. This will be fixed in a future release.

Mathematical Functions

Basic Functions

ABS(1).             // Returns absolute value of input. e.g. 1
MOD(21,6).          // Returns remainder of an integer division. e.g. 3
FLOOR(1.887).       // Rounds down to the nearest whole number. e.g. 1
CEILING(1.887).     // Rounds up to the nearest whole number. e.g. 2
ROUND(1.887).       // Rounds to the nearest whole number. e.g. 2
ROUND(1.887, 2).    // Rounds to the nearest place value. e.g. 1.89
SQRT(7.89).         // Returns square root. e.g. 2.80891438103763

Trigonometric Functions

SIN(6).                 // Returns sine of input. e.g. 0.10452846326
COS(6).                 // Returns cosine. e.g. 0.99452189536
TAN(6).                 // Returns tangent. e.g. 0.10510423526
ARCSIN(0.67).           // Returns angle whose sine is input in degrees. e.g. 42.0670648
ARCCOS(0.67).           // Returns angle whose cosine is input in degrees. e.g. 47.9329352
ARCTAN(0.67).           // Returns angle whose tangent is input in degrees. e.g. 33.8220852
ARCTAN2(0.67, 0.89).    // Returns the angle whose tangent is the quotient of two specified numbers in degrees. e.g. 36.9727625

Strings

Strings are pieces of text that are generally meant to be printed to the screen. For example:

PRINT “Hello World!”.

To concatenate strings, you can use the + operator. This works with mixtures of numbers and strings as well.

PRINT “4 plus 3 is: “ + (4+3).

Directions

Directions exist primarily to enable automated steering. You can initialize a direction using a vector or a rotation.

SET Direction TO V(0,1,0).         // Set a direction by vector
SET Direction TO R(0,90,0).        // Set by a rotation in degrees

You can use math operations on Directions as well. The next example uses a rotation of “UP” which is a system variable describing a vector directly away from the celestial body you are under the influence of.

SET Direction TO UP + R(0,-45,0).  // Set direction 45 degress west of “UP”.

Command Reference

ADD

Adds a maneuver node to the flight plan.

Example: This statement adds a node that occurs 30 seconds from now, and has a delta-V of 100 m/s radial out, 0 m/s normal, and 200 m/s prograde.

ADD NODE(TIME + 30, 100, 0, 200).

REMOVE

Removes maneuver node from flight plan. Cannot remove bare nodes e.g. ADD NODE().

SET X TO NODE(0,0,0,0).
ADD X.
REMOVE X.

ADD NODE(0,0,0,0).
REMOVE.             // Does not remove node.

BREAK

Breaks out of a loop. Example:

SET X TO 1.
UNTIL 0 {
    SET X TO X + 1.
    IF X > 10 { BREAK. }.       // Exits the loop when X is greater than 10
}.

CLEARSCREEN

Clears the screen and places the cursor at the top left. Example:

CLEARSCREEN.

COPY

Copies a file to or from another volume. Volumes can be referenced by their ID numbers or their names if they’ve been given one. See LIST, SWITCH and RENAME. Example:

SWITCH TO 1.       // Makes volume 1 the active volume
COPY file1 FROM 0. // Copies a file called file1 from volume 0 to volume 1
COPY file2 TO 0.   // Copies a file called file1 from volume 1 to volume 0

DELETE

Deletes a file. You can delete a file from the current volume, or from a named volume. Example:

DELETE file1.         // Deletes file1 from the active volume.
DELETE file1 FROM 1.  // Deletes file1 from volume 1

DECLARE

Declares a variable at the current context level. Alternatively, a variable can be implicitly declared by a SET or LOCK statement. Example:

DECLARE X.

DECLARE PARAMETER

Declares variables to be used as a parameter. Example:

DECLARE PARAMETER X.
DECLARE PARAMETER X,y.
RUN MYPROG(X).

EDIT

Edits a program on the currently selected volume. Example:

EDIT filename.

IF

Checks if the expression supplied returns true. If it does, IF executes the following command block. Example:

SET X TO 1.
IF X = 1 { PRINT "X equals one.". }.            // Prints "X equals one."
IF X > 10 { PRINT "X is greater than ten.". }.  // Does nothing

If statements can make use of boolean operators. Example:

IF X = 1 AND Y > 4 { PRINT "Both conditions are true". }.
IF X = 1 OR Y > 4 { PRINT "At least one condition is true". }.

LIST

Lists the files on the current volume, or lists the currently available volumes. Lists files by default. Example:

LIST.           // Lists files on the active volume
LIST FILES.     // Lists files on the active volume
LIST VOLUMES.   // Lists all volumes, with their numbers and names
LIST BODIES.    // Lists celestial bodies and their distance
LIST TARGETS.   // Lists target-able vessels in range
LIST RESOURCES. // List of resources by stage
LIST PARTS.     // Lists parts in vessel
LIST ENGINES.   // List of engines

LOCK

Locks a variable to an expression. On each cycle, the target variable will be freshly updated with the latest value from expression. Example:

SET X TO 1.
LOCK Y TO X + 2.
PRINT Y.       // Outputs 3
SET X TO 4.
PRINT Y.      // Outputs 6

ON

Awaits a change in a boolean variable, then runs the selected command. This command is best used to listen for action group activations. Example:

ON AG3 PRINT “Action Group 3 Activated!”.
ON SAS PRINT “SAS system has been toggled”.

PRINT

Prints the selected text to the screen. Can print strings, or the result of an expression. Example:

PRINT “Hello”.
PRINT 4+1.
PRINT “4 times 8 is: “ + (4*8).

PRINT.. AT (COLUMN,LINE)

Prints the selected text to the screen at specified location. Can print strings, or the result of an expression. Example:

PRINT “Hello” at (0,10).
PRINT 4+1 at (0,10).
PRINT “4 times 8 is: “ + (4*8) at (0,10).

LOG.. TO

Logs the selected text to a file on the local volume. Can print strings, or the result of an expression. Example:

LOG “Hello” to mylog.
LOG 4+1 to mylog .
LOG “4 times 8 is: “ + (4*8) to mylog.

RENAME

Renames a file or volume. Example:

RENAME VOLUME 1 TO AwesomeDisk
RENAME FILE MyFile TO AutoLaunch.

REMOVE

Removes a maneuver node. Example:

REMOVE NEXTNODE.        // Removes the first maneuver node in the flight plan.

RUN

Runs the specified file as a program. Example:

RUN AutoLaunch.

SET.. TO

Sets the value of a variable. Declares the variable if it doesn’t already exist. Example:

SET X TO 1.

STAGE

Executes the stage action on the current vessel. Example:

STAGE.

SWITCH TO

Switches to the specified volume. Volumes can be specified by number, or it’s name (if it has one). See LIST and RENAME. Example:

SWITCH TO 0.                        // Switch to volume 0.
RENAME VOLUME 1 TO AwesomeDisk.     // Name volume 1 as AwesomeDisk.
SWITCH TO AwesomeDisk.              // Switch to volume 1.

TOGGLE

Toggles a variable between true or false. If the variable in question starts out as a number, it will be converted to a boolean and then toggled. This is useful for setting action groups, which are activated whenever their values are inverted. Example:

TOGGLE AG1.			// Fires action group 1.
TOGGLE SAS.			// Toggles SAS on or off.

UNLOCK

Releases a lock on a variable. See LOCK. Examples:

UNLOCK X.                // Releases a lock on variable X.
UNLOCK ALL.              // Releases ALL locks.

UNTIL

Performs a loop until a certain condition is met. Example:

SET X to 1.
UNTIL X > 10 {          // Prints the numbers 1-10.
    PRINT X.
    SET X to X + 1.
}.

WAIT

Halts execution for a specified amount of time, or until a specific set of criteria are met. Note that running a WAIT UNTIL statement can hang the machine forever if the criteria are never met. Examples:

WAIT 6.2.                     // Wait 6.2 seconds.
WAIT UNTIL X > 40.            // Wait until X becomes greater than 40.
WAIT UNTIL APOAPSIS > 150000. // You can see where this is going.

WHEN.. THEN

Executes a command when a certain criteria are met. Unlike WAIT, WHEN does not halt execution. Example:

WHEN BCount < 99 THEN PRINT BCount + “ bottles of beer on the wall”.

..ON

Sets a variable to true. This is useful for the RCS and SAS bindings. Example:

RCS ON 			// Turns on the RCS

..OFF

Sets a variable to false. This is useful for the RCS and SAS bindings. Example

RCS OFF			// Turns off the RCS

WARP

Sets game warp to provided value(0-7).

SET WARP TO 5.      // Sets warp to 1000x.
SET WARP TO 0.      // Sets warp to 0x aka real time.

REBOOT

Reboots the kOS module.

SHUTDOWN

Causes kOS module to shutdown.

Flight Statistics

You can get several useful vessel stats for your ships

VESSELNAME
ALTITUDE
ALT:RADAR           // Your radar altitude
BODY                // The current celestial body whose influence you are under
MISSIONTIME         // The current mission time
VELOCITY            // The current orbital velocity
VERTICALSPEED
SURFACESPEED
LATITUDE
LONGITUDE
STATUS              // Current situation: LANDED, SPLASHED, PRELAUNCH, FLYING, SUB_ORBITAL, ORBITING, ESCAPING, or DOCKED
INLIGHT          // Returns true if not blocked by celestial body, always false without solar panel.
INCOMMRANGE         // returns true if in range
COMMRANGE           // returns commrange
MASS
MAXTHRUST           // Combined thrust of active engines at full throttle (kN)

TIME

Returns time in various formats.

TIME                // Gets the current universal time
TIME:CLOCK          // Universal time in H:M:S format(1:50:26)
TIME:CALENDAR       // Year 1, day 134
TIME:YEAR           // 1
TIME:DAY            // 134
TIME:HOUR           // 1
TIME:MINUTE         // 50
TIME:SECOND         // 26

Vectors

These return a vector object, which can be used in conjuction with the LOCK command to set your vessel's steering.

PROGRADE
RETROGRADE
UP				// Directly away from current body

Orbit geometry values

These values can be polled either for their altitude, or the vessel's ETA in reaching them. By default, altitude is returned.

APOAPSIS			// Altitude of apoapsis
ALT:APOAPSIS		// Altitude of apoapsis
PERIAPSIS			// Altitude of periapsis
ALT:PERIAPSIS		// Altitude of periapsis
ETA:APOAPSIS		// ETA to apoapsis
ETA:PERIAPSIS		// ETA to periapsis

Maneuver nodes

NODE                // Direction of next maneuver node, can be used with LOCK STEERING
MAG:NODE            // Delta-v magnitude of maneuver node
ETA:NODE            // ETA to active maneuver node
ENCOUNTER           // Returns celestial body of encounter
NEXTNODE            // Next node in flight plan.

Resources

Resource Types

LIQUIDFUEL
OXIDIZER
ELECTRICCHARGE
MONOPROPELLANT
INTAKEAIR
SOLIDFUEL

Stage specific values

STAGE:LIQUIDFUEL            // Prints per stage liquid fuel.
STAGE:OXIDIZER

Global values

PRINT <LiquidFuel>.                         // Print the total liquid fuel in all tanks. DEPRECATED
PRINT SHIP:LIQUIDFUEL.                      // Print the total liquid fuel in all tanks.
PRINT VESSEL("kerbRoller2"):LIQUIDFUEL.     // Print the total liquid fuel on kerbRoller2.
PRINT TARGET:LIQUIDFUEL.                    // Print the total liquid fuel on target.

Flight Control

These values can be SET, TOGGLED, or LOCKED. Some values such as THROTTLE and STEERING explicity require the use of lock.

Controls which use ON and OFF

SAS				// For these five, use ON and OFF, example: SAS ON. RCS OFF.
GEAR
RCS
LIGHTS
BRAKES
LEGS
CHUTES	// Cannot be un-deployed.
PANELS

Controls that can be used with TOGGLE

ABORT
AGX             // Where x = 1 through 10. Use toggle, example: TOGGLE AG1.             	

Controls that must be used with LOCK

THROTTLE			// Lock to a decimal value between 0 and 1.
STEERING			// Lock to a direction.
WHEELTHROTTLE       // Seperate throttle for wheels
WHEELSTEERING       // Seperate steering system for wheels

Structures

Structures are variables that can contain more than one piece of information. Structures can be used with SET.. TO just like any other variable. Changing valves works only with V() and NODE() at this time, cannot be used with lock.

Their subelements can be accessed by using : along with the name of the subelement.

LATLNG (latitude, longitude)

Represents a set of geo-coordinates.

SET X TO LATLNG(10, 20).            // Initialize point at lattitude 10, longitude 20
PRINT X:LAT.                        // Print 10.
PRINT X:LNG.                        // Print 20.
PRINT X:DISTANCE.                   // Print distance from vessel to x (same altitude is presumed)
PRINT LATLNG(10,20):HEADING.        // Print the heading to the point.
PRINT X:BEARING.                    // Print the heading to the point relative to vessel heading.

NODE (universalTime, radialOut, normal, prograde)

Represents a maneuver node.

SET X TO NODE(TIME+60, 0, 0, 100).  // Creates a node 60 seconds from now with
                                    // prograde=100 m/s
ADD X.                              // Adds the node to the flight plan.
PRINT X:PROGRADE.                   // Returns 100.
PRINT X:ETA.                        // Returns the ETA to the node.
PRINT X:DELTAV                      // Returns delta-v vector.
REMOVE X.                           // Remove node  from the flight plan.

SET X TO NODE(0, 0, 0, 0).          // Create a blank node.
ADD X.                              // Add Node to flight plan.
SET X:PROGRADE to 500.              // Set nodes prograde to 500m/s deltav.
PRINT X:APOAPSIS.                   // Returns nodes apoapsis.
PRINT X:PERIAPSIS.                  // Returns nodes periapsis.

HEADING (degreesFromNorth, pitchAboveHorizon)

Represents a heading that's relative to the body of influence.

SET X TO HEADING(45, 10).           // Create a rotation facing northeast, 10 degrees above horizon

R (pitch, yaw, roll)

Represents a rotation.

SET X TO PROGRADE + R(90,0,0).      // Initializes a direction to prograde plus a relative pitch of 90
LOCK STEERING TO X.                 // Steer the vessel in the direction suggested by direction X.

V (x, y, z)

Represents a vector.

SET varname TO V(100,5,0).          // initializes a vector with x=100, y=5, z=0
varname:X.                          // Returns 100.
V(100,5,0):Y.                       // Returns 5.
V(100,5,0):Z.                       // Returns 0.
varname:MAG.                        // Returns the magnitude of the vector, in this case
SET varname:X TO 111.               // Changes vector x value to 111.
SET varname:MAG to 10.              // Changes magnitude of vector. e.g. V(9.98987,0.44999,0)

VESSEL (vesselname)

Represents a targetable vessel

SET X TO VESSEL("kerbRoller2").     // Initialize a reference to a vessel.
PRINT X:DISTANCE.                   // Print distance from current vessel to target.
PRINT X:HEADING.                    // Print the heading to the vessel.
PRINT X:BEARING.                    // Print the heading to the target vessel relative to vessel heading.

SHIP

Represents currently selected ship

PRINT SHIP.                            // returns VESSEL("kerbRoller2")
PRINT SHIP:DISTANCE.                   // Print distance from current vessel to target.
PRINT SHIP:HEADING.                    // Print the heading to the vessel.
PRINT SHIP:BEARING.                    // Print the heading to the target vessel relative to vessel heading.

TARGET

Represents targeted vessel or celestial body

SET TARGET TO "kerbRoller2".        // target kerbRoller2
PRINT TARGET:DISTANCE.              // Print distance from current vessel to target.
PRINT TARGET:HEADING.               // Print the heading to the target vessel.
PRINT TARGET:BEARING.               // Print the bearing to the target vessel relative to vessel heading.

System Variables

Returns values about kOS and hardware

PRINT VERSION.            // Returns operating system version number. 0.8.6
PRINT VERSION:MAJOR.      // Returns major version number. e.g. 0
PRINT VERSION:MINOR.      // Returns minor version number. e.g. 8
PRINT SESSIONTIME.        // Returns amount of time, in seconds, from vessel load.

kos's People

Contributors

a1270 avatar bgog avatar civilwargeeky avatar dail8859 avatar dunbaratu avatar ehrenmurdick avatar nivekk avatar palaslet avatar perdog avatar pierreadam avatar thanpolas avatar xzise avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kos's Issues

Adding more expressions

I think it would be very useful if you would be able to use functions like %, CEIL, FLOOR, ROUND, SQRT, POW, ASIN, ACOS, ATAN, ATAN2, LOG and EXP.

And a quick look at Expression.cs shows that the current SIN, COS and TAN are using degrees. However I am used to radians, so it might also be useful to add two types of each, maybe SIN for radians and SIND for degrees?

Adding some mathematical constants with might also be useful, such as PI. And I personally would also prefer to be able to write an AND operation as "&&" and OR as "||".

And finally I think it would be useful to have a more complete list of expressions in the readme file.

Ability to set a target

With the ability to set a target from within the script the scope of usefulness would become wider for KOS scripting (ie. you could build a script to hunt for a good flight path to somewhere or rendezvous with something).

Remove file.

Hello,

I started to use this amazing projet on kerbal. So i store my programs on the volume 0 (archive). But i don't find the command to remove a file.
Is there one or is it still under development ?

Sincerly.

enchancement idea: count program size by tokens not bytes, to simulate "compiling".

One of the things about the 10k limit on programs is that while I like having to live with an old-school limit like it's an old computer, it seems a bit unnatural that this limit is based on the source code characters when in a real space program they'd be sending compiled code to the craft. I find myself being unwilling to format the code nicely, or use long variable names, when I know its wasting my 10k limit to do so. And that makes the programs less readable.

Perhaps a solution to this that might still keep the original feel of tight limits would be to generate a program complexity cost based on the number of lines or number of parts of speech rather than the number of characters. That way all the following would cost the same space on the volume hard drive:

set pS to 1.00 .
set pS to 1.
set preferredSpeed to 1.000  // This is a comment.

They would cost the same because they are equally complex as far as grammar goes. They all consist of 4 terms.

I know comments like in that last line are not implemented. But if they were it would be nice for them not to count against your limit, as that would discourage people from using them. And in a sense if this was compiled code, the comments would no longer exist in the compiled form. Just like in the compiled form it wouldn't matter if a variable name was long or short, unless it had been compiled with symbol table information included for debug purposes.

Another place where it would be nice is in indenting:

if x = 1 {
    if y = 1 {
        print "blah".
    }.
    if y = 0 {
        print "blorg".
    }.
}.
if x = 1 {
if y = 1 {
print "blah".
}.
if y = 0 {
print "blorg".
}.
}.

Both of the above examples are identical, but the first one penalizes the user for indenting it correctly by making it cost 32 bytes more (yeah that's not much but if I'd used a larger example with a longer body it would add up.)

Locking the steering while SAS is ON

Again, I don't know if this is intended or not.

Here is what happens:
lock steering to up + R(0,-45,0). - works just fine, ship alters course for hdg 90, pitch 45.

sas on.
lock steering to up + R(0,-45,0). - ship does absolutely nothing, the yaw/pitch/roll indicators in the bottom left stand still, the ship isn't even trying to turn.

I tried this on various ships, and increased the amount of reaction-wheel torque, all ships did nothing.

When setting the SAS to "off" manually, the ship starts to turn and alters it's course to the correct hdg and pitch as if the SAS was blocking it somehow.

Surface vectors?

Any chance of adding surface prograde as a builtin? Then you could for example launch with a pitch program that keeps limited AoA, or do a reentry with a fixed AoA.

Can't perform operations on verticalspeed

Whenever I try to perform a mathematical operation on verticalspeed (or a variable instantiated to verticalspeed, either through SET or LOCK), KOS "crashes" (requiring a reboot of the console).

I noticed that verticalspeed seems to have a higher decimal count than standard variables in the language, so perhaps the math code isn't designed for a decimal that big?

Just to make it easier, here's some example code which crashes the system on my end:

print verticalspeed + 10.
set y to verticalspeed.
print y - 5.

Quicksaving sometimes kills saves!

When a program contains braces and is quicksaved, this conflicts with the persistent.sfs file which also uses braces which kills save files.

These need to be escaped.

Set target to orbitalbodies

I don't know if this is possible, but I'd like to see an option to set the target to an orbital body, including the sun.

Blurred Fonts

I have an issue where my console fonts look very blurred (including the "close" button), and it's barely readable. I have all settings on max (besides anti-aliasing).

Crash when using { } multiline

This is the working syntax :

when stage:liquidfuel < 560 then { stage. }.

But this one is crashing the entire game :

when stage:liquidfuel < 560 then {
stage.
}.

Syntax doesn't understant abs() inside sin().

This works:
set theta to -30.
set posTheta to abs(theta).
print sin(posTheta).

But this issues an 'unrecognized term" error:
set theta to -30.
print sin(abs(theta)).

This also fails - it doesn't matter which order around they are:
print abs(sin(theta)).

The core problem appears to be nesting function calls inside function calls.

KER compatibility

Running the program screws with KER (Kerbal Engineer Redux) window. I'm not sure if that's KER or kOS problem.

Rename file

When you rename a file to an already existing file, you get two files with the same name.

Volume 10000 byte capacity limit checked in FROM but not TO direction.

Let's say Volume 1 has 8000 bytes on it already, and you want to add a 3000 byte program to it. This puts it beyond the capacity of 10000 bytes.

But the check to deny the copying only happens when doing this:
SWITCH TO 1.
COPY myprog FROM archive.

When you do the same copy in reverse like so:
SWITCH TO archive.
COPY myprog TO 1.

Then the check doesn't seem to be happening and it allows you to overflow the 10000 limit.

This caused me to overload my probe's volume 1 beyond capacity and not realize it until after I'd launched it and then tried to update a program from the archive and it failed. For a while I thought there was something wrong with the COPY command that made it only work in one direction, until I looked at the code and saw the 10,000 byte limit and then worked out that it wasn't being enforced universally in both directions.

Plot (x,y) function in the future?

This is probably way down the line, and maybe beyond the scope of what you're aiming to do, but the ability to plot points, lines, circles and/or rectangles on the console would allow for users to create things simple maps, graphs, radar displays, gauges, and many other things... :)

until 0{}. locks vessel control

Right after the 0.5 update I started writing some code for a leader-bot and a follower-bot, both bots are essentially rovers.
Here is a bug i found:

The leader-bot has absolutely no code.
The follower-bot has the following code:

brakes off.

set target to "LeaderBot".
lock wheelsteering to target.

lock wheelthrottle to -1.
wait until ABS(target:bearing)<90.

until 0
{
if target:distance > 10
{
lock wheelthrottle to 1.
brakes off.
wait until target:distance < 10.
}.
if target:distance < 10
{
lock wheelthrottle to 0.
brakes on.
wait until target:distance > 10.
}.
}.

While focused on the follower-bot, I run the program. The follower-bot corrects its heading and approaches the leader-bot. It then brakes within 10 meters of the leader and stops. --Everything is fine up to here.

I now switch to the leader using the bracket keys.
When trying to control the leader-bot manually I notice I have absolutely no control over it. The steering is locked and I cannot turn the wheels, I cannot accelerate, I cannot decelerate. Toggling sas, rcs, brakes, throttle still works..

I switch back to the follower-bot and stop the script execution with Ctrl +C.

I switch again to the leader. I can now control the leader-bot with no problems.

[QUESTION] Multiple Instances

Can kOS run in multiple instances within KSP? For example, I would be launching a rocket using a script and there is a script running on a probe making its way to Jool?

Allow for sub-expressions in PRINT xxx AT() ??

It might be cool to be able to assign expressions or variables in the AT() expression to be able to freely move text around the console.
So things like:

Set x to 1.
Set y to 1.
Until x = 10 {
Print "Hello world! at (x,y).
Set x to x + 1.
Set y to y + 1.
}.

become possible. It would allow for things like cool ASCII graphs!

A means to silence the "Program Ended." message in scripts.

It's very useful to make one program call another, as if it was a subroutine. But when you do so, the message "Program ended." can't be suppressed and it's really messing up my nice pretty displays made with print ... at... statements.

Can the "Program ended." message be either suppressed or directed somewhere else?

Toggle AG6.

Ok, so I found this:

print "1". - prints 1.
toggle ag1. - toggles action group 1.
print "1-1". -prints 1-1.
print "6-1". -prints 6-1.
toggle ag6. - doesn't toggle action group 6.
print "6-2". - doesn't print anything. (anything beyond toggle ag6 isn't evaluated)

I've tested all action groups, this only happens for ag6.

Editor loses indentation

The text editor needs support for the tab key, and currently strips leading spaces when saving.

"Unrecognized term" error for resource tags

When I try to get a resource tag by calling, for example,

print <LiquidFuel>.

the console prints out the error:

"Unrecognized term: ''." 

(note that those are 2 single quotes with nothing between them)

Add prograde/retrograde for other reference systems

Hi, add prograde and retrograde vectors for all three reference systems:

  • ORBIT:PROGRADE (are the same as current PROGRADE)
  • ORBIT:RETROGRADE (are the same as current RETROGRADE)
  • SURFACE:PROGRADE
  • SURFACE:RETROGRADE
  • TARGET:PROGRADE
  • TARGET:RETROGRADE

Maybe the current PROGRADE and RETROGRADE use the same reference system as the navball is using at the moment.

An additional proposal would be to have those vectors for any other object and not only the current target. So for example when there are three objects in orbit (A, B and Z). When the script is running on Z, it then would allow something like 'A':prograde and 'B':prograde without changing the target every time.

Question: Plans for a new file saving system?

I think I read somewhere that you were going to start work on a new file saving system. I had started working on a new system in a fork before reading the comment, so I'm just wondering if you had started on it yet, or if I should keep working away at it?

PS. Sorry if this isn't the proper place for this question, it's been a while since I used git and I couldn't find a way to message you.

PPS. I've been pretty bored lately and looking for something to do, which is why I started work on making the change for this. Figured I'd maybe help someone out while keeping myself amused :P

Can't build

: error CS2001: Source file `SpecialValue.cs' could not be found
: error CS2001: Source file `SpecialValueTester.cs' could not be found
: error CS2001: Source file `StageValues.cs' could not be found
: error CS2001: Source file `VesselTarget.cs' could not be found

Files not checked in?

persistent locks

Currently, when program ends, all locked parameters are unlocked. Would be nice to have an option to keep some of them (example: steering) still locked.

Any program with a DECLARE statement will hang the second time its run.

I had a program that worked the first time I ran it but then when I ran it a second time it always just hung there until I hit CTRL-C.

I eventually traced the cause to this line in the program:

declare mySpeed.

What happens is that if you run "declare" a second time on a variable name that already exists, kOS just hangs there. So any program that tries to do the right thing and declare variables up front ends up only being runnable once. For now I've changed all "declare" statements to "set" statements instead.

variable name after wait command

I encountered this issue:
set x to 0.
until x = 1 {
set y to 1.88.
print y.
wait y.
}.

This will print the correct value of 1.88, but will never loop back again. No syntax error, just a hung state.

Discuss: Should we continue to have two different Wikis or merge them now before they get too big to do it?

There is a GitHub wiki for the project here presumably typed in by the author Kevin Laity:
https://github.com/Nivekk/KOS/wiki

and there is a community-made Wiki for the project here:
http://kos.wikia.com/wiki/KOS_Wiki

Discuss: Is there a good reason to keep them separated? There will inevitably be duplication of information between them. Right now both are still small and it's not too late to go through the effort of copying the content from one into the other.if that's what is wanted. But as time goes on that will become a larger and larger job if its decided to do it later.

My vote would be that IF it's merged, to use the gitHub one over the Wikia one because it makes for a central repository of everything about the mod, and the Wikia banner ads are annoying and have buggy javascript that hurts my browser sometimes.
.

Variables as vector members

I would like to request that we be able to use variables in the vector triplets with KerboScript.

For instance:

declare X.
set X = -30.
lock steering to R(0,X,0).

Steering by vector broke in version 0.6

I posted about this in the forum but it's a critical bug that broke every script I wrote that worked on 0.5 and I can't find a workaround so I'm posting it here to be sure it gets seen as soon as possible.

This syntax used to work:
lock steering to up + V(x,y,z).
or this:
lock steering to up * V(x,y,z).

They are no longer supported, it seems. They now cause "Expression error" to try to use a V(...) expression to steer by.

This is critical because now all the available means to steer require that you know the angles ( you can use R() or Q() or HEADING... BY... ) and to get the angles from the vector XYZ lengths requires access to the functions arcsin, arccos, or arctan, which we don't have.

Either of the following two things would solve the problem:
1 - Put support for steering by a vector back in.
or
2 - Add arcsin, arccos, and arctan.

For example, the compass heading and pitch could be derived as follows if we had the arc functions, assuming X is north, Y is west, and Z is up:

set xyzLength to (x^2+y^z+z^2)^0.5 .
set xyLength to (x^2 * y^2) ^ 0.5 .
set compSin to (0-x) / xyLength.
set compCos to y / xyLength.
set compass to arccos( compCos ).
if compSin < 0 { set compass to 0 - compass. }.
set pitchSin to z / xyzLen .
set pitch to arcsin( pitchSin ).
lock steering to heading compass by pitch.

WHEN .. THEN requires space after THEN.

It may be intentional but it finally figured it out while napping. I happen to be hardcoded to allman indent so it's very annoying.

when cnt2 < 10 then {}. //sunshine and rainbows
when cnt2 < 10 then{}. //syntax error

I 'fixed' it by editing to the regex to this: [CommandAttribute(@"^WHEN (.+?) THEN(( |{)+(.+?))$")].

On a side note, PRINT .. AT seems to be reversed. (Column[x], Line[y]) is very confusing and always takes me some cycles to figure out. Adding to that, it only accepts int values, be nice it accepted variables. By swapping '[0-9]' for '.+' seems to allow for them. Don't know what type of issues that will cause... Haven't seen any yet.

I need to get back to work. Hopefully this made some sort of sense.

future feature: RCS translation controls?

It would be nice if there was a way to access what the IJKLHN keys normally do in flight. (sideways movement.) Docking is nearly impossible without it. It doesn't even have to be too fancy- just mimic what the controls do, which I think is boolean thrusting so it's simpler than the THROTTLE interface (no need to set a number between 0.0 and 1.0 just a boolean toggle for the 6 directions:

Any one of these would be fine:
suggestion 1 - direct control of the 6 thrust directions:

rcsleft on. // or off.
rcsright on.  // or off.
rcstup on.  // or off.
rcsdown on.  // or off.
rcsahead on.  // or off.
rcsback on.  // or off.

suggestion 2 - Same thing but use positive and negative numbers so there's only 3 thrust settings not 6:

lock rcsside to 1. // pushing  to ship's relative right
lock rcsside to 0. // drift.
lock rcsside to -1. // pushing to ship's relative left.

lock rcsvertical to 1. // pushing to ship's relative up.
lock rcsvertical to 0. // drift.
lock rcsvertical to -1. // pushing to ship's relative down.

lock rcsahead to 1. // pushing to ship's relative front.
lock rcsahead to 0. // drift.
lock rcsahead to -1. // pushing to ship's relative rear.

suggestion 3 - thrust in a direction, let kOS work the combination of the 6 thrust directions to do it:

lock rcsDirection to ( up + R(45,0,0) ). // push diagonally.
rcsThrust on.
rcsThrust off.

I actually prefer 1 or 2 over 3. Sort of the whole reason I'm using kOS instead of mechjeb is that I want to write my own piloting routines instead of having someone else do it for me.

The "x" key in the terminal window also kills throttle.

Open the terminal window while the engines are throttled up.
Type anything into the window that includes the letter 'x', for example:

set x to 5.

As soon as you type the 'x', the 'x' is also read by the main game as well as by the terminal window, causing KSP to kill your throttle, assuming you have default KSP settings where X is the kill throttle key.

Keyboard locking not working anymore in 0.34.

0.34 introduces a regression where the user still types in the terminal although the terminal window is not focused.

Scenario:
1 - launch a rocket.
2 - open the terminal.
3 - control the rocket manually with the terminal still opened.

Add commentary string

Hi!

Would be nice, if it becomes possible to add a commentary to a script, like in other programming languages.

I thought

/* TEXT */

would be nice, like in HTML/JAVA/PHP. Maybe something like !-- TEXT --! would also work.

Inconsistent variable case-sensitivity.

I'm not sure if this is intended behavior or not.

lock throttle to 1. - works, sets maximum throttle.
lock THROTTLE to 1. - doesn't work, throttle remains at 0.

This is an inconsistency because all other kOs variables are not case-sensitive, eg:
print missiontime. - works.
print MISSIONTIME. - works.

print VESSELNAME. - works.
print vesselname. - works.

Users can't see that theres a 10,000 byte limit on volumes.

I tried to figure out why on earth I couldn't copy a file to the volume and had to resort to reading the source code here to figure it out.

The fact that there's a 10,000 byte limit for a volume is completely undocumented. No end-user who hasn't read the code would realize it.

And when you try to copy the file into the volume, the error message doesn't tell you that a limited capacity is the reason it failed.

Something definitely needs to be added to make it known to the end user.

One simple thing would be if the "LIST" command showed a line at the bottom of the file list along the lines of:

Volume Capacity Used:   5012 / 10000 bytes.

People would at least then know there was such a thing as a limit.

lock steering overreacts when loading from mission center

After putting a small probe into orbit (core + fuel tank + engine + kos + solar panels), then quit to space center and finally go back to the probe via the mission center, the steering completely overreacts when being locked to some direction.

Interestingly this does not happen if you lock the steering directly after the payload separation, in this case the steering finds the desired direction quickly and accurately.

the GEAR control is in the README document but does nothing.

Make a tiny craft with landing gear and a kOS module on it. Put it on the launchpad, open the terminal. Type "gear on." or "gear off." No effect.
The README implies that it's supposed to be implemented. Am I misunderstanding what it's for (is it for landing gear deployment, i,e. pressing the "G" key?)?

Add inclination as flight statistic?

Would be nice to have this as a flight statistic and, if possible, be able to bind it to target. I guess this might go with adding AN and DN as an orbital geometry value?

Can we have some type of comment in the language?

The examples in the readme show the use of comments with "//", but that doesn't actually work in the parser.

Is there some form of comment in the language, and if not can we have one? Sometimes the logic of a script gets a bit messy and it's problematic that I can't describe in the code why I'm doing what I'm doing. At the moment I have some pseudo-comments by saying 'set c to "blah" like this example:

set c to "degrees to radians conversion multiplier.".
set d2r to 3.141559266 / 180.

set c to "multiplier to convert a sweep of degrees of ".
set c to "latitude/longitude to a surface distance given ".
set c to "the radius of the body.".
set c to "Warning: is only accurate for small degree sweep.".
set degToDist to d2r*bodyRadius.

But it seems silly to be having to execute a statement each time I'm trying to make a comment. I know it's an interpreted language so comments always will take a little bit of time, but if there was a dedicated comment syntax it could probably be faster to parse over and skip than a statement that actually does something.

Even an incredibly simplistic comment style like a "#" in column 1 would still be better than what I'm doing now.

velocity:surface doesn't behave as intended

The orientation of the velocity:surface vector seems somehow fixed to the planet, and not to the local horizon. This becomes especially clear in a circular equatorial orbit, when the surface velocity vector should remain constant (in direction and magnitude). Instead, it varies wildly, depending on your longitude.

So while the length of the vector is correct, it's direction isn't.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.