space_ex v0.3.0 SpaceEx.SpaceCenter
Provides functionality to interact with Kerbal Space Program.
This includes controlling the active vessel, managing its resources, planning maneuver nodes and auto-piloting.
Link to this section Summary
Functions
The currently active vessel
A dictionary of all celestial bodies (planets, moons, etc.) in the game, keyed by the name of the body
An object that can be used to control the camera
Returns true
if regular "on-rails" time warp can be used, at the specified warp
factor
Clears the current target
The contract manager
Whether Ferram Aerospace Research is installed
The value of the gravitational constant G in \(N(m/kg)^2\)
Launch a vessel
Launch a new vessel from the SPH onto the runway
Launch a new vessel from the VAB onto the launchpad
Returns a list of vessels from the given craftDirectory
that can be launched
Load the game with the given name
The current maximum regular "on-rails" warp factor that can be set
Whether the navball is visible
The physical time warp rate
Load a quicksave
Save a quicksave
The time warp rate, using regular "on-rails" time warp
Cast a ray from a given position in a given direction, and return the distance to the hit point
Cast a ray from a given position in a given direction, and return the part that it hits
Save the game with a given name
The currently active vessel
Whether the navball is visible
The physical time warp rate
The time warp rate, using regular "on-rails" time warp
The currently targeted celestial body
The currently targeted docking port
The currently targeted vessel
Whether the UI is visible
The currently targeted celestial body
The currently targeted docking port
The currently targeted vessel
Converts a direction from one reference frame to another
Converts a position from one reference frame to another
Converts a rotation from one reference frame to another
Converts a velocity (acting at the specified position) from one reference frame to another
Whether the UI is visible
The current universal time in seconds
A list of all the vessels in the game
The current warp factor
The current time warp mode
The current warp rate
Uses time acceleration to warp forward to a time in the future, specified
by universal time ut
The waypoint manager
Link to this section Functions
The currently active vessel.
A dictionary of all celestial bodies (planets, moons, etc.) in the game, keyed by the name of the body.
An object that can be used to control the camera.
Returns true
if regular "on-rails" time warp can be used, at the specified warp
factor
.
The maximum time warp rate is limited by various things, including how close the active vessel is to a planet. See the KSP wiki for details.
factor
— The warp factor to check.
Clears the current target.
The contract manager.
Whether Ferram Aerospace Research is installed.
The value of the gravitational constant G in \(N(m/kg)^2\).
Launch a vessel.
craftDirectory
— Name of the directory in the current saves "Ships" directory, that contains the craft file. For example"VAB"
or"SPH"
.name
— Name of the vessel to launch. This is the name of the ".craft" file in the save directory, without the ".craft" file extension.launchSite
— Name of the launch site. For example"LaunchPad"
or"Runway"
.
Launch a new vessel from the SPH onto the runway.
name
— Name of the vessel to launch.
This is equivalent to calling SpaceEx.SpaceCenter.launch_vessel/4
with the craft directory
set to "SPH" and the launch site set to "Runway".
Launch a new vessel from the VAB onto the launchpad.
name
— Name of the vessel to launch.
This is equivalent to calling SpaceEx.SpaceCenter.launch_vessel/4
with the craft directory
set to "VAB" and the launch site set to "LaunchPad".
Returns a list of vessels from the given craftDirectory
that can be launched.
craftDirectory
— Name of the directory in the current saves "Ships" directory. For example"VAB"
or"SPH"
.
Load the game with the given name.
This will create a load a save file called name.sfs
from the folder of the
current save game.
The current maximum regular "on-rails" warp factor that can be set.
A value between 0 and 7 inclusive. See the KSP wiki for details.
The physical time warp rate.
A value between 0 and 3 inclusive. 0 means no time warp. Returns 0 if regular "on-rails" time warp is active.
Load a quicksave.
This is the same as calling SpaceEx.SpaceCenter.load/2
with the name "quicksave".
Save a quicksave.
This is the same as calling SpaceEx.SpaceCenter.save/2
with the name "quicksave".
The time warp rate, using regular "on-rails" time warp.
A value between 0 and 7 inclusive. 0 means no time warp. Returns 0 if physical time warp is active.
If requested time warp factor cannot be set, it will be set to the next lowest possible value. For example, if the vessel is too close to a planet. See the KSP wiki for details.
Cast a ray from a given position in a given direction, and return the distance to the hit point.
If no hit occurs, returns infinity.
position
— Position, as a vector, of the origin of the ray.direction
— Direction of the ray, as a unit vector.referenceFrame
— The reference frame that the position and direction are in.
Returns: The distance to the hit, in meters, or infinity if there was no hit.
Cast a ray from a given position in a given direction, and return the part that it hits.
If no hit occurs, returns nil
.
position
— Position, as a vector, of the origin of the ray.direction
— Direction of the ray, as a unit vector.referenceFrame
— The reference frame that the position and direction are in.
Returns: The part that was hit or nil
if there was no hit.
Save the game with a given name.
This will create a save file called name.sfs
in the folder of the
current save game.
The currently active vessel.
The physical time warp rate.
A value between 0 and 3 inclusive. 0 means no time warp. Returns 0 if regular "on-rails" time warp is active.
The time warp rate, using regular "on-rails" time warp.
A value between 0 and 7 inclusive. 0 means no time warp. Returns 0 if physical time warp is active.
If requested time warp factor cannot be set, it will be set to the next lowest possible value. For example, if the vessel is too close to a planet. See the KSP wiki for details.
The currently targeted celestial body.
The currently targeted docking port.
The currently targeted vessel.
Whether the UI is visible.
The currently targeted celestial body.
The currently targeted docking port.
The currently targeted vessel.
Converts a direction from one reference frame to another.
direction
— Direction, as a vector, in reference framefrom
.from
— The reference frame that the direction is in.to
— The reference frame to covert the direction to.
Returns: The corresponding direction, as a vector, in reference frame
to
.
Converts a position from one reference frame to another.
position
— Position, as a vector, in reference framefrom
.from
— The reference frame that the position is in.to
— The reference frame to covert the position to.
Returns: The corresponding position, as a vector, in reference frame
to
.
Converts a rotation from one reference frame to another.
rotation
— Rotation, as a quaternion of the form \((x, y, z, w)\), in reference framefrom
.from
— The reference frame that the rotation is in.to
— The reference frame to covert the rotation to.
Returns: The corresponding rotation, as a quaternion of the form
\((x, y, z, w)\), in reference frame to
.
Converts a velocity (acting at the specified position) from one reference frame to another.
The position is required to take the relative angular velocity of the reference frames into account.
position
— Position, as a vector, in reference framefrom
.velocity
— Velocity, as a vector that points in the direction of travel and whose magnitude is the speed in meters per second, in reference framefrom
.from
— The reference frame that the position and velocity are in.to
— The reference frame to covert the velocity to.
Returns: The corresponding velocity, as a vector, in reference frame
to
.
Whether the UI is visible.
The current universal time in seconds.
A list of all the vessels in the game.
The current warp factor.
This is the index of the rate at which time
is passing for either regular "on-rails" or physical time warp. Returns 0
if time warp is not active. When in on-rails time warp, this is equal to
SpaceEx.SpaceCenter.rails_warp_factor/1
, and in physics time warp, this is equal to
SpaceEx.SpaceCenter.physics_warp_factor/1
.
The current time warp mode.
Returns :none
if time
warp is not active, :rails
if regular "on-rails" time warp
is active, or :physics
if physical time warp is active.
The current warp rate.
This is the rate at which time is passing for either on-rails or physical time warp. For example, a value of 10 means time is passing 10x faster than normal. Returns 1 if time warp is not active.
Uses time acceleration to warp forward to a time in the future, specified
by universal time ut
.
This call blocks until the desired
time is reached. Uses regular "on-rails" or physical time warp as appropriate.
For example, physical time warp is used when the active vessel is traveling
through an atmosphere. When using regular "on-rails" time warp, the warp
rate is limited by maxRailsRate
, and when using physical
time warp, the warp rate is limited by maxPhysicsRate
.
ut
— The universal time to warp to, in seconds.maxRailsRate
— The maximum warp rate in regular "on-rails" time warp.maxPhysicsRate
— The maximum warp rate in physical time warp.
Returns: When the time warp is complete.
The waypoint manager.