MASFlightComputerProxy3 - MOARdV/AvionicsSystems GitHub Wiki

MASFlightComputerProxy3.cs

Contents

The fc group contains the core interface between KSP, Avionics Systems, and props in an IVA. It consists of many 'information' functions that can be used to get information as well as numerous 'action' functions that are used to do things.

Due to the number of methods in the fc group, this document has been split across three pages:

NOTE 1: If a function listed below includes an entry for 'Supported Mod(s)', then that function will automatically use one of the mods listed to generate the data. In some cases, it is possible that the function does not work without one of the required mods. Those instances are noted in the function's description.

NOTE 2: Many descriptions make use of mathetmatical short-hand to describe a range of values. This short-hand consists of using square brackets [ and ] to denote "inclusive range", while parentheses ( and ) indicate exclusive range.

For example, if a parameter says "an integer between [0, fc.ExperimentCount())", it means that the parameter must be an integer greater than or equal to 0, but less than fc.ExperimentCount().

For another example, if a parameter says "a number in the range [0, 1]", it means that the number must be at least zero, and it must not be larger than 1.


Resources Category

The resource methods report the availability of various resources aboard the vessel. They are grouped into three types.

'Power' methods PowerCurrent(), etc, report the state of the resource identified in the MAS config file. By default, this is ElectricCharge, but mods may use a different resource for power, instead. By using the 'Power' methods, IVA makers do not have to worry about adapting their IVA configurations for use with modded configurations, as long as the player has correctly configured MAS to use the alternative power name.

'Propellant' methods track all of the active fuel types being used by ModuleEngines and ModuleEnginesFX. Instead of reporting the current and maximum amounts in units, like the 'Resource' methods do, these methods report amounts in kilograms. Using the propellant mass allows these methods to track alternate fuel types (such as mods using LHyd + Oxidizer), with the downside being mixed engine configurations, such as solid rockets + liquid-fueled engines) may be less helpful

'Rcs' methods work similarly to the 'Propellant' methods, but they track resource types consumed by ModuleRCS and ModuleRCSFX.

'Resource' methods that take a numeric parameter are ordinal resource listers. The numeric parameter is a number from 0 to fc.ResourceCount() - 1. This allows the IVA maker to display an alphabetized list of resources (on an MFD, for instance).

'Resource' methods that take a string parameter return the named resource. The name must match the name field of a RESOURCE_DEFINITION config node, or 0 will be returned.

fc.GetPowerDraw()

Returns: The current power draw of the flight computer, in EC/sec.

Returns the amount of power this MASFlightComputer requires.

fc.ChangePowerDraw(double rateChange)

  • rateChange: The amount of additional EC/sec required to operate the IVA (positive to increase, negative to decrease).

Returns: The current power draw of the flight computer, in EC/sec.

Increase or decrease the amount of power the MASFlightComputer requires.

This feature can be used to simulate subcomponents of the IVA being switched on or off. The minimum power draw of the MASFlightComputer is defined by its rate field in the configuration file. ChangePowerDraw can not be used to reduce the total power demand below rate.

NOTE: Additional power draw above rate is not persistent. This function is best used by creating a TRIGGER_EVENT in the appropriate prop that uses fc.ChangePowerDraw() with a positive value as the event, and fc.ChangePowerDraw() with a negative values as the exitEvent.

fc.PowerCurrent()

Returns: Current units of power.

Returns the current level of available power for the designated "Power" resource; by default, this is ElectricCharge.

fc.PowerDelta()

Returns the rate of change in available power (units/sec) for the designated "Power" resource; by default, this is ElectricCharge.

fc.PowerMax()

Returns the maximum capacity of the resource defined as "power" in the config. By default, this is ElectricCharge.

fc.PowerPercent()

Returns the current percentage of maximum capacity of the resource designated as "power" - in a stock installation, this would be ElectricCharge.

fc.PowerThreshold(double firstBound, double secondBound)

  • firstBound: The first boundary percentage, between 0 and 1.
  • secondBound: The second boundary percentage, between 0 and 1.

Returns: 1 if the power percentage is between the listed bounds.

Reports whether the vessel's power percentage falls between the two listed bounds. The bounds do not need to be in numerical order.

If there is no power onboard, returns 0. Doing so makes this function useful for alerts, for example.

fc.PropellantCurrent()

Returns: The current quantity of the active propellants in the vessel, in U.

Reports the total quantity in units (U) of resources currently being consumed by all active engines on the vessel.

fc.PropellantDelta()

Returns: The current propellant consumption rate, in U/s.

Reports the propellant consumption rate in U/s for all active engines on the vessel.

fc.PropellantDensity()

Returns: Propellant density in kg/U.

Returns the current density of the propellant. Note that because different propellants for different engines may be consumed at different rates, the density is only valid for the current propellant quantity. It should not be used to determine maximum propellant mass, unless you know in advance that all active propellants load are consumed at the same rate.

fc.PropellantMass()

Returns: The current propellant mass, in kg.

Reports the current mass of the propellant, including any locked resource tanks.

fc.PropellantMax()

Returns: The maximum propellant capacity, in U.

Reports the maximum amount of propellant, in units (U), that may be carried aboard the vessel.

fc.PropellantPercent()

Returns: The percentage of maximum propellant capacity that contains propellant, between 0 and 1.

Reports the current percentage of propellant aboard the vessel.

fc.PropellantReserve()

Returns: The locked propellant amount, in U.

Reports the amount of propellant, in U, that is currently locked (unavailable to engines).

fc.PropellantStageCount()

Reports the number of propellants currently in use.

fc.PropellantStageCurrent()

Returns: The current quantity of propellant accessible by the current stage, in U.

Reports the current amount of propellant, in U, available to active engines on the current stage.

fc.PropellantStageMax()

Returns: The maximum quantity of propellant accessible by the current stage, in U.

Reports the maximum amount of propellant available, in U, to the active engines on the current stage. Note that locked propellant tanks are not reported by this function.

fc.PropellantStageDisplayName(double index)

  • index: A number between 0 and fc.PropellantStageCount() - 1, inclusive.

Returns: The name of the propellant, or an empty string for invalid indices.

Returns the display (localized) name of the active propellant indexed by index. This call is equivalent to fc.ResourceDisplayName(fc.PropellantStageResourceId(index)).

fc.PropellantStageName(double index)

  • index: A number between 0 and fc.PropellantStageCount() - 1, inclusive.

Returns: The name of the propellant, or an empty string for invalid indices.

Returns the name of the active propellant indexed by index. This call is equivalent to fc.ResourceName(fc.PropellantStageResourceId(index)).

fc.PropellantStagePercent()

Returns: The percentage of maximum stage propellant capacity that contains propellant, between 0 and 1.

Reports the percentage of propellant remaining on the current stage for the active engines.

fc.PropellantStageResourceId(double index)

  • index: A number between 0 and fc.PropellantStageCount() - 1, inclusive.

Returns: The resourceId of the propellant, or -1 for invalid indices.

Returns the resourceId of the active propellant indexed by index. This value can be used in the various Resource methods in this category.

fc.PropellantStageThreshold(double firstBound, double secondBound)

  • firstBound: The first boundary percentage, between 0 and 1.
  • secondBound: The second boundary percentage, between 0 and 1.

Returns: 1 if current stage propellant is between the listed bounds.

Reports whether the current stage propellant percentage falls between the two listed bounds. The bounds do not need to be in numerical order.

If there is no propellant on the current stage, returns 0. Doing so makes this function useful for alerts, for example.

fc.PropellantThreshold(double firstBound, double secondBound)

  • firstBound: The first boundary percentage, between 0 and 1.
  • secondBound: The second boundary percentage, between 0 and 1.

Returns: 1 if propellant is between the listed bounds.

Reports whether the vessel's available propellant percentage falls between the two listed bounds. The bounds do not need to be in numerical order.

If there is no propellant or active engines, returns 0. Doing so makes this function useful for alerts, for example.

Reserve propellant is not included in this computation.

fc.RcsCurrent()

Returns: Total RCS propellant quantity in units.

Tracks the current units of all resources consumed by installed RCS thrusters.

fc.RcsDelta()

Returns: RCS propellant consumption rate in units/s.

Tracks the current resource consumption rate by installed RCS thrusters.

fc.RcsDensity()

Returns: RCS propellant consumption rate in kg/U.

Reports the current density of propellant for all RCS thrusters.

fc.RcsMass()

Returns: Current RCS propellant mass, in kg.

Reports the current mass of RCS propellant accessible by the current stage.

fc.RcsMax()

Returns: Maximum propellant capacity in units.

Tracks the total units that can be carried in all RCS propellant tanks.

fc.RcsPercent()

Returns: Current RCS propellant supply, between 0 and 1.

Tracks the percentage of total RCS propellant currently onboard.

fc.RcsReserve()

Returns: Reserve RCS propellant, in U.

Returns the number of units of RCS propellant that is currently locked and unavailable.

fc.RcsStageCurrent()

Returns: Available RCS propellant, in units.

Reports the current amount of RCS propellant available to the active stage.

fc.RcsStageMax()

Returns: Maximum stage RCS propellant mass, in units.

Reports the maximum amount of RCS propellant storage accessible by the current stage.

fc.RcsStagePercent()

Returns: Current stage percentage, between 0 and 1.

Reports the percentage of RCS propellant mass available to the current stage.

fc.RcsStageThreshold(double firstBound, double secondBound)

  • firstBound: The first boundary percentage, between 0 and 1.
  • secondBound: The second boundary percentage, between 0 and 1.

Returns: 1 if current stage RCS propellant is between the listed bounds.

Reports whether the current stage RCS propellant percentage falls between the two listed bounds. The bounds do not need to be in numerical order.

If there is no RCS propellant on the current stage, returns 0. Doing so makes this function useful for alerts, for example.

fc.RcsThreshold(double firstBound, double secondBound)

  • firstBound: The first boundary percentage, between 0 and 1.
  • secondBound: The second boundary percentage, between 0 and 1.

Returns: 1 if RCS propellant is between the listed bounds.

Reports whether the vessel's RCS propellant percentage falls between the two listed bounds. The bounds do not need to be in numerical order.

If there is no RCS propellant, returns 0. Doing so makes this function useful for alerts, for example.

This function does not count reserve quantities.

fc.ResourceAbbreviatedName(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns the abbreviation for the selected resource, or an empty string if the resource selected is invalid.

Some mod resources may not have an abbreviation. For those resources, the first three letters of the localized name are returned. If the resource does not have a localized name, either, then the first three letters of the internal name are returned.

fc.ResourceCount()

Returns the total number of resources found on this vessel.

fc.ResourceCurrent(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns the current available amount of the selected resource.

fc.ResourceDelta(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns the instantaneous change-per-second of the selected resource, or zero if the resource is invalid.

A positive number means the resource is being consumed (burning fuel, for instance).

fc.ResourceDensity(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns: Density in kg / unit

Returns the density of the selected resource, or zero if it is invalid.

fc.ResourceDisplayName(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns the display (localized) name of the selected resource, or an empty string if it doesn't exist.

fc.ResourceExists(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns 1 if resourceId is valid (there is a resource with that id on the craft).

fc.ResourceIsPropellant(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns: 1 if the resource is currently a propellant, 0 otherwise.

Returns 1 if the identified resource is currently marked as a propellant.

fc.ResourceLocked(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource. Use -1 to query if any resource is locked.

Returns 1 if the selected resource is locked (can not transfer resources) anywhere on the vessel. Returns 0 if the part is unlocked, or if it is not present.

Use -1 to query if any resource is locked.

fc.ResourceMass(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns the current mass of the selected resource in kg.

fc.ResourceMassMax(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns the maximum mass of the selected resource.

fc.ResourceMax(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns the maximum quantity of the selected resource.

fc.ResourceName(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns the internal name of the selected resource, or an empty string if it doesn't exist.

fc.ResourcePercent(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns the amount of the selected resource remaining as a percentage in the range [0, 1].

fc.ResourceReserve(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns: The amount of the selected resource that is locked, or 0.

Returns the amount of the selected resource that is marked as unavailable for use (locked).

fc.ResourceStageCurrent(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns the current amount of the selected resource in the current stage.

fc.ResourceStageMass(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns the current mass of the selected resource in the current stage.

fc.ResourceStageMassMax(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns the maximum mass of the selected resource in the current stage.

fc.ResourceStageMax(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns the max amount of the selected resource in the current stage.

fc.ResourceStagePercent(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns the max amount of the selected resource in the current stage.

fc.ResourceStageThreshold(object resourceId, double firstBound, double secondBound)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.
  • firstBound: The first boundary percentage, between 0 and 1.
  • secondBound: The second boundary percentage, between 0 and 1.

Returns: 1 if current stage resource percentage is between the listed bounds.

Reports whether the named resource's current stage percentage falls between the two listed bounds. The bounds do not need to be in numerical order.

If there is no such resource on the current stage, returns 0. Doing so makes this function useful for alerts, for example.

fc.ResourceThreshold(object resourceId, double firstBound, double secondBound)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.
  • firstBound: The first boundary percentage, between 0 and 1.
  • secondBound: The second boundary percentage, between 0 and 1.

Returns: 1 if the resource percentage is between the listed bounds.

Reports whether the vessel's total resource percentage falls between the two listed bounds. The bounds do not need to be in numerical order.

If there is no resource capacity onboard, returns 0. Doing so makes this function useful for alerts, for example.

fc.SetAllResourcesUnlocked()

Returns: 1 if any resources were unlocked, 0 if all resources were already available.

Sets all resources aboard the vessel as available.

fc.SetResourceLock(object resourceId, bool lockResource)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.
  • lockResource: When true, prevents that resource from being consumed. When false, allows that resource to be consumed.

Returns: 1 if the resource is present on the vessel, 0 otherwise.

Controls whether resourceId can be consumed.

When lockResource is true, all remaining resources of that type on the vessel are locked (unavailable). When lockResource is false, resources may be consumed.

Note that this will toggle all resource containers on the vessel.

fc.ToggleResourceLock(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns: 1 if the resource is present on the vessel, 0 otherwise.

Toggles the lock / unlock state of each resource container for resourceId. Locked resources are unlocked, unlocked resources are locked.

fc.VesselPowered()

Returns: 1 if there is ElectricCharge, 0 otherwise.

Returns 1 when there is at least 0.0001 units of power available to the craft. By default, 'power' is the ElectricCharge resource, but users may change that in the MAS config file.


Resource Converter Category

The Resource Converter category allows an IVA creator to register to track specific resources converters (ModuleResourceConverter) that are of interest to the IVA. By default, the MASFlightComputer installs a Resource Converter tracker for "ElectricCharge" (or whatever override resource is configured in the persistent file) as id number 0. This tracker is used to provide information for the Fuel Cell functions (FuelCellCount(), etc).

Any number of trackers may be installed. The only requirement is that each must be given a unique id that is a positive integer (1 or higher). When assigning a ModuleResourceConverter that has multiple outputs to a group, MAS will place it in the group with the highest id.

For example, say a ModuleResourceConverter took "Water" as an input, and it generated "LqdHydrogen" and "Oxidizer" for output. If Resource Converter group 1 tracked "LqdHydrogen" output and group 2 tracked "Oxidizer", then this resource converter would be assigned to group 2, since it is the highest priority resource of the two listed.

If an IVA tries to register more than one resource type to the same id, only the first one found will be registered. For instance, if a MASFlightComputer script attempts to call fc.TrackResourceConverter(1, "LqdHydrogen") and then calls fc.TrackResourceConverter(1, "Oxidizer"), then group 1 will track "LqdHydrogen". MAS will return a -1 on the second call to indicate that the requested group id is already in use with a different resource.

fc.GetResourceConverterActive(double id)

  • id: The id number of the resource converter group to query. Must be an integer 0 or larger.

Returns: 1 if any selected resource converter is switched on; 0 otherwise.

Returns 1 if at least one resource converter in the group selected by id is enabled; 0 otherwise.

fc.ResourceConverterCount(double id)

  • id: The id number of the resource converter group to query. Must be an integer 0 or larger.

Returns the number of resource converters that generate the output selected by the resource converter group id.

fc.ResourceConverterOutput(double id)

  • id: The id number of the resource converter group to query. Must be an integer 0 or larger.

Returns: Units of the resource generated per second.

Returns the current output of installed fuel cells.

fc.SetResourceConverterActive(double id, bool newState)

  • id: The id number of the resource converter group to query. Must be an integer 0 or larger.

Returns: 1 if resource converters are now active, 0 if they're off or they could not be toggled.

Sets the resource converter group selected by id on or off.

fc.ToggleResourceConverterActive(double id)

  • id: The id number of the resource converter group to query. Must be an integer 0 or larger.

Returns: 1 if resource converters are now active, 0 if they're off or they could not be toggled.

Toggles the resource converter group selected by id on or off.

fc.TrackResourceConverter(double id, string resourceName)

  • id: The id number to assign to this resource. Must be an integer 1 or larger.
  • resourceName: The name of the resource (from the name field of a RESOURCE_DEFINITION).

Returns: 1 if the converter was registered (or was already registered with the same id), -1 if a resource converter was registered using that id with a different resourceName, and 0 if an invalid id was provided.

Registers a family of Resource Converters with MAS. A resource converter is defined by two components: the id and the resourceName.

The id defines the priority, with larger numbers indicating a higher priority. When a specific ModuleResourceConverter has more than one output, MAS will add the module to the highest-priority tracked resource converter.

For example, if a particular resource converter outputs "LiquidFuel" and "Oxidizer", and "LiquidFuel" is registered as id = 1, and "Oxidizer" is registered as id = 2, then MAS will treat that resource converter as id = 2 with an "Oxidizer" output.

If more than one call to TrackResourceConverter uses the same id with different resourceName values, only the first such call applies. Additional calls using a different resourceName will have no effect, and TrackResourceConverter() will return -1.

id must be a positive number. id = 0 is reserved for "ElectricCharge", which corresponds with the Fuel Cell methods. If a call to TrackResourceConverter uses "ElectricCharge" with an id greater than zero, then the Fuel Cell methods will behave as if no fuel cells are installed.

The resourceName must be one of the name fields for a RESOURCE_DEFINITION, such as "ElectricCharge" in GameData/Squad/Resources/ResourcesGeneric.cfg. If an invalid resourceName is provided (for instance, if it is for a resource included in a mod that is not installed), there are no errors - MAS behaves as if there are no relevant resource converters.


Harvester Category

The Harvester section provides methods to query the state of a vessel's drills or resource abundance.

NOTE: A future update may split the resource scanning into a separate section.

fc.DrillTemperature(bool useKelvin)

  • useKelvin: If true, temperature is returned in Kelvin; if false, temperature is Celsius.

Returns: Average drill temperature. 0 if no drills installed.

Query returns the average temperature of all drills.

If any drills are active, the result is for active drills.

If no drills are active, the result is for all drills.

If the vessel has no drills, this function returns 0.

fc.DrillThermalEfficiency()

Returns: Thermal efficiency of active drills, in the range of 0 and 1, inclusive.

Query returns the thermal efficiency of active drills. If the vessel has no drills, this function returns 0.0;

fc.DrillActiveCount()

Returns: The number of active drill modules on the vessel.

Returns the number of active drills on the vessel.

fc.DrillDeployedCount()

Returns the number of drills that are currently deployed.

fc.ResourceScannerInRange(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns: 1 if the resource is in range, otherwise 0.

Returns 1 if the selected resource is in scanner range. If no resource scanners are installed, or the resource is not in range, returns 0.

fc.ResourceAbundance(object resourceId)

  • resourceId: A number between 0 and fc.ResourceCount()-1 or the name of a resource.

Returns: The abundance of the specified resource, or 0.

Returns a resource abundance rating for the requested resource.


SAS Category

The SAS section provides methods to control and query the state of a vessel's SAS stability system.

fc.CanSetSASMode(double mode)

Returns: 1 if the selected mode is currently selectable, 0 otherwise.

Query if a select SAS mode is may be selected. For example, mode 9 (Maneuver Node) is not valid if there is no maneuver node.

If SAS is off, this function always returns 0.

fc.GetPrecisionMode()

Returns: 1 if the controls are in precision mode, 0 if they are not.

Returns whether the controls are configured for precision mode.

fc.GetSAS()

Returns 1 if SAS is on, 0 otherwise.

fc.GetSASMode()

Returns: A number between 0 and 9, inclusive.

Returns a number representing the SAS mode:

  • 0 = StabilityAssist
  • 1 = Prograde
  • 2 = Retrograde
  • 3 = Normal
  • 4 = Anti-Normal
  • 5 = Radial In
  • 6 = Radial Out
  • 7 = Target
  • 8 = Anti-Target
  • 9 = Maneuver Node

fc.GetSASModeName(double mode)

  • mode: The SAS mode that is being queried

Returns: Returns the localized string for the selected mode, or "???" for an invalid mode.

Returns the localized name for the mode number provided. Invalid modes return "???"

fc.GetSASSpeedMode()

Return the current speed display mode: 1 for orbit, 0 for surface, and -1 for target.

fc.SASHasActions()

Returns 1 if the SAS action group has actions assigned to it.

fc.SetPrecisionMode(bool state)

  • state: 'true' to enable precision control, 'false' to disable it.

Returns: 1 if precision mode is now on, 0 if it is now off.

Activates or deactivates precision control mode.

fc.SetSAS(bool active)

Returns: 1 if the SAS action group is on, 0 otherwise.

Set the SAS state to on or off per the parameter.

fc.SetSASMode(double mode)

  • mode: One of the modes listed above. If an invalid value is provided, Stability Assist is set.

Returns: 1 if the mode was set, 0 if an invalid mode was specified

Set the SAS mode. Note that while you can set this mode when SAS is off, KSP sets it back to Stability Assist when SAS is switched on. Valid modes are:

  • 0 = StabilityAssist
  • 1 = Prograde
  • 2 = Retrograde
  • 3 = Normal
  • 4 = Anti-Normal
  • 5 = Radial In
  • 6 = Radial Out
  • 7 = Target
  • 8 = Anti-Target
  • 9 = Maneuver Node

fc.TogglePrecisionMode()

Returns: 1 if precision mode is now on, 0 if it is now off.

Toggle precision control mode

fc.ToggleSAS()

Returns: 1 if SAS is now on, 0 if it is now off.

Toggles SAS on-to-off or vice-versa

fc.ToggleSASSpeedMode()

Returns: The new speed mode (see fc.GetSASSpeedMode()).

Toggles the SAS speed mode.


Science Category

The Science category provides interaction with science experiments, categories of science experiments, and data transmitters.

The Experiment functions interact with individual experiments on the vessel, such as a Crew Report in the Command Pod. The ScienceType functions interact with categories of experiments.

Data Transmitters are any transmitter on the vessel capable of transmitting science. Not every transmitter can send science, however (such as the default transmitter found in a Command Pod), so the transmitters that MAS reports will not be all of the transmitters on the vessel.

Note that the functions that run an experiment always trigger the KSP experiment dialog, even if the UI overlays are switched off. The dialog's buttons do not intercept the button presses, so it won't have any side-effects other than possibly confusion when he player enables the UI later.

fc.CollectExperiments(double scienceContainerId)

  • scienceContainerId: An integer between [0, fc.ScienceContainerCount()).

Returns: 1 if a valid science container was selected, 0 otherwise.

Tell the science container identified by scienceContainerId to fill itself with as many experiments as possible.

fc.DataTransmitterAvailable(double transmitterId)

  • transmitterId: An integer in the range [0, fc.DataTransmitterCount()).

Returns: 1 if the selected transmitter is available to send data, 0 if it is not, or an invalid transmitterId was provided.

Indicates whether the selected transmitter is available for transmitting science.

TODO: This function only checks if the transmitter is busy. It should also check transmission ranges, once I find out how to do that.

fc.DataTransmitterCount()

Returns: An integer 0 or larger.

Returns the number of data transmitters aboard the vessel that are capable of transmitting science.

fc.DumpScienceContainer(double scienceContainerId)

  • scienceContainerId: An integer between [0, fc.ScienceContainerCount()).

Returns: 1 if data was dumped, 0 if the container was empty or an invalid container was selected.

Dump all of the data stored in the selected science container.

fc.DuplicateExperiment(double experimentId)

  • experimentId: An integer between 0 and fc.ExperimentTotal() - 1, inclusive.

Returns: 1 if the vessel already has equivalent data stored, 0 if it does not, or the experimentId is invalid.

Checks to see if the vessel currently has data for the selected experiment in the current circumstances (situation, biome, etc).

fc.DuplicateScienceType(double scienceTypeId)

  • scienceTypeId: An integer in the range [0, fc.ScienceTypeTotal()).

Returns: 1 if the vessel already has equivalent data stored, 0 if it does not, or the scienceTypeId is invalid.

Checks to see if the vessel already has data for the selected science type in the current circumstances (situation, biome).

fc.ExperimentAvailableCount(double scienceTypeId)

  • scienceTypeId: An integer in the range [0, fc.ScienceTypeTotal()).

Returns: The number of valid experiments available for the selected science type.

Returns a count of the number of experiments of the specified science type that are available. If an invalid science type is selected, returns 0.

fc.ExperimentBiome(double experimentId)

  • experimentId: An integer between 0 and fc.ExperimentTotal() - 1, inclusive.

Returns: The name of the biome, or an empty string.

Returns the name of the biome where the experiment experimentId was conducted.

If experimentId does not refer to a valid experiment, or if the selected experiment has not been run, or a biome does not apply (such as when in orbit), an empty string is returned.

fc.ExperimentCount(double scienceTypeId)

  • scienceTypeId: An integer in the range [0, fc.ScienceTypeTotal()).

Returns: The total number of experiments for the selected science type.

Returns a count of the total number of experiments of the specified science type. If an invalid science type is selected, returns 0.

fc.ExperimentDataSize(double experimentId)

  • experimentId: An integer between 0 and fc.ExperimentTotal() - 1, inclusive.

Returns: The data size of the experiment, in Mits, or 0.

Returns the size of the data for experiment experimentId.

If experimentId is an invalid experiment id, or the experiment has not run, returns 0.

fc.ExperimentId(double scienceTypeId, double experimentIndex)

  • scienceTypeId: An integer in the range [0, fc.ScienceTypeTotal()).
  • experimentIndex: An integer in the range [0, fc.ExperimentCount(scienceTypeId)).

Returns: The experimentId for the selected experiment, or -1 if an invalid id or index was provided.

Returns the experimentId value for the selected experiment for the science type ID. This value may then be used as the parameter for science fields that require experimentId. If an invalid scienceTypeId or experimentIndex is used, this function returns -1.

fc.ExperimentResults(double experimentId)

  • experimentId: An integer between 0 and fc.ExperimentTotal() - 1, inclusive.

Returns: The results of the experiment, or an empty string.

Returns the results of the selected experiment.

Note that this string may be lengthy - using fc.ScrollingMarquee() is recommended.

fc.ExperimentScienceValue(double experimentId)

  • experimentId: An integer between 0 and fc.ExperimentTotal() - 1, inclusive.

Returns: The science value of the experiment, or 0.

Returns the science value of the experiment selected by experimentId.

If experimentId is not a valid experiment, or the experiment has not been run, returns 0. It will also return 0 if the stored experiment has no science value, of course.

fc.ExperimentSituation(double experimentId)

  • experimentId: An integer between 0 and fc.ExperimentTotal() - 1, inclusive.

Returns: The name of the biome, or an empty string.

Returns the name of the situation where the experiment experimentId was conducted.

If experimentId does not refer to a valid experiment, or if the selected experiment has not been run, or a situaion does not apply, an empty string is returned.

fc.ExperimentStatus(double experimentId)

  • experimentId: An integer between 0 and fc.ExperimentTotal() - 1, inclusive.

Returns: -1, 0, or +1.

Returns the status of the selected experimentId.

  • +1: Experiment has run, results are available.
  • 0: Experiment has not run, or invalid experimentId
  • -1: Experiment has run, results have been transmitted.

fc.ExperimentTransmissionScalar(double experimentId)

  • experimentId: An integer between 0 and fc.ExperimentTotal() - 1, inclusive.

Returns: The data transmission scalar, or 0 if an invalid experimentid is supplied.

Returns the data transmission scalar for the experiment experimentId.

fc.ExperimentType(double experimentId)

  • experimentId: An integer between 0 and fc.ExperimentTotal() - 1, inclusive.

Returns: The name of the experiment type, or an empty string.

Returns the type of experiment the experiment experimentId contains.

Returns an empty string if experimentId is invalid.

fc.ExperimentTotal()

Returns: An integer 0 or larger.

Returns the total number of science experiments aboard the vessel.

fc.ResetExperiment(double experimentId)

  • experimentId: An integer between 0 and fc.ExperimentTotal() - 1, inclusive.

Returns: 1 if the experiment was reset, 0 otherwise.

Resets the selected experiment. If the experiment has not been run, or it requires a scientist to clean it first, this function has no effect.

fc.ReviewExperiment(double experimentId)

  • experimentId: An integer between 0 and fc.ExperimentTotal() - 1, inclusive.

Returns: 1 if the experiment review dialog was launched, 0 otherwise.

Trigger the stock "Review Science" dialog for the given experiment.

If the experiment has not been run, or experimentId selects an invalid experiment, nothing happens.

fc.ReviewScienceContainer(double scienceContainerId)

  • scienceContainerId: An integer between [0, fc.ScienceContainerCount()).

Returns: 1 if the container review dialog was launched, 0 otherwise.

Trigger the stock "Review Science" dialog for the given container.

fc.RunAvailableExperiment(double scienceTypeId)

  • scienceTypeId: An integer in the range [0, fc.ScienceTypeTotal()).

Returns: 1 if an experiment was run, 0 otherwise.

Run the first available experiment of the type selected by scienceTypeId. If no experiments are available, then nothing happens.

fc.RunExperiment(double experimentId)

  • experimentId: An integer between 0 and fc.ExperimentTotal() - 1, inclusive.

Returns: 1 if the experiment was run, 0 if it was not.

Run the selected experiment.

If the experiment has already been run, this function has no effect.

Note that the science dialog is displayed after running an experiment.

fc.ScienceContainerCapacity(double scienceContainerId)

  • scienceContainerId: An integer between [0, fc.ScienceContainerCount()).

Returns: The storage capacity, or 0.

Returns the number of experiments that may be stored in the container, or 0 if an invalid ID is provided.

A capacity of 0 indicates unlimited storage capacity.

fc.ScienceContainerCount()

Returns: The number of science containers.

Returns the number of science containers (ModuleScienceContainer) on the vessel.

fc.ScienceContainerDataCount(double scienceContainerId)

  • scienceContainerId: An integer between [0, fc.ScienceContainerCount()).

Returns: The number of stored experiments, or 0.

Returns the number of experiments stored in the container, or 0 if an invalid ID is provided.

fc.ScienceContainerDataSize(double scienceContainerId)

  • scienceContainerId: An integer between [0, fc.ScienceContainerCount()).

Returns: The data size of all experiments stored in the container, in Mits, or 0.

Returns the size of all the data stored in the science container.

If scienceContainerId is an invalid science container id, or there is no data in the container, it returns 0.

fc.ScienceContainerName(double scienceContainerId)

  • scienceContainerId: An integer between [0, fc.ScienceContainerCount()).

Returns: The part name, or an empty string.

Returns the name of the part that the container is installed on, or an empty string if an invalid ID is provided.

fc.ScienceType(double scienceTypeId)

  • scienceTypeId: An integer between 0 and fc.ScienceTypeTotal() - 1.

Returns: The name of the experiment type, or an empty string.

Returns the type of experiment recorded as category scienceTypeId.

Returns an empty string if scienceTypeId does not refer to a valid category.

fc.ScienceTypeId(string scienceTypeName)

  • scienceTypeName: The id of the science.

Returns: An integer in the range [0, fc.ScienceTypeTotal()), or -1.

Returns a number usable as the scienceTypeId parameter in science functions based on the scienceTypeName parameter. If an invalid name is supplied, or there are no experiments of the named type, returns -1.

Note that scienceTypeName is the "id" field for the corresponding EXPERIMENT_DEFINITION from ScienceDefs.cfg (or another science definition config file).

fc.ScienceTypeTotal()

Returns: An integer 0 or larger.

Returns the total number of categories of science experiments aboard the vessel.

fc.ScienceDataTotal()

Returns: Total science data, in Mits.

Returns the total science data stored on the vessel, in Mits.

fc.TransmitScienceContainer(double transmitterId, double scienceContainerId)

  • transmitterId: An integer in the range [0, fc.DataTransmitterCount()).
  • scienceContainerId: An integer between [0, fc.ScienceContainerCount()).

Returns: 1 if the container's data was sent, 0 if it could not be sent or an invalid ID was provided.

Transmit all of the contents of the selected science container using the transmitter identified by transitterId.

Does nothing if there is no data in the container, or if an invalid or busy transmitter is selected.

fc.TransmitExperiment(double transmitterId, double experimentId)

  • transmitterId: An integer in the range [0, fc.DataTransmitterCount()).
  • experimentId: An integer between 0 and fc.ExperimentTotal() - 1, inclusive.

Returns: 1 if the experiment was sent, 0 if it could not be sent or an invalid ID was provided.

Transmit the experiment selected by experimentId using the transmitter transmitterId.

Does nothing if there is no data in the experiment, or if an invalid or busy transmitter is selected.


Speed, Velocity, and Acceleration Category

Variables related to the vessels speed, velocity, and accelerations are grouped in this category.

fc.AccelEngines()

Returns: Engine acceleration in m/s^2.

Returns the current acceleration of the vessel from engines, in m/s^2.

fc.Acceleration()

Returns: Net acceleration in m/s^2.

Returns the net acceleration on the vessel from all forces in m/s^2.

fc.AccelForward()

Returns: Forward acceleration in m/s^2.

Returns the forward (towards the vessel nose) component of the net acceleration on the vessel in m/s^2. Negative values represent a rearward acceleration.

fc.AccelRight()

Returns: Right acceleration in m/s^2.

Returns the rightward component of the net acceleration on the vessel in m/s^2. Negative values represent a leftward acceleration.

fc.AccelSurfaceForward()

Returns: Surface forward acceleration in m/s^2.

Returns the surface forward-relative component of the net acceleration on the vessel in m/s^2.

fc.AccelSurfacePrograde()

Returns: Surface prograde acceleration in m/s^2.

Returns the surface prograde-relative component of the net acceleration on the vessel in m/s^2.

fc.AccelSurfaceRight()

Returns: Surface right acceleration in m/s^2.

Returns the surface right-relative component of the net acceleration on the vessel in m/s^2.

fc.AccelTop()

Returns: Top acceleration in m/s^2.

Returns the top (towards the 'top' of an aircraft, or the typical 'up' direction of kerbals in pods) component of the net acceleration on the vessel in m/s^2. Negative values represent a vessel-downward acceleration.

fc.AccelUp()

Returns: Top acceleration in m/s^2.

Returns the surface-relative up component of the net acceleration on the vessel in m/s^2. Negative values represent acceleration towards the surface.

fc.AltitudeTerrainRate()

Returns: Rate of change of terrain altitude in m/s.

Returns the rate at which the vessel's distance to the ground is changing. This is the vertical speed as measured from vessel to surface, as opposed to measuring from a fixed altitude. When over an ocean, sea level is used as the ground height (in other words, fc.AltitudeTerrain(false)).

Because terrain may be rough, this value may be noisy. It is smoothed using exponential smoothing, so the rate is not instantaneously precise.

fc.ApproachSpeed()

Returns: Approach speed in m/s. Returns 0 if there is no target.

Returns the approach speed (the rate of closure directly towards the target). Returns 0 if there's no target or all relative movement is perpendicular to the approach direction.

fc.CurrentSpeedModeSpeed()

Returns: Current speed in m/s.

Returns the speed selected by the speed mode (surface, orbit, or target) in m/s. This value is equivalent to the speed displayed over the NavBall in the UI.

fc.EquivalentAirspeed()

Returns: EAS in m/s.

Compute equivalent airspeed based on current surface speed and atmospheric density.

https://en.wikipedia.org/wiki/Equivalent_airspeed

fc.GForce()

Returns: Current instantaneous force in Gs.

Returns the magnitude of g-forces currently affecting the craft, in gees.

fc.GForceVertical()

Returns: The number of Gs towards the head or feet of the crew.

Returns the magnitude of g-forces perpendicular to the front of the craft aligned with the normal seating configuration of the crew. For aircraft and most spacecraft, positive values indicates forces towards the feet of the crew, while negative values indicate forces towards the heads of the crew.

Excessive positive values could cause blackouts, while excessive negative values may cause redouts.

fc.HorizontalSpeed()

Returns: Horizontal surface speed in m/s.

Measure of the surface speed of the vessel after removing the vertical component, in m/s.

fc.IndicatedAirspeed()

Returns: IAS in m/s.

Returns the indicated airspeed in m/s, based on current surface speed, atmospheric density, and Mach number.

fc.MachNumber()

Returns: Vessel speed as a factor of the speed of sound.

Returns the vessel's current Mach number (multiple of the speed of sound). This number only makes sense in an atmosphere.

fc.OrbitSpeed()

Returns: Orbital speed in m/s.

Return the orbital speed of the vessel in m/s

fc.SpeedDisplayMode()

Returns: 1 for "Orbit" mode, 0 for "Surface" mode, and -1 for "Target" mode.

Returns +1 if the KSP automatic speed display is set to "Orbit", +0 if it's "Surface", and -1 if it's "Target". This mode affects SAS behaviors, so it's useful to know.

fc.SurfaceForwardSpeed()

Returns: The vessel's velocity fore/aft velocity in m/s.

Returns the component of surface velocity relative to the nose of the craft, in m/s. If the vessel is near vertical, the 'forward' vector is treated as the vector that faces 'down' in a horizontal cockpit configuration.

fc.SurfaceLateralSpeed()

Returns: The vessel's left/right velocity in m/s. Right is positive; left is negative.

Returns the lateral (right/left) component of surface velocity in m/s. This value could become zero at extreme roll orientations. Positive values are to the right, negative to the left.

fc.SurfaceSpeed()

Returns: Surface speed in m/s.

Return the surface-relative speed of the vessel in m/s.

fc.TargetSpeed()

Returns: Speed relative to the target in m/s. 0 if there is no target.

Target-relative speed in m/s. 0 if no target.

fc.VerticalSpeed()

Returns: Surface-relative vertical speed in m/s.

Returns the vertical speed of the vessel in m/s.


Staging Category

Controls for staging a vessel, and controlling the stage lock, and information related to both staging and stage locks are all in the Staging category. Launch clamp info is also grouped under Staging.

fc.CurrentStage()

Returns: A whole number 0 or larger.

Returns the current stage. Before launch or after undocking, this number may be larger than the total number of stages on the vessel.

fc.GetLaunchClampCount()

Returns: A whole number 0 or larger.

Returns the number of launch clamps currently attached to the vessel.

fc.GetStageLocked()

Returns: 1 if staging is locked, 0 if staging is unlocked.

Returns 1 if staging is locked, 0 otherwise.

fc.ReleaseLaunchClamps()

Returns: 1 if any launch clamps released, 0 otherwise.

Release all launch clamps holding the vessel.

fc.SetStageLocked(bool locked)

  • locked: true to lock staging, false to unlock staging.

Returns: 1 if staging is locked, 0 otherwise.

Sets stage locking to the specified setting (true or false).

fc.Stage()

Returns: 1 if the vessel staged; 0 otherwise.

Activate the next stage.

fc.StageReady()

Returns: 1 if the vessel can stage, and staging is unlocked; 0 otherwise.

Can the vessel stage?

fc.StageValid()

Returns: 1 if CurrentStage refers to a stage on the vessel, 0 if it does not.

The staging manager sets the 'current stage' to 1 greater than the number of stages on the vessel when a new vessel spawns (either at the launch pad, or after undocking). Doing so allows the vessel to sit on the launch pad without the last stage firing.

However, since the same thing happens after undocking, it is possible that the vessel's staging system is off-by-one, meaning that an engine on the last stage won't be available without staging, first.

This function returns 1 if the staging manager Current Stage is the same as the vessel's Last Stage, meaning that fc.CurrentStage() shows a valid stage on the vessel. It returns 0 prior to launch, or immediately after undocking, when the current stage is larger than the number of stages on the vessel.

fc.ToggleStageLocked()

Returns: 1 if staging is now locked; 0 if staging is now unlocked.

Toggle the stage lock on or off. Returns the new state.


Survival Category

Information related to the survivability of the current pod are grouped in the Survival category.

fc.MaxImpactSpeed()

Returns: Max impact speed of the command pod, in m/s.

Reports the maximum impact speed of the current part, in meters per second.

fc.SuicideBurnTime()

Returns: Time in seconds until the burn must start, or 0.

Supported Mod(s): MechJeb, Kerbal Engineer Redux

Returns the time (in seconds) until a suicide burn (maximum thrust burn) must start to avoid lithobraking. If the orbit does not impact the surface, or it is too late to avoid impact, returns 0.

If Kerbal Engineer Redux is installed, MAS will use the KER prediction of time-of-impact. If KER is not installed, MAS uses its own estimate of time-to-impact.


Target and Rendezvous Category

The Target and Rendezvous section provides functions and methods related to targets and rendezvous operations with a target. These methods include raw distance and velocities as well as target name and classifiers (is it a vessel, a celestial body, etc).

fc.ClearTarget()

Returns: 1 if the target was cleared, 0 otherwise.

Clears any targets being tracked.

fc.ClearTargetFilter(double vesselType)

  • vesselType: An integer value between 1 and 13, inclusive.

Returns: 1 if the vesselType was cleared, 0 if it was not.

Removes the specified vesselType from the target tracking filter. vesselType must be one of:

  • 1 - Ship
  • 2 - Plane
  • 3 - Probe
  • 4 - Lander
  • 5 - Station
  • 6 - Relay
  • 7 - Rover
  • 8 - Base
  • 9 - EVA
  • 10 - Flag
  • 11 - Debris
  • 12 - Space Object
  • 13 - Unknown

Returns 1 if the provided vesselType was previously set, or 0 if it was not set or an invalid vesselType was supplied.

fc.GetTargetFilter(double vesselType)

  • vesselType: An integer value between 1 and 13, inclusive.

Returns: 1 if the vesselType was cleared, 0 if it was not.

Indicates whether the specified vesselType is set in the target selection filter. vesselType must be one of:

  • 1 - Ship
  • 2 - Plane
  • 3 - Probe
  • 4 - Lander
  • 5 - Station
  • 6 - Relay
  • 7 - Rover
  • 8 - Base
  • 9 - EVA
  • 10 - Flag
  • 11 - Debris
  • 12 - Space Object
  • 13 - Unknown

Returns 1 if the provided vesselType is a target that will be selected, or 0 if it will not be selected or an invalid vesselType was supplied.

fc.SetTargetFilter(double vesselType)

  • vesselType: An integer value between 1 and 13, inclusive.

Returns: 1 if the vesselType was set, 0 if it was not.

Adds the specified vesselType to the target tracking filter. vesselType must be one of:

  • 1 - Ship
  • 2 - Plane
  • 3 - Probe
  • 4 - Lander
  • 5 - Station
  • 6 - Relay
  • 7 - Rover
  • 8 - Base
  • 9 - EVA
  • 10 - Flag
  • 11 - Debris
  • 12 - Space Object
  • 13 - Unknown

Returns 1 if the provided vesselType was not previously set, or 0 if it was already set or an invalid vesselType was supplied.

fc.SetTargetVessel(double id)

  • id: The id of the vessel to target.

Returns: 1 if the target was successfully set, 0 otherwise.

Set the active target to the vessel selected by id. If the id is invalid, the current target is cleared. The id parameter must be greater than or equal to 0, and less than fc.TargetVesselCount() to be valid.

fc.TargetAltitude()

Returns: Target altitude in meters.

Returns the altitude of the target, or 0 if there is no target.

fc.TargetAngle()

Returns: Returns 0 if the target is directly in front of the vessel, or if there is no target; returns a number up to 180 in all other cases. Value is in degrees.

Returns the raw angle between the target and the nose of the vessel, or 0 if there is no target.

fc.TargetAxialAngle()

Returns: Axial angle in degrees, or 0 if there is no target.

Returns the geometric angle of the target's position when projected onto the vessel's X/Y plane.

Combined with fc.TargetAxialDistance(), this angle can be used to determine where the target is relative to the vessel's nose. The angle and distance can also be used to compute fc.TargetDistanceX() and fc.TargetDistanceY().

An angle of 0 indicates the target lies directly along the +X axis. An angle of 90 indicates it lies on the +Y axis.

fc.TargetAxialDistance()

Returns: Axial displacement in meters, or 0 if there is no target.

Returns the axial displacement of the target relative to the nose of the vessel.

The axial displacement indicates how far away the target is from a line extending directly from the front of the vessel (or from the current reference part / docking port).

fc.TargetAxialVelocity()

Returns: Axial velocity in m/s, or 0 if there is no target.

Returns the relative axial velocity of the target relative to the nose of the vessel.

fc.TargetApoapsis()

Returns: Target's Ap in meters, or 0 if there is no target.

Returns the target's apoapsis.

fc.TargetBodyName()

Returns the name of the body that the target orbits, or an empty string if there is no target.

fc.TargetClosestApproachDistance()

Returns: Closest approach distance in meters, or 0 if there is no target.

Returns the distance of the closest approach to the target during the next orbit. If the target is a celestial body, the closest approach distance reports the predicted periapsis, with a value of 0 indicating lithobraking (impact).

fc.TargetClosestApproachSpeed()

Returns: Speed at closest approach in m/s, or 0 if there is no target.

Returns the relative speed of the target at closest approach. If there is no target, returns 0.

fc.TargetClosestApproachTime()

Returns: Time to closest approach in seconds, or 0 if there is no target.

Returns the time until the closest approach to the target.

fc.TargetDistance()

Returns: Target distance in meters, or 0 if there is no target.

Returns the distance to the current target in meters, or 0 if there is no target.

fc.TargetDistanceX()

Returns: Distance in meters. Positive means the target is to the right, negative means to the left.

Returns the displacement between the target vessel and the reference transform on the horizontal (reference-transform relative) plane in meters, with target to the right = +X and left = -X.

fc.TargetDistanceY()

Returns: Distance in meters. Positive means the target is above the craft, negative means below.

Returns the displacement between the target vessel and the reference transform on the vertical (rt-relative) plane in meters, with target up = +Y and down = -Y.

fc.TargetDistanceZ()

Returns: Distance in meters. Positive indicates a target in front of the craft, negative indicates behind.

Returns the displacement between the target vessel and the reference transform on the Z (fore/aft) axis in meters, with target ahead = +Z and behind = -Z

fc.TargetEccentricity()

Returns: Returns the target orbit's eccentricity.

Returns the eccentricity of the target's orbit, or 0 if there is no target.

fc.TargetHeadingPrograde()

Returns: Heading, or 0.

Returns the heading of the target's prograde surface speed, or 0 if there is no target, or the target does not have a meaningful surface heading.

NOTE: At present, only vessel targets return valid headings. All others return 0.

fc.TargetInclination()

Returns: Target orbital inclination in degrees, or 0 if there is no target.

Returns the orbital inclination of the target, or 0 if there is no target.

fc.TargetIsVessel()

Returns: 1 for vessel or docking port targets, 0 otherwise.

Returns 1 if the target is a vessel (vessel or Docking Port); 0 otherwise.

fc.TargetLatLonValid()

Returns: 1 for vessel, docking port, or waypoint targets, 0 otherwise.

Returns whether the latitude / longitude of the target are currently valid.

fc.TargetLatitude()

Returns: Latitude in degrees. Positive values are north of the equator, and negative values are south.

Returns the target latitude for targets that have valid latitudes.

fc.TargetLongitude()

Returns: Longitude in degrees. Negative values are west of the prime meridian, and positive values are east of it.

Returns the target longitude for targets that have valid longitudes.

fc.TargetName()

Returns: The name of the current target, or "" if there is no target.

Get the name of the current target, or an empty string if there is no target.

fc.TargetNextMoon()

Returns: Returns 1 if a moon was targeted. 0 otherwise.

Sets the target to the next moon of the body that vessel currently orbits. If there are no moons orbiting the current body, nothing happens.

If the vessel is currently targeting anything other than a moon of the current body, that target is cleared and the first moon is selected, instead.

Moon order is based on the order that the moons appear in the CelestialBody's list of worlds.

If the vessel is currently orbiting the Sun, this method will target planets.

fc.TargetNextVessel()

Returns: 1 if a vessel was targeted, 0 otherwise.

Sets the target to the nearest vessel in same SoI as the current vessel.

If the vessel is alreadying targeting a vessel in the same SoI, the next closest one will be targeted, instead. If the current target is the closest vessel, the most distant one is selected.

fc.TargetOrbitPeriod()

Returns the orbital period, in seconds, of the current target. If there is no target, returns 0.

fc.TargetOrbitSpeed()

Returns: Current orbital speed of the target, or 0.

Returns the orbital speed of the current target, in m/s. If there is no target, returns 0.

fc.TargetPeriapsis()

Returns: Target's Pe in meters, or 0 if there is no target.

Returns the target's periapsis.

fc.TargetRelativeInclination()

Returns: Inclination in degrees. Returns 0 if there is no target, or the target orbits a different celestial body.

Returns the relative inclination between the vessel and the target.

fc.TargetSameSoI()

Returns: 1 if the target is in the same SoI; 0 if not, or if there is no target.

Returns 1 if there is a target, and it is in the same SoI as the vessel (for example: both orbiting Kerbin, or both orbiting the Mun, but not one orbiting Kerbin, and the other orbiting the Mun).

fc.TargetSituation()

Returns: A number between -1 and 7 (inclusive).

Returns the target's situation, based on the KSP variable:

  • -1 - INVALID (no target)
  • 0 - LANDED
  • 1 - SPLASHED
  • 2 - PRELAUNCH
  • 3 - FLYING
  • 4 - SUB_ORBITAL
  • 5 - ORBITING
  • 6 - ESCAPING
  • 7 - DOCKED

For some Celestial Body target types, the situation is always 5 (ORBITING).

fc.TargetSMA()

Returns: SMA in meters, or 0 if there is no target.

Returns the semi-major axis of the target's orbit.

fc.TargetTimeToAp()

Returns: Time to Ap in seconds, or 0 if there's no target.

Returns the time until the target's next apoapsis.

fc.TargetTimeToPe()

Returns: Time to Pe in seconds, or 0 if there's no target.

Returns the time until the target's next periapsis.

fc.TargetType()

Returns: A number between 0 and 5 (inclusive)

Returns a number identifying the target type. Valid results are:

  • 0: No target
  • 1: Target is a Vessel
  • 2: Target is a Docking Port
  • 3: Target is a Celestial Body
  • 4: Target is a Waypoint
  • 5: Target is an asteroid

fc.TargetTypeId()

Returns: A value between 1 and 13 inclusive for a vessel-type target, or 14 for a Celestial Body, or 0 for no target, or another target type.

Returns a number representing the target vessel type (eg, 1 = Ship, etc).

  • 0 - Invalid (not one of the below types)
  • 1 - Ship
  • 2 - Plane
  • 3 - Probe
  • 4 - Lander
  • 5 - Station
  • 6 - Relay
  • 7 - Rover
  • 8 - Base
  • 9 - EVA
  • 10 - Flag
  • 11 - Debris
  • 12 - Space Object
  • 13 - Unknown
  • 14 - Celestial Body

fc.TargetVelocityX()

Returns: Velocity in m/s. Positive means the vessel is moving 'right' relative to the target, and negative means 'left'.

Returns the target's velocity relative to the left-right axis of the vessel.

fc.TargetVelocityY()

Returns: Velocity in m/s. Positive means the vessel is moving 'up' relative to the target, negative means relative 'down'.

Returns the target's velocity relative to the top-bottom axis of the vessel (the top / bottom of the vessel from the typical inline IVA's perspective).

fc.TargetVelocityZ()

Returns: Velocity in m/s. Positive means approaching, negative means departing.

Returns the target's velocity relative to the forward-aft axis of the vessel (the nose of an aircraft, the 'top' of a vertically-launched craft).

fc.TargetVesselCount()

Returns: The number of other non-debris vessels, or 0 if there are none.

Returns the number of other non-debris vessels in the current SoI. This count includes landed vessels as well as vessels in flight, but it does not count the current vessel.

fc.TargetVesselDistance(double id)

  • id: The id number of the desired vessel.

Returns: Distance to the target in meters, or 0.

Returns the distance to the non-debris target selected by id. Distance is in meters. The id parameter must be between 0 and fc.TargetVesselCount() - 1.

fc.TargetVesselIndex()

Returns: An integer between 0 and fc.TargetVesselCount() - 1, or -1 if the none of the vessels is the current target.

Returns the index of the non-debris vessel that is currently targeted, between 0 and fc.TargetVesselCount() - 1. If none of those vessels are targeted, returns -1.

fc.TargetVesselName(double id)

  • id: The id number of the desired vessel.

Returns: The name of the selected vessel, or an empty string if no valid vessel was selected.

Returns the name of the non-debris vessel selected by id. The id parameter must be between 0 and fc.TargetVesselCount() - 1.

fc.TargetVesselType()

Returns: Name of the target vessel type, or an empty string if there is no target, or the target is not a vessel.

Returns the name of the target vessel type (eg, "Ship", "Plane", "Station", etc).

fc.ToggleTargetFilter(double vesselType)

  • vesselType: An integer value between 1 and 13, inclusive.

Returns: 1 if the vesselType was cleared, 0 if it was not.

Toggles the specified vesselType in the target tracking filter. vesselType must be one of:

  • 1 - Ship
  • 2 - Plane
  • 3 - Probe
  • 4 - Lander
  • 5 - Station
  • 6 - Relay
  • 7 - Rover
  • 8 - Base
  • 9 - EVA
  • 10 - Flag
  • 11 - Debris
  • 12 - Space Object
  • 13 - Unknown

Returns 1 if the provided vesselType was previously set, or 0 if it was not set or an invalid vesselType was supplied.


Thermal Category

The Thermal section contains temperature monitoring values.

fc.AmbientTemperature(bool useKelvin)

  • useKelvin: If true, the temperature is returned in Kelvin; if false, the temperature is in Celsius.

Returns: Ambient temperature in Kelvin or Celsius.

Returns the static temperature of the atmosphere (or vacuum of space) outside the craft.

Static temperature does not account for compression heating caused by the vessel's passage through an atmosphere.

fc.ExternalTemperature(bool useKelvin)

  • useKelvin: If true, the temperature is returned in Kelvin; if false, the temperature is in Celsius.

Returns: External temperature in Kelvin or Celsius.

Returns the current actual temperature outside the vessel.

In an atmosphere at high speeds, this temperature represents the compression heating as the vessel travels through the atmosphere. In a vacuum, this temperature is identical to fc.AmbientTemperature(useKelvin).

fc.HottestEngineTemperatureSign()

Returns: -1 if the temperature is cooling, +1 if it is increasing, +0 if it is stable or no heat shields are installed.

Returns the direction of temperature change of the hottest engine.

fc.HottestEngineTemperature(bool useKelvin)

  • useKelvin: If true, the temperature is returned in Kelvin; if false, the temperature is in Celsius.

Returns: Current temperature of the hottest engine in Kelvin or Celsius.

Returns the current temperature of the hottest engine, where hottest engine is defined as "closest to its maximum temperature".

fc.HottestEngineMaxTemperature(bool useKelvin)

  • useKelvin: If true, the temperature is returned in Kelvin; if false, the temperature is in Celsius.

Returns: Current temperature of the hottest engine in Kelvin or Celsius.

Returns the maximum temperature of the hottest engine, where hottest engine is defined as "closest to its maximum temperature".

fc.HeatShieldMaxTemperature(bool useKelvin)

  • useKelvin: If true, the temperature is returned in Kelvin; if false, the temperature is in Celsius.

Returns: Heat shield maximum temperature in Kelvin or Celsius, or 0 if no heatshields are installed.

Returns the maximum temperature of the hottest heat shield.

fc.HeatShieldTemperature(bool useKelvin)

  • useKelvin: If true, the temperature is returned in Kelvin; if false, the temperature is in Celsius.

Returns: Heat shield temperature in Kelvin or Celsius, or 0 if no heatshields are installed.

Returns the current temperature of the hottest heat shield.

fc.HeatShieldTemperatureSign()

Returns: -1 if the temperature is cooling, +1 if it is increasing, +0 if it is stable or no heat shields are installed.

Returns the direction of temperature change of the hottest heat shield.

fc.HottestPartMaxTemperature(bool useKelvin)

  • useKelvin: When true, returns the temperature in units of Kelvin; when false, Celsius is used.

Returns: The current hottest part's maximum temperature, in degrees Celsius or Kelvin.

Returns the maximum temperature of the current hottest part.

fc.HottestPartSign()

Returns: -1 if the temperature is cooling, +1 if it is increasing, +0 if it is stable.

Returns the direction of temperature change of the hottest part.

fc.HottestPartTemperature(bool useKelvin)

  • useKelvin: When true, returns the temperature in units of Kelvin; when false, Celsius is used.

Returns: The current hottest part's temperature, in degrees Celsius or Kelvin.

Returns the hottest part on the vessel (the part closest to its thermal limit).

fc.InternalMaxTemperature(bool useKelvin)

  • useKelvin: If true, the temperature is returned in Kelvin; if false, the temperature is in Celsius.

Returns: Maximum temperature of the interior of the current IVA pod in Kelvin or Celsius.

Returns the maximum interior temperature of the current IVA pod.

fc.InternalTemperature(bool useKelvin)

  • useKelvin: If true, the temperature is returned in Kelvin; if false, the temperature is in Celsius.

Returns: Current temperature of the interior of the current IVA pod in Kelvin or Celsius.

Returns the interior temperature of the current IVA pod.

fc.InternalTemperatureSign()

Returns: -1 if the temperature is cooling, +1 if it is increasing, +0 if it is stable.

Returns the direction of the temperature change in the pod interior.

fc.PodMaxTemperature(bool useKelvin)

  • useKelvin: If true, the temperature is returned in Kelvin; if false, the temperature is in Celsius.

Returns: Maximum temperature of the skin of the current IVA pod in Kelvin or Celsius.

Returns the maximum skin temperature of the current IVA pod.

fc.PodTemperature(bool useKelvin)

  • useKelvin: If true, the temperature is returned in Kelvin; if false, the temperature is in Celsius.

Returns: Current temperature of the skin of the current IVA pod in Kelvin or Celsius.

Returns the skin temperature of the current IVA pod.

fc.PodTemperatureSign()

Returns: -1 if the temperature is cooling, +1 if it is increasing, +0 if it is stable.

Returns the direction of the temperature change on the pod skin.

fc.RadiatorActive()

Returns: 1 if any radiators are active, or 0 if no radiators are active or no radiators are installed.

Returns 1 if there is at least one radiator active on the vessel.

fc.RadiatorCount()

Returns the number of radiators installed on the craft, regardless of their status (enabled / disabled / damaged).

fc.RadiatorDamaged()

Returns 1 if any deployable radiators are damaged.

fc.RadiatorDeployable()

Returns: 1 if any radiators may be deployed, or 0 if no radiators may be deployed or no radiators are installed.

Returns 1 if at least one radiator may be deployed.

fc.RadiatorInactive()

Returns: 1 if any radiators are inactive, or 0 if no radiators are inactive or no radiators are installed.

Returns 1 if there is at least one radiator inactive on the vessel.

fc.RadiatorMoving()

Returns: -1, 0, or +1.

Returns -1 if a deployable radiator is retracting, +1 if a deployable radiator is extending, or 0 if no deployable radiators are moving.

fc.RadiatorPosition()

Returns: A number between 0 and 1 as described in the summary.

Returns a number representing the average position of undamaged deployable radiators.

  • 0 - No radiators, no undamaged radiators, or all undamaged radiators are retracted.
  • 1 - All deployable radiators extended.

If the radiators are moving, a number between 0 and 1 is returned.

fc.RadiatorRetractable()

Returns: 1 if a deployable radiator may be retracted, or 0 if none may be retracted or no deployable radiators are installed.

Returns 1 if at least one radiator on the vessel may be retracted or undeployed.

fc.RadiatorUtilization()

Returns: Current utilization, in the range of 0 to 1. If no active radiators are installed, or none are active, returns 0.

Returns current radiator utilization as a percentage of maximum of active radiators.

fc.SetRadiator(bool deploy)

  • deploy: 'true' to deploy radiators, 'false' to undeploy radiators.

Returns: 1 if any radiators are now deploying or retracting.

Deploys deployable radiators, or retracts retractable radiators.

fc.SkinTemperature(bool useKelvin)

  • useKelvin: If true, the temperature is returned in Kelvin; if false, the temperature is in Celsius.

Returns: Current temperature of the interior of the current IVA pod in Kelvin or Celsius.

Returns the skin temperature of the current IVA pod.

fc.ToggleRadiator()

Returns: 1 if any deployable radiators are installed. 0 otherwise.

Deploys deployable radiators, or retracts retractable radiators.


Time Category

The Time section provides access to the various timers in MAS (and KSP).

fc.HourOfDay(double time)

  • time: Time in seconds (eg, fc.UT()).

Returns: The hour of the day, accounting for Kerbin time vs. Earth time.

Returns the hour of the day (0-5.999... using the Kerbin clock, 0-23.999... using the Earth clock). Fraction of the hour is retained.

fc.MET()

Returns: Mission time, in seconds.

Fetch the current MET (Mission Elapsed Time) for the vessel in seconds.

fc.MinutesOfHour(double time)

  • time: Time in seconds (eg, fc.MET()).

Returns: A number representing the minutes in the hour in the range [0, 60).

Given a standard time in seconds, return the minutes of the hour (a number from 0 to 60). Fractions of a minute are retained and negative values are converted to positive.

fc.SecondsOfMinute(double time)

  • time: Time in seconds (eg, fc.MET()).

Returns: A number representing the seconds in the minute in the range [0, 60).

Given a standard time in seconds, return the seconds of the minute (the number from 0 to 60). Fractions of a second are retained and negative values are converted to positive.

fc.TimeOfDay(double time)

Returns: Number of seconds since the latest day began.

Similar to fc.HourOfDay(), but returning the answer in seconds instead of hours.

When used with fc.UT(), for instance, it returns the number of seconds since midnight UT.

fc.TimeToAltitude(double altitude)

  • altitude: Altitude above the datum, in meters.

Returns: Time in seconds until the altitude is crossed, or 0 if the orbit does not cross that altitude.

Given an altitude in meters, return the number of seconds until the vessel next crosses that altitude. If the vessel is on a hyperbolic orbit, or if the orbit never crosses the given altitude, return 0.0.

fc.TimeToANEq()

Returns: Time to AN, seconds, or 0 if the orbit is hyperbolic.

For non-hyperbolic orbits, returns time to the next equatorial Ascending Node.

fc.TimeToANTarget()

Returns: Time in seconds to the next ascending node, in seconds, or 0.

Returns the time until the next ascending node with the current target, provided the target is orbiting the same body as the vessel (and the target exists).

fc.TimeToAp()

Returns: Time until Ap in seconds, or 0 if the time would be invalid.

Fetch the time to the next apoapsis. If the orbit is hyperbolic, or the vessel is not flying, return 0.

fc.TimeToAtmosphere()

Returns: Time until the atmosphere boundary is crossed, in seconds; 0 for invalid times.

Fetch the time until the vessel's orbit next enters or exits the body's atmosphere. If there is no atmosphere, or the orbit does not cross that threshold, return 0.

fc.TimeToDNEq()

Returns: Time in seconds to the next descending node, or 0 if the orbit is hyperbolic.

Returns the time to the equatorial descending node, in seconds.

fc.TimeToDNTarget()

Returns: Time in seconds to the next descending node, in seconds, or 0.

Returns the time until the next descending node with the current target, provided the target is orbiting the same body as the vessel (and the target exists).

fc.TimeToLanding()

Returns: Time in seconds until landing; 0 for invalid times.

Alias for fc.LandingTime()

fc.TimeToPe()

Returns: Time until the next Pe in seconds, or 0 if the time would be invalid. May return a negative number in hyperbolic orbits.

Fetch the time to the next periapsis. If the vessel is not flying, the value will be zero. If the vessel is on a hyperbolic orbit, and it has passed the periapsis already, the value will be negative.

fc.TimeToSoI()

Returns: Time until transition in seconds; 0 if the orbit does not cross a Sphere of Influence.

Returns the number of seconds until the vessel's orbit transitions to another sphere of influence (leaving the current one and entering another).

fc.UT()

Returns: Universal Time, in seconds.

Fetch the current UT (universal time) in seconds.

fc.WarpRate()

Returns: 1 for normal speed, larger values for various warps.

Returns the current time warp multiplier.


Trim Category

The Trim section provides control over aircraft trim settings.

fc.GetPitchTrim()

Returns: Current pitch trim, in the range [-1, 1].

Returns the current pitch trim.

fc.GetRollTrim()

Returns: Current roll trim, in the range [-1, 1].

Returns the current roll trim.

fc.GetYawTrim()

Returns: Current yaw trim, in the range [-1, 1].

Returns the current yaw trim.

fc.SetPitchTrim(double pitchTrim)

  • pitchTrim: The new pitch trim, in the range [-1, 1]

Returns: Updated pitch trim, in the range [-1, 1].

Returns the current pitch trim.

fc.SetRollTrim(double rollTrim)

  • rollTrim: The new roll trim, in the range [-1, 1]

Returns: Updated roll trim, in the range [-1, 1].

Returns the current roll trim.

fc.SetYawTrim(double yawTrim)

  • yawTrim: The new yaw trim, in the range [-1, 1]

Returns: Updated yaw trim, in the range [-1, 1].

Returns the current yaw trim.

fc.SetTrim(double yawTrim, double pitchTrim, double rollTrim)

  • yawTrim: The new yaw trim, in the range [-1, 1]
  • pitchTrim: The new pitch trim, in the range [-1, 1]
  • rollTrim: The new roll trim, in the range [-1, 1]

Returns: Always returns 1.

Update all trim settings at once.


Unassigned Region Category

Variables that have not been assigned to a different category are dumped in this region until I figured out where to put them.

fc.BoolToNumber(bool condition)

  • condition: The condition to test

Returns: 1 if condition is true, 0 if it is false.

Returns 1 if condition is true, 0 if it is false.

fc.Remap(double value, double bound1, double bound2, double map1, double map2)

  • value: An input number
  • bound1: One of the two bounds of the source range.
  • bound2: The other bound of the source range.
  • map1: The first value of the destination range.
  • map2: The second value of the destination range.

Remaps value from the range [bound1, bound2] to the range [map1, map2].

The order of the bound and map parameters will be interpreted correctly. For instance, fc.Remap(var, 1, 0, 0, 1) will have the same effect as 1 - var.

fc.Select(bool condition, object trueValue, object falseValue)

  • condition: The condition that selects the value.
  • trueValue: The value returned when condition is true.
  • falseValue: The value returned when condition is false.

Returns: One of trueValue or falseValue.

Returns trueValue when condition is true, otherwise returns falseValue.

trueValue and falseValue may be numbers or strings. They do not have to be the same type.

condition may be either a boolean value or a number. If it a a number, then trueValue is returned if condition is greater than zero. falseValue is returned if condition is equal to or less than zero.

fc.Select(double condition, object negativeValue, object zeroValue, object positiveValue)

  • condition: A numeric value that selects the response.
  • negativeValue: The value returned when condition is less than zero.
  • zeroValue: The value returned when condition is exactly zero.
  • positiveValue: The value returned when condition is greater than zero.

Returns: One of negativeValue, zeroValue, or positiveValue.

Select one of three values, depending on the value of condition.

If condition is less than zero, negativeValue is returned. If condition is exactly zero, zeroValue is returned. If condition is positive, positiveValue is returned.

negativeValue, zeroValue, and positiveValue may be numbers or strings. They do not have to be all numbers or all strings.

Remember that numeric precision may may it difficult for equations to return exactly zero.

fc.SendSoftkey(string monitorName, double softkeyNumber)

  • monitorName: The name of the monitor.
  • softkeyNumber: The softkey code to send.

Returns: 1 if the code was processed, 0 otherwise.

Send a softkey event to the named monitor. A softkey is a numeric integer code that may be interpreted by the active page on that monitor, or it may be forwarded to the components of that page (such as an RPM_MODULE node).


Vessel Info Category

The Vessel Info group contains non-flight information about the vessel (such as vessel name, type, etc.).

fc.VesselDescription()

Returns: The (possibly multi-line) vessel description, or an empty string if no description was provided.

Returns the text entered into the vessel description in the Editor.

Line breaks are preserved, so this text may display as multiple lines. Any Action Group Memos (lines that begin with "AG") are removed.

fc.VesselName()

Returns the name of the vessel.

fc.VesselType()

Returns a string naming the type of vessel.

fc.VesselTypeId()

Returns: A value between 1 and 13 inclusive for a vessel, or 14 for a Celestial Body, or 0 another target type.

Returns a number representing the vessel type (eg, 1 = Ship, etc).

  • 0 - Invalid (not one of the below types)
  • 1 - Ship
  • 2 - Plane
  • 3 - Probe
  • 4 - Lander
  • 5 - Station
  • 6 - Relay
  • 7 - Rover
  • 8 - Base
  • 9 - EVA
  • 10 - Flag
  • 11 - Debris
  • 12 - Space Object
  • 13 - Unknown
  • 14 - Celestial Body

This documentation was automatically generated from source code at 13:21 UTC on 23/Aug/2020.