space_ex v0.8.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.
Returns: a reference to a SpaceEx.SpaceCenter.Vessel object
A dictionary of all celestial bodies (planets, moons, etc.) in the game, keyed by the name of the body.
Returns: %{str => celestial_body, ...}, where str is a string and celestial_body is a reference to a SpaceEx.SpaceCenter.CelestialBody object
An object that can be used to control the camera.
Returns: a reference to a SpaceEx.SpaceCenter.Camera object
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.
Returns: true or false
Clears the current target.
Returns: :ok
The contract manager.
Returns: a reference to a SpaceEx.SpaceCenter.ContractManager object
Whether Ferram Aerospace Research is installed.
Returns: true or false
The value of the gravitational constant G in \(N(m/kg)^2\).
Returns: a high precision decimal
Launch a vessel.
craft_directory— 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.launch_site— Name of the launch site. For example"LaunchPad"or"Runway".
Returns: :ok
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”.
Returns: :ok
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: :ok
Returns a list of vessels from the given craftDirectory
that can be launched.
craft_directory— Name of the directory in the current saves “Ships” directory. For example"VAB"or"SPH".
Returns: [str, ...], where str is a string
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.
Returns: :ok
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.
Returns: an integer
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.
Returns: an integer
Load a quicksave.
This is the same as calling SpaceEx.SpaceCenter.load/2 with the name “quicksave”.
Returns: :ok
Save a quicksave.
This is the same as calling SpaceEx.SpaceCenter.save/2 with the name “quicksave”.
Returns: :ok
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.
Returns: an integer
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.reference_frame— 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.
Returns: a high precision decimal
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.reference_frame— The reference frame that the position and direction are in.
Returns the part that was hit or nil if there was no hit.
Returns: a reference to a SpaceEx.SpaceCenter.Part object
Save the game with a given name.
This will create a save file called name.sfs in the folder of the
current save game.
Returns: :ok
The currently active vessel.
Returns: :ok
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.
Returns: :ok
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.
Returns: :ok
The currently targeted celestial body.
Returns: :ok
The currently targeted docking port.
Returns: :ok
The currently targeted vessel.
Returns: :ok
Whether the UI is visible.
Returns: :ok
The currently targeted celestial body.
Returns: a reference to a SpaceEx.SpaceCenter.CelestialBody object
The currently targeted docking port.
Returns: a reference to a SpaceEx.SpaceCenter.DockingPort object
The currently targeted vessel.
Returns: a reference to a SpaceEx.SpaceCenter.Vessel object
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.
Returns: {double, double, double}, where double is a high precision decimal
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.
Returns: {double, double, double}, where double is a high precision decimal
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.
Returns: {double, double, double, double}, where double is a high precision decimal
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.
Returns: {double, double, double}, where double is a high precision decimal
Whether the UI is visible.
Returns: true or false
The current universal time in seconds.
Returns: a high precision decimal
A list of all the vessels in the game.
Returns: [vessel, ...], where vessel is a reference to a SpaceEx.SpaceCenter.Vessel object
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.
Returns: a low-precision decimal
The current time warp mode.
Returns SpaceEx.SpaceCenter.WarpMode.none if time
warp is not active, SpaceEx.SpaceCenter.WarpMode.rails if regular “on-rails” time warp
is active, or SpaceEx.SpaceCenter.WarpMode.physics if physical time warp is active.
Returns: a Elixir.SpaceEx.SpaceCenter.WarpMode value in atom form
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.
Returns: a low-precision decimal
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.max_rails_rate— The maximum warp rate in regular “on-rails” time warp.max_physics_rate— The maximum warp rate in physical time warp.
Returns when the time warp is complete.
Returns: :ok
The waypoint manager.
Returns: a reference to a SpaceEx.SpaceCenter.WaypointManager object