Vessel

All vessels share a structure. To get a variable referring to any vessel you can do this:

// Get a vessel by it's name.
// The name is Case Sensitive.
SET MY_VESS TO VESSEL("Some Ship Name").

// Save the current vessel in a variable,
// in case the current vessel changes.
SET MY_VESS TO SHIP.

// Save the target vessel in a variable,
// in case the target vessel changes.
SET MY_VESS TO TARGET.

Vessels are also Orbitable, and as such have all the associated suffixes as well as some additional suffixes.

structure Vessel
Suffix Type Description
Every suffix of Orbitable
CONTROL Control Raw flight controls
BEARING scalar (deg) relative heading to this vessel
HEADING scalar (deg) Absolute heading to this vessel
MAXTHRUST scalar Sum of active maximum thrusts
MAXTHRUSTAT(pressure) scalar Sum of active maximum thrusts at the given atmospheric pressure
AVAILABLETHRUST scalar Sum of active limited maximum thrusts
AVAILABLETHRUSTAT(pressure) scalar Sum of active limited maximum thrusts at the given atmospheric pressure
FACING Direction The way the vessel is pointed
BOUNDS Bounds Construct bounding box information about the vessel
MASS scalar (metric tons) Mass of the ship
WETMASS scalar (metric tons) Mass of the ship fully fuelled
DRYMASS scalar (metric tons) Mass of the ship with no resources
DYNAMICPRESSURE scalar (ATM’s) Air Pressure surrounding the vessel
Q scalar (ATM’s) Alias name for DYNAMICPRESSURE
VERTICALSPEED scalar (m/s) How fast the ship is moving “up”
GROUNDSPEED scalar (m/s) How fast the ship is moving “horizontally”
AIRSPEED scalar (m/s) How fast the ship is moving relative to the air
TERMVELOCITY (DEPRECATED) scalar (m/s) terminal velocity of the vessel
SHIPNAME string The name of the vessel
NAME string Synonym for SHIPNAME
STATUS string Current ship status
TYPE string Ship type
STARTTRACKING None Start tracking the “vessel” via the tracking statin
ANGULARMOMENTUM Vector In SHIP_RAW
ANGULARVEL Vector In SHIP_RAW
SENSORS VesselSensors Sensor data
LOADED Boolean loaded into KSP physics engine or “on rails”
UNPACKED Boolean The ship has individual parts unpacked
LOADDISTANCE LoadDistance the LoadDistance object for this vessel
ISDEAD Boolean True if the vessel refers to a ship that has gone away.
PATCHES List Orbit patches
ROOTPART Part Root Part of this vessel
CONTROLPART Part Control reference Part of this vessel
PARTS List all Parts
DOCKINGPORTS List all DockingPorts
ELEMENTS List all Elements
RESOURCES List all AggrgateResources
PARTSNAMED(name) List Parts by NAME
PARTSNAMEDPATTERN(namePattern) List Parts by NAME regex pattern
PARTSTITLED(title) List Parts by TITLE
PARTSTITLEDPATTERN(titlePattern) List Parts by TITLE regex pattern
PARTSTAGGED(tag) List Parts by TAG
PARTSTAGGEDPATTERN(tagPattern) List Parts by TAG regex pattern
PARTSDUBBED(name) List Parts by NAME, TITLE or TAG
PARTSDUBBEDPATTERN(namePattern) List Parts by NAME, TITLE or TAG regex pattern
MODULESNAMED(name) List PartModules by NAME
PARTSINGROUP(group) List Parts by action group
MODULESINGROUP(group) List PartModules by action group
ALLPARTSTAGGED() List Parts that have non-blank nametags
CREWCAPACITY scalar Crew capacity of this vessel
CREW() List all CrewMembers
CONNECTION Connection Returns your connection to this vessel
MESSAGES MessageQueue This vessel’s message queue

Note

This type is serializable.

Vessel:CONTROL
Type:Control
Access:Get only

The structure representing the raw flight controls for the vessel.

WARNING: This suffix is only gettable for CPU Vessel

Vessel:BEARING
Type:scalar
Access:Get only

relative compass heading (degrees) to this vessel from the CPU Vessel, taking into account the CPU Vessel’s own heading.

Vessel:HEADING
Type:scalar
Access:Get only

absolute compass heading (degrees) to this vessel from the CPU Vessel

Vessel:MAXTHRUST
Type:scalar
Access:Get only

Sum of all the engines’ MAXTHRUSTs of all the currently active engines In Kilonewtons.

Vessel:MAXTHRUSTAT(pressure)
Parameters:
  • pressure – atmospheric pressure (in standard Kerbin atmospheres)
Return type:

scalar (kN)

Sum of all the engines’ MAXTHRUSTATs of all the currently active engines In Kilonewtons at the given atmospheric pressure. Use a pressure of 0 for vacuum, and 1 for sea level (on Kerbin). (Pressure must be greater than or equal to zero. If you pass in a negative value, it will be treated as if you had given a zero instead.)

Vessel:AVAILABLETHRUST
Type:scalar
Access:Get only

Sum of all the engines’ AVAILABLETHRUSTs of all the currently active engines taking into account their throttlelimits. Result is in Kilonewtons.

Vessel:AVAILABLETHRUSTAT(pressure)
Parameters:
  • pressure – atmospheric pressure (in standard Kerbin atmospheres)
Return type:

scalar (kN)

Sum of all the engines’ AVAILABLETHRUSTATs of all the currently active engines taking into account their throttlelimits at the given atmospheric pressure. Result is in Kilonewtons. Use a pressure of 0 for vacuum, and 1 for sea level (on Kerbin). (Pressure must be greater than or equal to zero. If you pass in a negative value, it will be treated as if you had given a zero instead.)

Vessel:FACING
Type:Direction
Access:Get only

The way the vessel is pointed, which is also the rotation that would transform a vector from a coordinate space where the axes were oriented to match the vessel’s orientation, to one where they’re oriented to match the world’s ship-raw coordinates.

i.e. SHIP:FACING * V(0,0,1) gives the direction the ship is pointed (it’s Z-axis) in absolute ship-raw coordinates

Vessel:BOUNDS
Type:Bounds
Access:Get only

Constructs a “bounding box” structure that can be used to give your script some idea of the extents of the vessel’s shape - how wide, long, and tall it is.

It is rather expensive in terms of CPU time to call this suffix. (Calling Part:BOUNDS on ONE part on the ship is itself a little expensive, and this has to perform that same work on every part on the ship, finding the bounding box that would surround all the parts.) Because of that expense, kOS forces your script to give up its remaining instructions this update when you call this (It forces the equivalent of doing a WAIT 0. right after you call it). This is to discourage you from calling this suffix again and again in a fast loop. The proper way to use this suffix is to call it once, storing the result in a variable, and then use that variable repeatedly, rather than using the suffix itself repeatedly. Only call the suffix again when you have reason to expect the bounding box to change or become invalid, such as docking, staging, changing facing to a new control-from part, and so on.

More detailed information about how to read the bounds box, and what circumstances call for getting a re-generated copy of the bounds box, is found on the documentation page for Bounds.

Vessel:MASS
Type:scalar (metric tons)
Access:Get only

The mass of the ship

Vessel:WETMASS
Type:scalar (metric tons)
Access:Get only

The mass of the ship if all resources were full

Vessel:DRYMASS
Type:scalar (metric tons)
Access:Get only

The mass of the ship if all resources were empty

Vessel:DYNAMICPRESSURE
Type:scalar (ATM’s)
Access:Get only

Returns what the air pressure is in the atmosphere surrounding the vessel. The value is returned in units of sea-level Kerbin atmospheres. Many formulae expect you to plug in a value expressed in kiloPascals, or kPA. You can convert this value into kPa by multiplying it by constant:ATMtokPa.

Vessel:Q
Type:scalar (ATM’s)
Access:Get only

Alias for DYNAMICPRESSURE

Vessel:VERTICALSPEED
Type:scalar (m/s)
Access:Get only

How fast the ship is moving. in the “up” direction relative to the SOI Body’s sea level surface.

Vessel:GROUNDSPEED
Type:scalar (m/s)
Access:Get only

How fast the ship is moving in the two dimensional plane horizontal to the SOI body’s sea level surface. The vertical component of the ship’s velocity is ignored when calculating this.

Note

New in version 0.18: The old name for this value was SURFACESPEED. The name was changed because it was confusing before. “surface speed” implied it’s the scalar magnitude of “surface velocity”, but it wasn’t, because of how it ignores the vertical component.

Vessel:AIRSPEED
Type:scalar (m/s)
Access:Get only

How fast the ship is moving relative to the air. KSP models atmosphere as simply a solid block of air “glued” to the planet surface (the weather on Kerbin is boring and there’s no wind). Therefore airspeed is generally the same thing as as the magnitude of the surface velocity.

Vessel:SHIPNAME
Type:string
Access:Get/Set

The name of the vessel as it appears in the tracking station. When you set this, it cannot be empty.

Vessel:NAME

Same as Vessel:SHIPNAME.

Vessel:STATUS
Type:string
Access:get only

The current status of the vessel possible results are: LANDED, SPLASHED, PRELAUNCH, FLYING, SUB_ORBITAL, ORBITING, ESCAPING and DOCKED.

Vessel:TYPE
Type:string
Access:Get/Set

The ship’s type as described on the KSP wiki.

Vessel:STARTTRACKING()
Returns:None

Call this method to start tracking the object. This is functionally the same as clicking on the “Start Tracking” button in the Tracking Station interface. The primary purpose is to change asteroids from being displayed in the tracking station or on the map as "Unknown" to being displayed as "SpaceObject". By doing so, the asteroid will not be de-spawned by KSP’s asteroid management system.

Note

This does not change the value returned by Vessel:TYPE. KSP internally manages the “discovery information” for vessels, including assteroids, in a different system. As a result, the value kOS reads for TYPE may be different from that displayed on the map.

Vessel:ANGULARMOMENTUM
Type:Direction
Access:Get only

Given in SHIP_RAW reference frame. The vector represents the axis of the rotation (in left-handed convention, not right handed as most physics textbooks show it), and its magnitude is the angular momentum of the rotation, which varies not only with the speed of the rotation, but also with the angular inertia of the vessel.

Units are expressed in: (Megagrams * meters^2) / (seconds * radians)

(Normal SI units would use kilograms, but in KSP all masses use a 1000x scaling factor.)

Justification for radians here: Unlike the trigonometry functions in kOS, this value uses radians rather than degrees. The convention of always expressing angular momentum using a formula that assumes you’re using radians is a very strongly adhered to universal convention, for... reasons. It’s so common that it’s often not even explicitly mentioned in information you may find when doing a web search on helpful formulae about angular momentum. This is why kOS doesn’t use degrees here. (That an backward compatibility for old scripts. It’s been like this for quite a while.).

Vessel:ANGULARVEL

Angular velocity of the body’s rotation about its axis (its day) expressed as a vector.

The direction the angular velocity points is in Ship-Raw orientation, and represents the axis of rotation. Remember that everything in Kerbal Space Program uses a left-handed coordinate system, which affects which way the angular velocity vector will point. If you curl the fingers of your left hand in the direction of the rotation, and stick out your thumb, the thumb’s direction is the way the angular velocity vector will point.

The magnitude of the vector is the speed of the rotation.

Note, unlike many of the other parts of kOS, the rotation speed is expressed in radians rather than degrees. This is to make it congruent with how VESSEL:ANGULARMOMENTUM is expressed, and for backward compatibility with older kOS scripts.

Vessel:SENSORS
Type:VesselSensors
Access:Get only

Structure holding summary information of sensor data for the vessel

Vessel:LOADED
Type:Boolean
Access:Get only

True if the vessel is fully loaded into the complete KSP physics engine (false if it’s “on rails”). See LoadDistance for details.

Vessel:UNPACKED
Type:Boolean
Access:Get only

True if the vessel is fully unpacked. That is to say that all of the individual parts are loaded and can be interacted with. This allows docking ports to be targeted, and controls if some actions/events on parts will actually trigger. See LoadDistance for details.

Vessel:LOADDISTANCE
Type:LoadDistance
Access:Get only

Returns the load distance object for this vessel. The suffixes of this object may be adjusted to change the loading behavior of this vessel. Note: these settings are not persistent across flight instances, and will reset the next time you launch a craft from an editor or the tracking station.

Vessel:ISDEAD
Type:Boolean
Access:Get only

It is possible to have a variable that refers to a vessel that doesn’t exist in the Kerbal Space Program universe anymore, but did back when you first got it. For example: you could do: SET VES TO VESSEL(“OTHER”). WAIT 10. And in that intervening waiting time, the vessel might have crashed into the ground. Checking :ISDEAD lets you see if the vessel that was previously valid isn’t valid anymore.

Vessel:PATCHES
Type:List
Access:Get only

The list of orbit patches that describe this vessel’s current travel path based on momentum alone with no thrusting changes. If the current path has no transitions to other bodies, then this will be a list of only one orbit. If the current path intersects other bodies, then this will be a list describing the transitions into and out of the intersecting body’s sphere of influence. SHIP:PATCHES[0] is always exactly the same as SHIP:OBT, SHIP:PATCHES[1] is the same as SHIP:OBT:NEXTPATCH, SHIP:PATCHES[2] is the same as SHIP:OBT:NEXTPATCH:NEXTPATCH, and so on. Note that you will only see as far into the future as your KSP settings allow. (See the setting CONIC_PATCH_LIMIT in your settings.cfg file)

Vessel:ROOTPART
Type:Part
Access:Get only

The ROOTPART is usually the first Part that was used to begin the ship design - the command core. Vessels in KSP are built in a tree-structure, and the first part that was placed is the root of that tree. It is possible to change the root part in VAB/SPH by using Root tool, so ROOTPART does not always point to command core or command pod. Vessel:ROOTPART may change in flight as a result of docking/undocking or decoupling of some part of a Vessel.

Vessel:CONTROLPART
Type:Part
Access:Get only

Returns the Part serving as the control reference, relative to which the directions (as displayed on the navball and returned in FACING) are determined. A part may be set as the control reference part by “Control From Here” action or PART:CONTROLFROM command (available for parts of specific types). NOTE: It is possible for this to return unexpected values if the root part of the vessel cannot serve as a control reference, and the control has not been directly selected.

Vessel:PARTS
Type:List of Part objects
Access:Get only

A List of all the parts on the vessel. SET FOO TO SHIP:PARTS. has exactly the same effect as LIST PARTS IN FOO.. For more information, see ship parts and modules.

Vessel:DOCKINGPORTS
Type:List of DockingPort objects
Access:Get only

A List of all the docking ports on the Vessel.

Vessel:ELEMENTS
Type:List of Element objects
Access:Get only

A List of all the elements on the Vessel.

Vessel:RESOURCES
Type:List of AggregateResource objects
Access:Get only

A List of all the AggregateResources on the vessel. SET FOO TO SHIP:RESOURCES. has exactly the same effect as LIST RESOURCES IN FOO..

Vessel:PARTSNAMED(name)
Parameters:
  • name – (string) Name of the parts
Returns:

List of Part objects

Part:NAME. The matching is done case-insensitively. For more information, see ship parts and modules.

Vessel:PARTSNAMEDPATTERN(namePattern)
Parameters:
  • namePattern – (string) Pattern of the name of the parts
Returns:

List of Part objects

Part:NAME. The matching is done identically as in String:MATCHESPATTERN. For more information, see ship parts and modules.

Vessel:PARTSTITLED(title)
Parameters:
  • title – (string) Title of the parts
Returns:

List of Part objects

Part:TITLE. The matching is done case-insensitively. For more information, see ship parts and modules.

Vessel:PARTSTITLEDPATTERN(titlePattern)
Parameters:
  • titlePattern – (string) Patern of the title of the parts
Returns:

List of Part objects

Part:TITLE. The matching is done identically as in String:MATCHESPATTERN. For more information, see ship parts and modules.

Vessel:PARTSTAGGED(tag)
Parameters:
  • tag – (string) Tag of the parts
Returns:

List of Part objects

Part:TAG value. The matching is done case-insensitively. For more information, see ship parts and modules.

Vessel:PARTSTAGGEDPATTERN(tagPattern)
Parameters:
  • tagPattern – (string) Pattern of the tag of the parts
Returns:

List of Part objects

Part:TAG value. The matching is done identically as in String:MATCHESPATTERN. For more information, see ship parts and modules.

Vessel:PARTSDUBBED(name)
Parameters:
  • name – (string) name, title or tag of the parts
Returns:

List of Part objects

name regardless of whether that name is the Part:Name, the Part:Tag, or the Part:Title. It is effectively the distinct union of :PARTSNAMED(val), :PARTSTITLED(val), :PARTSTAGGED(val). The matching is done case-insensitively. For more information, see ship parts and modules.

Vessel:PARTSDUBBEDPATTERN(namePattern)
Parameters:
  • namePattern – (string) Pattern of the name, title or tag of the parts
Returns:

List of Part objects

name regardless of whether that name is the Part:Name, the Part:Tag, or the Part:Title. It is effectively the distinct union of :PARTSNAMEDPATTERN(val), :PARTSTITLEDPATTERN(val), :PARTSTAGGEDPATTERN(val). The matching is done identically as in String:MATCHESPATTERN. For more information, see ship parts and modules.

Vessel:MODULESNAMED(name)
Parameters:
  • name – (string) Name of the part modules
Returns:

List of PartModule objects

match the given name. The matching is done case-insensitively. For more information, see ship parts and modules.

Vessel:PARTSINGROUP(group)
Parameters:
  • group – (integer) the action group number
Returns:

List of Part objects

one action triggered by the given action group. For more information, see ship parts and modules.

Vessel:MODULESINGROUP(group)
Parameters:
  • group – (integer) the action group number
Returns:

List of PartModule objects

have at least one action triggered by the given action group. For more information, see ship parts and modules.

Vessel:ALLPARTSTAGGED()
Returns:List of Part objects

nametag on them of any sort that is nonblank. For more information, see ship parts and modules.

Vessel:CREWCAPACITY
Type:scalar
Access:Get only

crew capacity of this vessel

Vessel:CREW()
Returns:List of CrewMember objects

list of all kerbonauts aboard this vessel

Vessel:CONNECTION
Return:Connection

Returns your connection to this vessel.

Vessel:MESSAGES
Return:MessageQueue

Returns this vessel’s message queue. You can only access this attribute for your current vessel (using for example SHIP:MESSAGES).

Deprecated Suffix

Vessel:TERMVELOCITY
Type:scalar (m/s)
Access:Get only

terminal velocity of the vessel in freefall through atmosphere, based on the vessel’s current altitude above sea level, and its drag properties. Warning, can cause values of Infinity if used in a vacuum, and kOS sometimes does not let you store Infinity in a variable.

Note

Deprecated since version 0.17.2: Removed to account for significant changes to planetary atmosphere mechanics introduced in KSP 1.0