Editor#

class SpaceCenter.Editor()#

Provides access to the vehicle assembly building and space plane hangar. Obtained by calling SpaceCenter.getEditor().

Editor.getFacility()#

The editor that is currently open.

Property:

Read-only, cannot be set

Return type:

SpaceCenter.EditorFacility

Game Scenes:

Editor Vab, Editor Sph

Editor.getVessel()#

The vessel that is being constructed.

Property:

Read-only, cannot be set

Return type:

SpaceCenter.EditorVessel

Game Scenes:

Editor Vab, Editor Sph

Note

An editor that has not had a vessel loaded into it holds an empty vessel, with no parts, rather than nothing at all.

Editor.loadVessel(craftDirectory, name)#

Load a vessel from a craft file into the editor, replacing the vessel that is currently being constructed.

Arguments:
  • craftDirectory (string) – Name of the directory in the current saves “Ships” directory, that contains the craft file. For example "VAB" or "SPH".

  • name (string) – Name of the vessel to load. This is the name of the “.craft” file in the save directory, without the “.craft” file extension.

Game Scenes:

Editor Vab, Editor Sph

Note

The vessel is loaded into whichever editor is open, regardless of which directory it came from. Its delta-v figures are recalculated in the background afterwards; see SpaceCenter.EditorVessel.getDeltaVReady().

Editor.launchVessel(launchSite[, crew[, recover[, flagUrl]]])#

Launch the vessel that is being constructed, from the given launch site.

Arguments:
  • launchSite (string) – Name of the launch site. For example "LaunchPad" or "Runway".

  • crew (Array of string or null) – The Kerbals to place in the vessel, by name. Controls how the vessel is crewed, as described in the remarks.

  • recover (boolean) – If true and there is a vessel on the launch site, recover it before launching. Defaults to true.

  • flagUrl (string) – If not null, the asset URL of the mission flag to use for the launch. Defaults to "".

Game Scenes:

Editor Vab, Editor Sph

Note

The vessel being constructed is not a craft file, so it is written to the editor’s auto-saved craft file and that is launched, as the game’s own launch button does. The vessel’s own craft file, if it was loaded from one, is left alone. The crew parameter works as it does for SpaceCenter.launchVessel(), and takes precedence over the crew assigned in the editor. Throws an exception if any of the games pre-flight checks fail.

Editor.getDeltaVBody()#
Editor.setDeltaVBody(value)#

The body whose gravity and atmosphere the vessel’s delta-v, thrust, TWR and specific impulse figures assume.

Property:

Can be read or written

Return type:

SpaceCenter.CelestialBody

Game Scenes:

Editor Vab, Editor Sph

Note

This and SpaceCenter.Editor.getDeltaVAltitude() are what SpaceCenter.EditorVessel.getDeltaV(), SpaceCenter.Stage.getDeltaV() and the other current-situation figures are computed for. The body sets the gravity the thrust-to-weight ratios are against, and, with the altitude, the atmospheric pressure and density the specific impulses and thrusts are against. This is global game state rather than editor state: the same setting backs the game’s delta-v readout in flight, and it persists across scene changes. Setting it asks the game to re-run the simulation and returns straight away; the figures are out of date until SpaceCenter.EditorVessel.getDeltaVReady() is true again.

Editor.getDeltaVAltitude()#
Editor.setDeltaVAltitude(value)#

The altitude above SpaceCenter.Editor.getDeltaVBody(), in meters, that the vessel’s delta-v, thrust, TWR and specific impulse figures assume. The atmospheric pressure and density at this altitude are what the figures are computed for, so raising it from zero to above the body’s atmosphere moves them from the vessel’s sea-level figures to its vacuum ones. Setting it asks the game to re-run the simulation and returns straight away; the figures are out of date until SpaceCenter.EditorVessel.getDeltaVReady() is true again.

Property:

Can be read or written

Return type:

number

Game Scenes:

Editor Vab, Editor Sph

Editor.getDeltaVSituation()#
Editor.setDeltaVSituation(value)#

Which situation the game’s own delta-v readout shows figures for.

Property:

Can be read or written

Return type:

SpaceCenter.DeltaVSituation

Game Scenes:

Editor Vab, Editor Sph

Note

This selects which column the game’s own delta-v app displays, and nothing else. It does not affect anything kRPC reports: the current-situation figures follow SpaceCenter.Editor.getDeltaVBody() and SpaceCenter.Editor.getDeltaVAltitude() whatever this is set to, and the sea-level and vacuum figures are reported directly as SpaceCenter.EditorVessel.getSeaLevelDeltaV() and SpaceCenter.EditorVessel.getVacuumDeltaV(). It is here for completeness with the app.

class SpaceCenter.DeltaVSituation()#

The situation the game’s own delta-v readout shows figures for. See SpaceCenter.Editor.getDeltaVSituation().

DeltaVSituation.seaLevel#

At sea level on the selected body.

DeltaVSituation.altitude#

At the selected altitude on the selected body.

DeltaVSituation.vacuum#

In vacuum.

class SpaceCenter.EditorVessel()#

The vessel that is being constructed in the editor. Obtained by calling SpaceCenter.Editor.getVessel().

EditorVessel.getName()#
EditorVessel.setName(value)#

The name of the vessel.

Property:

Can be read or written

Return type:

string

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.getDescription()#
EditorVessel.setDescription(value)#

The description of the vessel.

Property:

Can be read or written

Return type:

string

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.getFacility()#

The editor the vessel is in.

Property:

Read-only, cannot be set

Return type:

SpaceCenter.EditorFacility

Game Scenes:

Editor Vab, Editor Sph

Note

This is the editor the vessel is currently loaded into, not the one it was designed in. A vessel moved from the vehicle assembly building to the space plane hangar reports the space plane hangar.

EditorVessel.getMass()#

The total mass of the vessel, including resources and crew, in \(\mathrm{kg}\).

Property:

Read-only, cannot be set

Return type:

number

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.getDryMass()#

The total mass of the vessel, excluding resources, in \(\mathrm{kg}\).

Property:

Read-only, cannot be set

Return type:

number

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.getMomentOfInertia()#

The moment of inertia of the vessel around its center of mass in \(\mathrm{kg \cdot m^{2}}\). The inertia values in the returned 3-tuple are around the pitch, roll and yaw directions respectively. This corresponds to the vessels reference frame (SpaceCenter.EditorVessel.getReferenceFrame()).

Property:

Read-only, cannot be set

Return type:

[number, number, number]

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.getInertiaTensor()#

The inertia tensor of the vessel around its center of mass, in the vessels reference frame (SpaceCenter.EditorVessel.getReferenceFrame()). Returns the 3x3 matrix as a list of elements, in row-major order.

Property:

Read-only, cannot be set

Return type:

Array of number

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.getReferenceFrame()#

The reference frame that is fixed relative to the vessel, and orientated with the vessel.

  • The origin is at the center of mass of the vessel.

  • The axes rotate with the vessel.

  • The x-axis points out to the right of the vessel.

  • The y-axis points in the forward direction of the vessel.

  • The z-axis points out of the bottom off the vessel.

Property:

Read-only, cannot be set

Return type:

SpaceCenter.ReferenceFrame

Game Scenes:

Editor Vab, Editor Sph

Note

The axes are those of the root part. This is the frame SpaceCenter.Vessel.getReferenceFrame() gives at launch, with the root part as the control point.

EditorVessel.getSurfaceReferenceFrame()#

The reference frame that is fixed relative to the vessel, and orientated with the vertical of the editor.

  • The origin is at the center of mass of the vessel.

  • The axes are fixed in the editor.

  • The x-axis points upwards.

  • The y-axis and z-axis are horizontal.

Property:

Read-only, cannot be set

Return type:

SpaceCenter.ReferenceFrame

Game Scenes:

Editor Vab, Editor Sph

Note

This is the vessel as it stands in the editor, and as it stands at launch. The editor has no north or east, so the horizontal axes are fixed in the editor.

EditorVessel.flight([referenceFrame])#

Returns a SpaceCenter.SimulatedFlight object that can be used to simulate the vessel in flight, in the specified reference frame.

Arguments:
Return type:

SpaceCenter.SimulatedFlight

Game Scenes:

Editor Vab, Editor Sph

Note

Each call returns a new object, which is kept until the game leaves the editor.

EditorVessel.position(referenceFrame)#

The position of the center of mass of the vessel, in the given reference frame.

Arguments:
Returns:

The position as a vector.

Return type:

[number, number, number]

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.boundingBox(referenceFrame)#

The axis-aligned bounding box of the vessel in the given reference frame.

Arguments:
Returns:

The positions of the minimum and maximum vertices of the box.

Return type:

SpaceCenter.BoundingBox

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.rotation(referenceFrame)#

The rotation of the vessel, in the given reference frame.

Arguments:
Returns:

The rotation as a quaternion of the form (x, y, z, w).

Return type:

[number, number, number, number]

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.direction(referenceFrame)#

The direction in which the vessel is pointing, in the given reference frame.

Arguments:
Returns:

The direction as a unit vector.

Return type:

[number, number, number]

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.getCost()#

The total cost of the vessel, including resources, in funds.

Property:

Read-only, cannot be set

Return type:

number

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.getCrewCapacity()#

The total number of crew that the vessel can hold.

Property:

Read-only, cannot be set

Return type:

number

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.getParts()#

A SpaceCenter.Parts object, that can be used to interact with the parts that make up the vessel.

Property:

Read-only, cannot be set

Return type:

SpaceCenter.Parts

Game Scenes:

Editor Vab, Editor Sph

Note

Only the parts of SpaceCenter.Part that describe the design are available in the editor. Those that need a vessel in flight or running physics, such as the thermal members, are restricted to the flight scene. SpaceCenter.Part.position(), SpaceCenter.Part.centerOfMass(), SpaceCenter.Part.direction(), SpaceCenter.Part.rotation(), SpaceCenter.Part.boundingBox(), the part’s reference frames, SpaceCenter.Part.getMomentOfInertia() and SpaceCenter.Part.getInertiaTensor() are available.

EditorVessel.getResources()#

A SpaceCenter.EditorVessel.getResources() object for the resources the vessel can hold.

Property:

Read-only, cannot be set

Return type:

SpaceCenter.Resources

Game Scenes:

Editor Vab, Editor Sph

Note

This is a view of what the vessel can hold as designed. The flow-state members work, as they are part of the design, but nothing here reports how a resource would be drawn on in flight.

EditorVessel.getStages()#

Activation (burn) stages for the vessel, in ascending stage order. This does not include the -1 stage (parts with no staging icon), as it carries no delta-v; use SpaceCenter.EditorVessel.stageAt() with -1 to get those parts.

Property:

Read-only, cannot be set

Return type:

Array of SpaceCenter.Stage

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.stageAt(stage)#

The activation stage with the given number. Pass -1 to get the parts that are never activated (those with no staging icon).

Arguments:
  • stage (number) – Get activation stage at this index.

Return type:

SpaceCenter.Stage

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.getDecoupleStages()#

Decouple stages for the vessel, in ascending stage order. The -1 stage, containing the parts that are never decoupled and remain on the vessel, is included first when any such parts exist.

Property:

Read-only, cannot be set

Return type:

Array of SpaceCenter.Stage

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.decoupleStageAt(stage)#

The decouple stage with the given number. Pass -1 to get the parts that are never decoupled and remain on the vessel after all stages have fired.

Arguments:
  • stage (number) – Get decouple stage at this index.

Return type:

SpaceCenter.Stage

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.getDeltaVReady()#

Whether the stock delta-v figures for the vessel have been calculated.

Property:

Read-only, cannot be set

Return type:

boolean

Game Scenes:

Editor Vab, Editor Sph

Note

The game recalculates them in the background whenever the vessel changes, and whenever SpaceCenter.Editor.getDeltaVBody() or SpaceCenter.Editor.getDeltaVAltitude() is set, and they are out of date until it has finished. Reading SpaceCenter.EditorVessel.getDeltaV(), or any delta-v member of a SpaceCenter.Stage, before then raises an error rather than returning a stale figure. Poll this after changing anything the figures depend on.

EditorVessel.getDeltaV()#

Total delta-v for the vessel in the situation the game’s delta-v readout assumes, in \(\mathrm{m/s}\). See SpaceCenter.Editor.getDeltaVBody().

Property:

Read-only, cannot be set

Return type:

number

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.getVacuumDeltaV()#

Total vacuum delta-v for the vessel, in \(\mathrm{m/s}\).

Property:

Read-only, cannot be set

Return type:

number

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.getSeaLevelDeltaV()#

Total sea-level delta-v for the vessel, in \(\mathrm{m/s}\).

Property:

Read-only, cannot be set

Return type:

number

Game Scenes:

Editor Vab, Editor Sph

EditorVessel.getBurnTime()#

Total burn time for the vessel, in seconds.

Property:

Read-only, cannot be set

Return type:

number

Game Scenes:

Editor Vab, Editor Sph

class SpaceCenter.SimulatedFlight()#

Used to simulate the vessel in the editor in flight. The counterpart of SpaceCenter.Flight. All of the information returned by this class is given in the reference frame passed to SpaceCenter.EditorVessel.flight(), or in SpaceCenter.SimulatedFlight.getSurfaceReferenceFrame() if none was passed. Obtained by calling SpaceCenter.EditorVessel.flight().

Note

The simulated attitude is set by SpaceCenter.SimulatedFlight.getSurfaceReferenceFrame(), and belongs to this object. The vessel is read from the editor on each call, so the object follows every edit.

SimulatedFlight.getSurfaceReferenceFrame()#
SimulatedFlight.setSurfaceReferenceFrame(value)#

The reference frame of the surface the vessel is simulated over. Its x-axis points upwards, and gravity acts along the negative x-axis. Defaults to SpaceCenter.EditorVessel.getSurfaceReferenceFrame().

Property:

Can be read or written

Return type:

SpaceCenter.ReferenceFrame

Game Scenes:

Editor Vab, Editor Sph

Note

Only the rotation of the frame is used. A frame created relative to SpaceCenter.EditorVessel.getReferenceFrame() follows the vessel as it is edited.

SimulatedFlight.getCenterOfMass()#

The position of the center of mass of the vessel, in the reference frame SpaceCenter.ReferenceFrame

Property:

Read-only, cannot be set

Returns:

The position as a vector.

Return type:

[number, number, number]

Game Scenes:

Editor Vab, Editor Sph

SimulatedFlight.getRotation()#

The rotation of the vessel, in the reference frame SpaceCenter.ReferenceFrame

Property:

Read-only, cannot be set

Returns:

The rotation as a quaternion of the form (x, y, z, w).

Return type:

[number, number, number, number]

Game Scenes:

Editor Vab, Editor Sph

SimulatedFlight.getDirection()#

The direction that the vessel is pointing in, in the reference frame SpaceCenter.ReferenceFrame.

Property:

Read-only, cannot be set

Returns:

The direction as a unit vector.

Return type:

[number, number, number]

Game Scenes:

Editor Vab, Editor Sph

SimulatedFlight.getPitch()#

The pitch of the vessel relative to the horizon, in degrees. A value between -90° and +90°.

Property:

Read-only, cannot be set

Return type:

number

Game Scenes:

Editor Vab, Editor Sph

Note

An absolute Euler angle, ill-conditioned when the vessel points near vertical (a pitch near -90° or +90°). For an always-defined attitude use SpaceCenter.SimulatedFlight.getRotation() or SpaceCenter.SimulatedFlight.getDirection().

SimulatedFlight.getRoll()#

The roll of the vessel relative to the horizon, in degrees. A value between -180° and +180°.

Property:

Read-only, cannot be set

Return type:

number

Game Scenes:

Editor Vab, Editor Sph

Note

An absolute Euler angle, ill-conditioned when the vessel points near vertical (a pitch near -90° or +90°). For an always-defined attitude use SpaceCenter.SimulatedFlight.getRotation().

SimulatedFlight.getDisplacement()#

The volume of water the vessel displaces when fully submerged, in \(\mathrm{m^{3}}\).

Property:

Read-only, cannot be set

Return type:

number

Game Scenes:

Editor Vab, Editor Sph

SimulatedFlight.getFullySubmergedCenterOfBuoyancy()#

The point the buoyant force acts through with the vessel fully submerged, in reference frame SpaceCenter.ReferenceFrame. Returns null if no part of the vessel displaces any water.

Property:

Read-only, cannot be set

Returns:

The position as a vector.

Return type:

[number, number, number] or null

Game Scenes:

Editor Vab, Editor Sph

Note

A hull at rest carries this on the same vertical line as SpaceCenter.SimulatedFlight.getCenterOfMass().

SimulatedFlight.buoyantForceAt(density, gravity)#

The buoyant force on the vessel when fully submerged in a fluid of the given density, in Newtons.

Arguments:
  • density (number) – The density of the fluid, in \(\mathrm{kg/m^{3}}\).

  • gravity (number) – The acceleration due to gravity, in \(\mathrm{m/s^{2}}\).

Return type:

number

Game Scenes:

Editor Vab, Editor Sph

SimulatedFlight.buoyantTorqueAt(density, gravity)#

The torque the buoyant force exerts about the vessel’s center of mass when fully submerged in a fluid of the given density, in reference frame SpaceCenter.ReferenceFrame. Gravity acts along the negative x-axis of SpaceCenter.SimulatedFlight.getSurfaceReferenceFrame().

Arguments:
  • density (number) – The density of the fluid, in \(\mathrm{kg/m^{3}}\).

  • gravity (number) – The acceleration due to gravity, in \(\mathrm{m/s^{2}}\).

Returns:

A vector pointing along the axis of the torque, with its magnitude equal to the strength of the torque in \(\mathrm{N \cdot m}\).

Return type:

[number, number, number]

Game Scenes:

Editor Vab, Editor Sph