Skip to content

MASFlightComputerProxy2

MOARdV edited this page Jun 13, 2018 · 58 revisions

MASFlightComputerProxy2.cs

Contents

The fc group contains the core interface between KSP, Avionics Systems, and props in an IVA. It consists of many 'variable' 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: If a variable listed below includes an entry for 'Required Mod(s)', then the mod listed (or any of the mods, if more than one) must be installed for that particular feature to work.


Maneuver Node Category

Methods for querying and controlling maneuver nodes are in this category.

fc.AddManeuverNode(double progradedV, double normaldV, double radialdV, double timeUT)

  • progradedV: ΔV in the prograde direction at the time of the maneuver, in m/s.
  • normaldV: ΔV in the normal direction at the time of the maneuver, in m/s.
  • radialdV: ΔV in the radial direction at the time of the maneuver, in m/s.
  • timeUT: UT to schedule the maneuver, in seconds.

Returns: 1 if the manuever node was created, 0 on any errors.

Replace any scheduled maneuver nodes with this maneuver node.

fc.ClearManeuverNode()

Returns: 1 if any nodes were cleared, 0 if no nodes were cleared.

Clear all scheduled maneuver nodes.

fc.ManeuverNodeAp()

Returns: New Ap in meters, or 0 if no node is scheduled.

Returns the apoapsis of the orbit that results from the scheduled maneuver.

fc.ManeuverNodeBurnTime()

Returns: Approximate burn time in seconds, or 0 if no node is scheduled.

Returns an estimate of the maneuver node burn time, in seconds.

fc.ManeuverNodeDV()

Returns: ΔV in m/s, or 0 if no node is scheduled.

Delta-V of the next scheduled node.

fc.ManeuverNodeDVNormal()

Returns: ΔV in m/s; negative values indicate anti-normal.

The normal component of the next scheduled maneuver.

fc.ManeuverNodeDVPrograde()

Returns: ΔV in m/s; negative values indicate retrograde.

The prograde component of the next scheduled maneuver.

fc.ManeuverNodeDVRadial()

Returns: ΔV in m/s; negative values indicate anti-radial.

The radial component of the next scheduled maneuver.

fc.ManeuverNodeEcc()

Returns: New eccentricity, or 0 if no node is scheduled.

Returns the eccentricity of the orbit that results from the scheduled maneuver.

fc.ManeuverNodeExists()

Returns 1 if there is a valid maneuver node; 0 otherwise

fc.ManeuverNodeInc()

Returns: New inclination in degrees, or 0 if no node is scheduled.

Returns the inclination of the orbit that results from the scheduled maneuver.

fc.ManeuverNodeNextBody()

Returns the index to the body that the vessel will encounter after a change in SoI caused by a scheduled maneuver node. If there is no maneuver node, or the vessel does not change SoI because of the maneuver, returns -1 (current body).

fc.ManeuverNodeNextSoI()

Returns: 0 if the orbit does not transition. 1 if the vessel will encounter a body, -1 if the vessel will escape the current body.

Returns 1 if the SoI change after a scheduled maneuver is an 'encounter', -1 if it is an 'escape', and 0 if the scheduled orbit does not change SoI.

fc.ManeuverNodePe()

Returns: New Pe in meters, or 0 if no node is scheduled.

Returns the periapsis of the orbit that results from the scheduled maneuver.

fc.ManeuverNodeRelativeInclination()

Returns: New relative inclination in degrees, or 0 if there is no maneuver node, no target, or the target orbits a different body.

Returns the relative inclination of the target that will result from the scheduled maneuver.

fc.ManeuverNodeTargetClosestApproachDistance()

Returns: Closest approach to the target, or 0.

Closest approach to the target after the next maneuver completes, in meters. If there is no maneuver scheduled, or no target, returns 0.

fc.ManeuverNodeTargetClosestApproachSpeed()

Returns: Relative speed of the target at closest approach after the maneuver, m/s.

Relative speed of the target at closest approach after the scheduled maneuver, in m/s. If there is no maneuver scheduled, or no target, returns 0.

fc.ManeuverNodeTargetClosestApproachTime()

Returns: Time until closest approach after the maneuver.

Time when the closest approach with a target occurs after the scheduled maneuver, in seconds. If there is no maneuver scheduled, or no target, returns 0.

fc.ManeuverNodeTime()

Returns time in seconds until the maneuver node; 0 if no node is valid.

fc.ManeuverNodeTimeToNextSoI()

Returns: Time until the next SoI after the scheduled maneuver, or 0

Returns the time to the next SoI transition in the scheduled maneuver, in seconds. If the planned orbit does not change SoI, or no node is scheduled, returns 0.


Mass Category

Vessel mass may be queried with these methods.

fc.Mass(bool wetMass)

  • wetMass: wet mass if true, dry mass otherwise

Returns: Vessel mass in tonnes.

Returns the mass of the vessel in tonnes.


Math Category

Provides MAS-native methods for common math primitives. These methods generally duplicate the functions in the Lua math table, but by placing them in MAS, MAS can use native delegates instead of having to call into Lua (which is slower).

This region also contains other useful mathematical methods.

fc.Abs(double value)

Returns: The absolute value of value.

Returns the absolute value of value.

fc.Between(double value, double lowerBound, double upperBound)

  • value: The value to test.
  • lowerBound: The lower bound (inclusive) of the range to test.
  • upperBound: The upper bound (inclusive) of the range to test.

Returns: 1 if value is between lowerBound and upperBound, 0 otherwise.

Returns 1 if value is at least equal to lowerBound and not greater than upperBound. Returns 0 otherwise.

In other words,

  • If value >= lowerBound and value <= upperBound, return 1.
  • Otherwise, reutrn 0.

fc.Ceiling(double value)

  • value: The value to round

Rounds a number up to the next integer.

fc.Clamp(double value, double a, double b)

  • value: The value to clamp.
  • a: The first bound.
  • b: The second bound.

Returns: The clamped value.

Clamps value to stay within the range a to b, inclusive. a does not have to be less than b.

fc.Floor(double value)

  • value: The value to round

Rounds a number down to the next integer.

fc.Max(double a, double b)

  • a: The first value to test.
  • b: The second value to test.

Returns: a if a is larger than b; b otherwise.

Return the larger value

fc.Min(double a, double b)

  • a: The first value to test.
  • b: The second value to test.

Returns: a if a is smaller than b; b otherwise.

Return the smaller value

fc.NormalizeAngle(double angle)

  • angle: The de-normalized angle to correct.

Returns: A value between 0 (inclusive) and 360 (exclusive).

Normalizes an angle to the range [0, 360).

fc.NormalizeLongitude(double angle)

  • angle: The de-normalized angle to correct.

Returns: A value between -180 (inclusive) and +180 (exclusive).

Normalizes an angle to the range [-180, 180).

fc.NormalizePitch(double angle)

  • angle: The angle to convert

Returns: A value between -90 and +90, inclusive.

Converts an angle to a pitch value in the range of [-90, +90].

fc.PseudoLog10(double sourceValue)

  • sourceValue: An input number

Returns: A Log10-like representation of the input value.

Apply a log10-like curve to the value.

The exact formula is:

if (abs(sourceValue) < 1.0)
  return sourceValue;
else
  return (1 + Log10(abs(sourceValue))) * Sign(sourceValue);
end

fc.SafeDivide(double numerator, double denominator)

  • numerator: The numerator
  • denominator: The denominator

Returns: numerator / denominator, or 0 if the denominator is zero.

Divides numerator by denominator. If the denominator is zero, this method returns 0 instead of infinity or throwing a divide-by-zero exception.

fc.SafeModulo(double numerator, double denominator)

  • numerator: The numerator
  • denominator: The denominator

Returns: A value between 0 and denominator, or 0 if the denominator is zero.

Returns the remainder of numerator divided by denominator. If the denominator is zero, this method returns 0 instead of infinity or throwing a divide-by-zero exception.


Meta Category

Meta variables and functions are variables provide information about the game, as opposed to the vessel. They also include the fc.Conditioned() functions, which can provide some realism by disrupting lighting under low power or high G situations.

fc.AssemblyLoaded(string assemblyName)

Returns: 1 if the named assembly is loaded, 0 otherwise.

Checks for the existence of the named assembly (eg, fc.AssemblyLoaded("MechJeb2")). This can be used to determine if a particular mod has been installed when that mod is not directly supported by Avionics Systems.

fc.CancelTimeWarp(bool instantCancel)

  • instantCancel: If true, time warp is immediately set to x1. If false, time warp counts downward like in normal gameplay.

Returns: 1 if time warp was successfully adjusted, 0 if it could not be adjusted.

Cancel time warp.

fc.ColorTag(double red, double green, double blue)

  • red: Red channel value, [0, 255]
  • green: Green channel value, [0, 255]
  • blue: Blue channel value, [0, 255]

Converts the supplied RGB value into a MAS text color tag (eg, fc.HexColor(255, 255, 0) returns "[#ffff00]"). This value is slightly more efficient if you do not need to change the alpha channel.

All values are clamped to the range 0 to 255.

fc.ColorTag(double red, double green, double blue, double alpha)

  • red: Red channel value, [0, 255]
  • green: Green channel value, [0, 255]
  • blue: Blue channel value, [0, 255]
  • alpha: Alpha channel value, [0, 255]

Converts the supplied RGBA value into a MAS text color tag (eg, fc.HexColor(255, 255, 0, 255) returns "[#ffff00ff]").

All values are clamped to the range 0 to 255.

fc.Conditioned(object value)

  • value: A numeric value or a boolean

Returns: value if the conditions above are not met.

Applies some "realism" conditions to the variable to cause it to return zero under two general conditions:

  1. When there is no power available (the config-file-specified power variable is below 0.0001), or

  2. The craft is under high g-loading. G-loading limits are defined in the per-pod config file. When these limits are exceeded, there is a chance (also defined in the config file) of the variable being interrupted. This chance increases as the g-forces exceed the threshold using a square-root curve.

  3. The optional variable powerOnVariable in MASFlightComputer returns 0 or less.

The variable fc.Conditioned(1) behaves the same as the RasterPropMonitor ASET Props custom variable CUSTOM_ALCOR_POWEROFF, with an inverted value (CUSTOM_ALCOR_POWEROFF returns 1 to indicate "disrupt", but fc.Conditioned(1) returns 0 instead).

For boolean parameters, true is treated as 1, and false is treated as 0.

fc.SIFormatValue(double value, double totalLength, double minDecimal, string delimiter, bool forceSign, bool showPrefix)

  • value: The number to format.
  • totalLength: The total length of the string.
  • minDecimal: The minimum decimal precision of the string.
  • delimiter: A custom delimiter, or an empty string "" to indicate no delimiter
  • forceSign: Require a space for the sign, even if the value is positive
  • showPrefix: Whether the SI prefix should be appended to the string.

Returns: The formatted string.

Provides a custom SI formatter with more control than the basic SIP format.

NOT IMPLEMENTED: Custom delimiter.

fc.HoursPerDay()

Returns: 6 for Kerbin time, 24 for Earth time, or another value for modded installations.

Returns the number of hours per day on Kerbin. With a stock installation, this is 6 hours or 24 hours, depending on whether the Kerbin calendar or Earth calendar is selected. Mods may change this to a different value.

fc.KerbinTime()

Returns 1 if the KSP UI is configured for the Kerbin calendar (6 hour days); returns 0 for Earth days (24 hour).

fc.LogMessage(string message)

  • message: The string to write. Strings may be formatted using the Lua string library, or using the .. concatenation operator.

Log messages to the KSP.log. Messages will be prefixed with [MASFlightComputerProxy].

fc.MapIconU(double iconId)

  • iconId: The Icon Id - either fc.TargetTypeId() or one of the numbers listed in the description.

Returns: The U shift to select the icon from the '%MAP_ICON%' texture.

Returns the U texture shift required to display the map icon listed below. This function is intended to be used in conjunction with the '%MAP_ICON%' texture in MASMonitor IMAGE nodes.

  • 0 - Invalid (not one of the below types)
  • 1 - Ship target
  • 2 - Plane target
  • 3 - Probe target
  • 4 - Lander target
  • 5 - Station target
  • 6 - Relay target
  • 7 - Rover target
  • 8 - Base target
  • 9 - EVA target
  • 10 - Flag target
  • 11 - Debris target
  • 12 - Space Object target
  • 13 - Unknown target
  • 14 - Celestial Body (planet)
  • 15 - Ap Icon
  • 16 - Pe Icon
  • 17 - AN Icon
  • 18 - DN Icon
  • 19 - Maneuver Node Icon
  • 20 - Ship location at intercept
  • 21 - Target location at intercept
  • 22 - Enter an SoI
  • 23 - Exit an SoI
  • 24 - Point of Impact (?)

Note that entries 0 - 14 correspond to the results of fc.TargetTypeId().

fc.MapIconV(double iconId)

  • iconId: The Icon Id - either fc.TargetTypeId() or one of the numbers listed in the description.

Returns: The V shift to select the icon from the '%MAP_ICON%' texture.

Returns the V texture shift required to display the map icon listed below. This function is intended to be used in conjunction with the '%MAP_ICON%' texture in MASMonitor IMAGE nodes.

  • 0 - Invalid (not one of the below types)
  • 1 - Ship target
  • 2 - Plane target
  • 3 - Probe target
  • 4 - Lander target
  • 5 - Station target
  • 6 - Relay target
  • 7 - Rover target
  • 8 - Base target
  • 9 - EVA target
  • 10 - Flag target
  • 11 - Debris target
  • 12 - Space Object target
  • 13 - Unknown target
  • 14 - Celestial Body (planet)
  • 15 - Ap Icon
  • 16 - Pe Icon
  • 17 - AN Icon
  • 18 - DN Icon
  • 19 - Maneuver Node Icon
  • 20 - Ship location at intercept
  • 21 - Target location at intercept
  • 22 - Enter an SoI
  • 23 - Exit an SoI
  • 24 - Point of Impact (?)

Note that entries 0 - 14 correspond to the results of fc.TargetTypeId().

fc.MASVersion()

Returns: MAS Version in string format.

Returns the version number of the MAS plugin, as a string, such as 1.0.1.12331.

fc.NavballB(double iconId)

  • iconId: The icon as explained in the description.

Returns: The B value to use in passiveColor or activeColor.

Returns the B color value for the navball marker icon selected. This function is intended to be used in conjunction with the '%NAVBALL_ICON%' texture in MASMonitor IMAGE nodes.

  • 0 - Prograde
  • 1 - Retrograde
  • 2 - Radial Out
  • 3 - Radial In
  • 4 - Normal +
  • 5 - Normal - (anti-normal)
  • 6 - Maneuver Node
  • 7 - Target +
  • 8 - Target - (anti-target)

If an invalid number is supplied, this function treats is as "Prograde".

fc.NavballG(double iconId)

  • iconId: The icon as explained in the description.

Returns: The G value to use in passiveColor or activeColor.

Returns the G color value for the navball marker icon selected. This function is intended to be used in conjunction with the '%NAVBALL_ICON%' texture in MASMonitor IMAGE nodes.

  • 0 - Prograde
  • 1 - Retrograde
  • 2 - Radial Out
  • 3 - Radial In
  • 4 - Normal +
  • 5 - Normal - (anti-normal)
  • 6 - Maneuver Node
  • 7 - Target +
  • 8 - Target - (anti-target)

If an invalid number is supplied, this function treats is as "Prograde".

fc.NavballR(double iconId)

  • iconId: The icon as explained in the description.

Returns: The R value to use in passiveColor or activeColor.

Returns the R color value for the navball marker icon selected. This function is intended to be used in conjunction with the '%NAVBALL_ICON%' texture in MASMonitor IMAGE nodes.

  • 0 - Prograde
  • 1 - Retrograde
  • 2 - Radial Out
  • 3 - Radial In
  • 4 - Normal +
  • 5 - Normal - (anti-normal)
  • 6 - Maneuver Node
  • 7 - Target +
  • 8 - Target - (anti-target)

If an invalid number is supplied, this function treats is as "Prograde".

fc.NavballU(double iconId)

  • iconId: The icon as explained in the description.

Returns: The U value to use in uvShift.

Returns the U texture shift to select the navball marker icon as listed below. This function is intended to be used in conjunction with the '%NAVBALL_ICON%' texture in MASMonitor IMAGE nodes.

  • 0 - Prograde
  • 1 - Retrograde
  • 2 - Radial Out
  • 3 - Radial In
  • 4 - Normal +
  • 5 - Normal - (anti-normal)
  • 6 - Maneuver Node
  • 7 - Target +
  • 8 - Target - (anti-target)

If an invalid number is supplied, this function treats is as "Prograde".

fc.NavballV(double iconId)

  • iconId: The icon as explained in the description.

Returns: The V value to use in uvShift.

Returns the V texture shift to select the navball marker icon as listed below. This function is intended to be used in conjunction with the '%NAVBALL_ICON%' texture in MASMonitor IMAGE nodes.

  • 0 - Prograde
  • 1 - Retrograde
  • 2 - Radial Out
  • 3 - Radial In
  • 4 - Normal +
  • 5 - Normal - (anti-normal)
  • 6 - Maneuver Node
  • 7 - Target +
  • 8 - Target - (anti-target)

If an invalid number is supplied, this function treats is as "Prograde".

fc.PlayAudio(string sound, double volume, bool stopCurrent)

  • sound: The name (URI) of the sound to play.
  • volume: The volume to use for playback, between 0 and 1 (inclusive).
  • stopCurrent: If 'true', stops any current audio clip being played.

Returns: Returns 1 if the audio was played, 0 if it was not found or otherwise not played.

Play the audio file specified in sound, at the volume specified in volume. If stopCurrent is true, any current sound clip is canceled first. If stopCurrent is false, and an audio clip is currently playing, this call to PlayAudio does nothing.

fc.PlayMorseSequence(string sequence, double volume, bool stopCurrent)

  • sequence: The sequence of letters to play as a Morse Code.
  • volume: The volume to use for playback, between 0 and 1 (inclusive).
  • stopCurrent: If 'true', stops any current audio clip being played.

Play the sequence of letters as a Morse Code sequence. Letters play automatically, and a space ' ' inserts a pause in the sequence. All other characters are skipped.

fc.RecoverVessel()

Returns: 1 if the craft can be recovered (although it is also recovered immediately), 0 otherwise.

Recover the vessel if it is recoverable. Has no effect if the craft can not be recovered.

fc.RunMonitorStartupScript()

Returns: The number of scripts executed.

Run the startupScript on every monitor and prop in the pod that has a defined startupScript.

fc.ScrollingMarquee(string inputString, double maxChars, double scrollRate)

  • inputString: The string to use for the marquee.
  • maxChars: The maximum number of characters in the string to display.
  • scrollRate: The frequency, in seconds, that the marquee advances.

Returns: A substring of no more than maxChars length.

The ScrollingMarquee function takes a string, input, and it returns a substring of maximum length maxChars. The substring that is returned changes every scrollRate seconds if the string length is greater than maxChars, allowing for a scrolling marquee effect. Using this method with the Repetition Scrolling font can simulate an LED / LCD display.

Note that characters advance one character width at a time - it is not a smooth sliding movement.

fc.SetWarp(double warpRate, bool instantChange)

  • warpRate: The desired warp rate, such as '50'.
  • instantChange: Should the rate be changed instantly?

Returns: The warp rate selected. This may not be the exact value requested.

Attempt to set time warp rate to warpRate. Because KSP has specific supported rates, the rate selected may not match the rate requested. Warp rates are not changed when physics warp is enabled (such as while flying in the atmosphere).

fc.VesselRecoverable()

Returns: 1 if the craft can be recovered, 0 otherwise.

Returns 1 if the vessel is recoverable, 0 otherwise.

fc.WarpTo(double UT)

  • UT: The Universal Time to warp to. Must be in the future.

Returns: 1 if the warp to time is successfully set, 0 if it was not.

Warp to the specified universal time. If the time is in the past, or the warp is otherwise not possible, nothing happens.


Orbit Parameters Category

Information on the vessel's current orbit are available in this category.

fc.Apoapsis()

Returns the orbit's apoapsis (from datum) in meters.

fc.Eccentricity()

Return the eccentricity of the orbit.

fc.Inclination()

Returns: Inclination in degrees.

Return the vessel's orbital inclination.

fc.NextBodyName()

Returns: Name of the body, or an empty string if the orbit does not change SoI.

Returns the name of the body that the vessel will be orbiting after the next SoI change. If the craft is not changing SoI, returns an empty string.

fc.TimeToNextSoI()

Returns the time to the next SoI transition. If the current orbit does not change SoI, returns 0.

fc.NextSoI()

Returns: 0 if the orbit does not transition. 1 if the vessel will encounter a body, -1 if the vessel will escape the current body.

Returns 1 if the next SoI change is an 'encounter', -1 if it is an 'escape', and 0 if the orbit is not changing SoI.

fc.OrbitPeriod()

Returns: Orbital period, seconds. Zero if the craft is not in flight.

Returns the orbital period, in seconds.

fc.Periapsis()

Returns the orbits periapsis (from datum) in meters.

fc.SemiMajorAxis()

Returns: SMA in meters.

Returns the semi-major axis of the current orbit. When the SMA matches a body's synchronous orbit SMA, the vessel is in a synchronous orbit.


Orientation Category

Variables related to the vessel's orientation in space, relative to a target, or relative to the surface, are here.

fc.AngleOfAttack()

Returns: The angle of attack, in degrees

Returns the angle of attack of the vessel. If FAR is installed, FAR's results are used.

fc.Heading()

Return heading relative to the surface in degrees [0, 360)

fc.HeadingPrograde()

Return the heading of the surface velocity vector relative to the surface in degrees [0, 360)

fc.Pitch()

Return pitch relative to the surface [-90, 90]

fc.PitchActivePrograde()

Pitch of the vessel relative to the current SAS prograde mode (orbit, surface, or target).

fc.PitchAntiNormal()

Pitch of the vessel relative to the orbit anti-normal vector.

fc.PitchAntiTarget()

Pitch of the vessel relative to the vector pointing away from the target.

fc.PitchDockingAlignment()

Returns the pitch component of the angle between a target docking port and a reference (on Vessel) docking port; 0 if the target is not a docking port or if the reference transform is not a docking port.

fc.PitchManeuver()

Pitch of the vessel relative to the next scheduled maneuver vector.

fc.PitchNormal()

Pitch of the vessel relative to the orbit normal vector.

fc.PitchRate()

Returns the pitch rate of the vessel in degrees/sec

fc.PitchPrograde()

Pitch of the vessel relative to the orbital prograde vector.

fc.PitchRadialIn()

Pitch of the vessel relative to the orbital Radial In vector.

fc.PitchRadialOut()

Pitch of the vessel relative to the orbital Radial Out vector.

fc.PitchRetrograde()

Pitch of the vessel relative to the orbital retrograde vector.

fc.PitchSAS()

Returns: Pitch in the range [+90, -90]

Pitch of the vessel relative to the current active SAS mode. If SAS is not enabled, or the current mode is Stability Assist, returns 0.

fc.PitchSurfacePrograde()

Pitch of the vessel relative to the surface prograde vector.

fc.PitchSurfaceRetrograde()

Pitch of the vessel relative to the surface retrograde vector.

fc.PitchTarget()

Pitch of the vessel relative to the vector pointing at the target.

fc.PitchTargetPrograde()

Pitch of the vessel relative to the target relative prograde vector.

fc.PitchTargetRetrograde()

Pitch of the vessel relative to the target relative retrograde vector.

fc.PitchWaypoint()

Pitch of the vessel relative to the active waypoint. 0 if no active waypoint.

fc.ReferenceTransformType()

Returns a number identifying what the current reference transform is: 1: The current IVA pod (if in IVA) 2: A command pod or probe control part. 3: A docking port 4: A Grapple Node (Claw) 0: Unknown.

fc.Roll()

Return roll relative to the surface. [-180, 180]

fc.RollDockingAlignment()

Returns the roll angle between the vessel's reference transform and a targeted docking port. If the target is not a docking port, returns 0;

fc.RollRate()

Returns the roll rate of the vessel in degrees/sec

fc.Sideslip()

Returns: Sideslip in degrees.

Returns the vessel's current sideslip. If FAR is installed, it will use FAR's computation of sideslip.

fc.SlopeAngle()

Returns: Slope of the terrain below the vessel, or 0 if the slope cannot be read.

Returns the slope of the terrain directly below the vessel. If the vessel's altitude is too high to read the slope, returns 0.

fc.YawActivePrograde()

Yaw of the vessel relative to the current SAS prograde mode (orbit, surface, or target).

fc.YawAntiNormal()

Yaw of the vessel relative to the orbit's anti-normal vector.

fc.YawAntiTarget()

Yaw of the vessel relative to the vector pointing away from the target.

fc.YawDockingAlignment()

Returns the yaw angle between the vessel's reference transform and a targeted docking port. If the target is not a docking port, returns 0;

fc.YawManeuver()

Yaw of the vessel relative to the next scheduled maneuver vector.

fc.YawNormal()

Yaw of the vessel relative to the orbit's normal vector.

fc.YawRate()

Returns the yaw rate of the vessel in degrees/sec

fc.YawPrograde()

Yaw of the vessel relative to the orbital prograde vector.

fc.YawRadialIn()

Yaw of the vessel relative to the radial in vector.

fc.YawRadialOut()

Yaw of the vessel relative to the radial out vector.

fc.YawRetrograde()

Yaw of the vessel relative to the orbital retrograde vector.

fc.YawSAS()

Returns: Yaw in the range [+180, -180]

Yaw of the vessel relative to the current active SAS mode. If SAS is not enabled, or the current mode is Stability Assist, returns 0.

fc.YawSurfacePrograde()

Yaw of the vessel relative to the surface prograde vector.

fc.YawSurfaceRetrograde()

Yaw of the vessel relative to the surface retrograde vector.

fc.YawTarget()

Yaw of the vessel relative to the vector pointing at the target.

fc.YawTargetPrograde()

Yaw of the vessel relative to the target relative prograde vector.

fc.YawTargetRetrograde()

Yaw of the vessel relative to the target relative retrograde vector.

fc.YawWaypoint()

Yaw of the vessel relative to the active waypoint. 0 if no active waypoint.


Periodic Variables Category

Periodic variables change value over time, based on a requested frequency.

fc.PeriodCount(double period, double countTo)

  • period: The period required to increase the counter, in cycles/second (Hertz).
  • countTo: The exclusive upper limit of the count.

Returns: An integer between [0 and countTo).

Returns a periodic variable that counts upwards from 0 to 'countTo'-1 before repeating, with each change based on the 'period'. Note that the counter is not guaranteed to start at zero, since it is based on universal time.

fc.PeriodSine(double period)

  • period: The period of the change, in cycles/second (Hertz).

Returns: A number between -1 and +1.

Returns a periodic variable that follows a sine-wave curve.

fc.PeriodStep(double period)

  • period: The period of the change, in cycles/second (Hertz).

Returns: 0 or 1

Returns a stair-step periodic variable (changes from 0 to 1 to 0 with no ramps between values).


Persistent Vars Category

Persistent variables are the primary means of data storage in Avionics Systems. As such, there are many ways to set, alter, or query these variables.

Persistent variables may be numbers or strings. Several of the setter and getter functions in this category will convert the variable automatically from one to the other (whenever possible), but it is the responsibility of the prop config maker to make sure that text and numbers are not intermingled when a specific persistent variable will be used as a number.

fc.AddPersistent(string persistentName, double amount)

  • persistentName: The name of the persistent variable to change.
  • amount: The amount to add to the persistent variable.

Returns: The new value of the persistent variable, or the name of the variable if it could not be converted to a number.

This method adds an amount to the named persistent. If the variable did not already exist, it is created and initialized to 0 before adding amount. If the variable was a string, it is converted to a number before adding amount.

If the variable cannot converted to a number, the variable's name is returned, instead.

fc.AddPersistentClamped(string persistentName, double amount, double minValue, double maxValue)

  • persistentName: The name of the persistent variable to change.
  • amount: The amount to add to the persistent variable.
  • minValue: The minimum value of the variable. If adding amount to the variable causes it to be less than this value, the variable is set to this value, instead.
  • maxValue: The maximum value of the variable. If adding amount to the variable causes it to be greater than this value, the variable is set to this value, instead.

Returns: The new value of the persistent variable, or the name of the variable if it could not be converted to a number.

This method adds an amount to the named persistent. The result is clamped to the range [minValue, maxValue].

If the variable did not already exist, it is created and initialized to 0 before adding amount. If the variable was a string, it is converted to a number before adding amount.

If the variable cannot converted to a number, the variable's name is returned, instead.

fc.AddPersistentWrapped(string persistentName, double amount, double minValue, double maxValue)

  • persistentName: The name of the persistent variable to change.
  • amount: The amount to add to the persistent variable.
  • minValue: The minimum value of the variable. If adding amount would make the variable less than minValue, MAS sets the variable to maxValue minus the difference.
  • maxValue: The maximum value of the variable. If adding amount would make the variable greather than maxValue, MAS sets the variable to minValue plus the overage.

Returns: The new value of the persistent variable, or the name of the variable if it could not be converted to a number.

This method adds an amount to the named persistent. The result wraps around the range [minValue, maxValue]. This feature is used, for instance, for adjusting a heading between 0 and 360 degrees without having to go from 359 all the way back to 0. maxValue is treated as an alias for minValue, so if adding to a persistent value makes it equal exactly maxValue, it is set to minValue instead. With the heading example above, for instance, you would use fc.AddPersistentWrapped("SomeVariableName", 1, 0, 360).

To make a counter that runs from 0 to 2 before wrapping back to 0 again, fc.AddPersistentWrapped("SomeVariableName", 1, 0, 3).

If the variable did not already exist, it is created and initialized to 0 before adding amount. If the variable was a string, it is converted to a number before adding amount.

If the variable cannot converted to a number, the variable's name is returned, instead.

If minValue and maxValue are the same, amount is treated as zero (nothing is added).

fc.AppendPersistent(string persistentName, string addon, double maxLength)

  • persistentName: The name of the persistent variable to change.
  • amount: The amount to add to the persistent variable.
  • maxLength: The maximum number of characters allowed in the string. Characters in excess of this amount are not added to the persistent.

Returns: The new string.

Append the string addon to the persistent variable persistentName, but only up to the specified maximum length. If the persistent does not exist, it is created and initialized to addon. If the persistent is a numeric value, it is converted to a string, and then addon is added.

fc.GetPersistent(string persistentName)

  • persistentName: The name of the persistent variable to query.

Returns: The value of the persistent, or its name if it does not exist.

Return value of the persistent. Strings are returned as strings, numbers are returned as numbers. If the persistent does not exist yet, the name is returned.

fc.GetPersistentAsNumber(string persistentName)

  • persistentName: The name of the persistent variable to query.

Returns: The numeric value of the persistent, or 0 if it either does not exist, or it cannot be converted to a number.

Return the value of the persistent as a number. If the persistent does not exist yet, or it is a string that can not be converted to a number, return 0.

fc.GetPersistentExists(string persistentName)

  • persistentName: The persistent variable name to check.

Returns: 1 if the variable contains initialized data, 0 if it does not.

Returns 1 if the named persistent variable has been initialized. Returns 0 if the variable does not exist yet.

fc.SetPersistent(string persistentName, object value)

  • persistentName: The name of the persistent variable to change.
  • value: The new number or text string to use for this persistent.

Returns: value

Set a persistent to value. value may be either a string or a number. The existing value of the persistent is replaced.

fc.SetPersistentBlended(string persistentName, double value, double maxChangePerSecond)

  • persistentName: The name of the persistent variable to change.
  • value: The new value for this variable.
  • maxChangePerSecond: The maximum amount the existing variable may change per second.

Returns: The resulting value.

Set a persistent to value, but allow the persistent to change by at most maxChangePerSecond from its initial value.

If the persistent did not already exist, or if it was a string that could not be converted to a number, it is set to value immediately.

For other cases, the persistent's value is updated by adding or subtracting the minimum of (maxChangePerSecond * timestep) or Abs(old value - value).

While this method is a "setter" method, it is best applied where its results are displayed, such as a number on an MFD, or controlling the animation of a prop. This will ensure that the number continually updates, whereas using this method in a collider action will cause it to only update the value when the collider is hit.

fc.TogglePersistent(string persistentName)

  • persistentName: The name of the persistent variable to change.

Returns: 0 or 1. If the variable was a string, and it could not be converted to a number, persistentName is returned, instead.

Toggle a persistent between 0 and 1.

If the persistent is a number, it becomes 0 if it was a positive number and it becomes 1 if it was previously %lt;= 0.

If the persistent was a string, it is converted to a number, and the same rule is applied.


Position Category

The Position category provides information about the vessel's position relative to a body (latitude and longitude) as well as landing predictions and the like.

The various landing functions, such as LandingLatitude(), will prefer results generated by MechJeb if its Landing Predictions module is active. Otherwise, it uses a very rudimentary predictor that assumes the planet has no atmosphere and is a sphere at sea level. Because of these limitations, the results will change during atmospheric braking, and they may be wildly inaccurate in mountainous terrain.

fc.LandingAltitude()

Returns: Predicted altitude (meters ASL) of the point of landing.

Returns the predicted altitude of landing. Uses MechJeb if its landing computer is active.

If the MechJeb is not available, the fallback estimator assumes the surface is at sea level and there is no atmosphere, so this result will be inaccurate when the point of impact is at a higher altitude, or there is an atmosphere.

fc.LandingLatitude()

Returns: Latitude of estimated landing point, or 0 if the orbit does not lithobrake.

Returns the predicted latitude of landing. Uses MechJeb if its landing computer is active.

If the MechJeb is not available, the fallback estimator assumes the surface is at sea level and there is no atmosphere, so this result will be inaccurate when the point of impact is at a higher altitude, or there is an atmosphere.

fc.LandingLongitude()

Returns: Longitude of estimated landing point, or 0 if the orbit does not lithobrake.

Returns the predicted longitude of landing. Uses MechJeb if its landing computer is active.

If the MechJeb is not available, the fallback estimator assumes the surface is at sea level and there is no atmosphere, so this result will be inaccurate when the point of impact is at a higher altitude, or there is an atmosphere.

fc.LandingPredictorActive()

Returns 1 if landing predictions are valid. Automatically selects MechJeb if its landing computer is active.

fc.Latitude()

Return the vessel's latitude.

fc.Longitude()

Return the vessel's longitude.


Power Production Category

Queries and controls related to power production belong in this category.

For all of these components, if the player has changed the ElectricCharge field in the MAS config file, these components will track that resource instead.

The Fuel Cell methods track any ModuleResourceConverter that outputs ElectricCharge, unless a different resource converter tracker has been installed with a higher priority. For general-purpose ModuleResourceConverter tracking, refer to Resource Converter category.

fc.AlternatorCount()

Returns: Number of alternator modules.

Returns the number of alternators on the vessel.

fc.AlternatorOutput()

Returns: Units of ElectricCharge/second

Returns the current net output of the alternators.

fc.FuelCellCount()

Returns: Number of fuel cells.

Returns the number of fuel cells on the vessel. Fuel cells are defined as ModuleResourceConverter units that output ElectricCharge (or whatever the player-selected override is in the MAS config file).

fc.FuelCellOutput()

Returns: Units of ElectricCharge/second.

Returns the current output of installed fuel cells.

fc.GeneratorCount()

Returns: Number of generator.s

Returns the number of generators on the vessel. Generators are and ModuleGenerator that outputs ElectricCharge.

fc.GeneratorOutput()

Returns: Output in ElectricCharge/sec.

Returns the current output of installed generators.

fc.GetFuelCellActive()

Returns: 1 if any fuel cell is switched on; 0 otherwise.

Returns 1 if at least one fuel cell is enabled; 0 otherwise.

fc.SolarPanelCount()

Returns: The number of solar panel modules on the vessel.

Returns the number of solar panels on the vessel.

fc.SolarPanelDamaged()

Returns: 1 is all solar panels are damaged; 0 otherwise.

Returns 1 if all solar panels are damaged.

fc.SolarPanelDeployable()

Returns: 1 if any solar panel is retracted and available to deploy; 0 otherwise.

Returns 1 if at least one solar panel may be deployed.

fc.SolarPanelEfficiency()

Returns: The efficiency value, 0 or larger.

Returns the net efficiency of solar panels. This value can provide some information about blocked solar panels, or non-rotating solar panels that are not optimally positioned. Because the amount of energy delivered depends on the distance from the star, maximum efficiency can be larger than 1 (or less than 1).

fc.SolarPanelMoving()

Returns: 1 if any solar panels are moving (deploying or retracting).

Returns 1 if at least one solar panel is moving.

fc.SolarPanelOutput()

Returns: Solar panel output in ElectricCharge/sec.

Returns the current output of installed solar panels.

fc.SolarPanelPosition()

Returns: Panel Position (a number between 0 and 4); 1 if no panels are installed.

Returns a number representing deployable solar panel position:

  • 0 = Broken
  • 1 = Retracted
  • 2 = Retracting
  • 3 = Extending
  • 4 = Extended

If there are multiple panels, the first non-broken panel's state is reported; if all panels are broken, the state will be 0.

fc.SolarPanelRetractable()

Returns: 1 if a solar panel is deployed, and it may be retracted; 0 otherwise.

Returns 1 if at least one solar panel is retractable.

fc.ToggleFuelCellActive()

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

Toggles fuel cells from off to on or vice versa. Fuel cells that can not be manually controlled are not toggled.

fc.ToggleSolarPanel()

Returns: 1 if at least one panel is moving; 0 otherwise.

Deploys / undeploys solar panels.


Procedural Fairings Category

This section contains the functions used to interact with the stock procedural fairings system.

fc.DeployFairings()

Returns: 1 if any fairings deployed, 0 otherwise.

Deploys all stock procedural fairings that are currently available to deploy.

fc.FairingsCanDeploy()

Returns: 1 if any fairings can deploy, 0 otherwise.

Returns 1 if at least one installed stock procedural fairing is available to deploy.

fc.FairingsCount()

Returns: The total number of stock p-fairings on the vessel.

Returns the number of stock procedural fairings installed on the vessel.


Radar Category

The Radar category provides the interface for controlling MASRadar modules installed on the craft.

fc.RadarActive()

Returns: 1 if any radar is switched on; 0 otherwise.

Returns 1 if any radars are turned on; 0 otherwise.

fc.RadarCount()

Returns: The count of the number of radar units installed on the vessel, 0 or higher.

Returns the number of radar modules available on the vessel.

fc.ToggleRadar()

Toggle any installed radar from active to inactive.


Random Category

Random number generators are in this category.

fc.Random()

Returns: A uniformly-distributed pseudo-random number in the range [0, 1].

Return a random number in the range of [0, 1]

fc.RandomNormal(double mean, double stdDev)

  • mean: The desired mean of the normal distribution.
  • stdDev: The desired standard deviation of the normal distribution.

Returns: A pseudo-random number that emulates a normal distribution. See the summary for more detail.

Return an approximation of a normal distribution with a mean and standard deviation as specified. The actual result falls in the range of (-7, +7) for a mean of 0 and a standard deviation of 1.

fc.RandomNormal uses a Box-Muller approximation method modified to prevent a 0 in the u component (to avoid trying to take the log of 0). The number was tweaked so for all practical purposes the range of numbers is about (-7, +7), as explained above.


RCS Category

The RCS controls may be accessed in this category along with status variables.

fc.AnyRCSDisabled()

Returns: 1 if any ports are disabled; 0 if all are enabled or there are no RCS ports.

Returns 1 if any RCS ports are disabled on the vessel.

fc.CurrentRCSThrust()

Returns: A value between 0.0 and 1.0.

Returns the current thrust percentage of all enabled RCS thrusters. This number counts only active RCS ports. Even so, it is possible for the result to be less than 1.0. For instance, if some thrusters are firing at less than full power to maintain orientation while translating, the net thrust will be less than 1.0.

The result does not account for thrust reductions in the atmosphere due to lower ISP, so sea level thrust will be a fraction of full thrust.

fc.EnableAllRCS()

Returns: 1 if any disabled RCS ports were enabled, 0 if there were no disabled ports.

Enables any RCS ports that have been disabled.

fc.RCSHasActions()

Returns: 1 if any actions are assigned to the RCS group.

Returns 1 if the RCS action group has any actions attached to it. Note that RCS thrusters don't neccessarily appear here.

fc.GetRCS()

Returns: 1 if the RCS group is enabled, 0 otherwise.

Returns 1 if RCS is on, 0 otherwise.

fc.GetRCSActive()

Returns 1 if any RCS thrusters are firing, 0 otherwise.

fc.GetRCSRotate()

Returns 1 if any RCS thrusters are configured to allow rotation, 0 otherwise.

fc.GetRCSThrustLimit()

Returns: A weighted average between 0 (no thrust) and 1 (full rated thrust).

Returns the thrust-weighted average of the RCS thrust limit for all enabled RCS thrusters.

fc.GetRCSTranslate()

Returns 1 if any RCS thrusters are configured to allow translation, 0 otherwise.

fc.HasRCS()

Returns 1 if there is at least once RCS module on the vessel.

fc.SetRCS(bool active)

  • active: true to enable RCS, false to disable RCS.

Set the state of RCS.

fc.SetRCSRotate(bool active)

  • active: Whether RCS should be used for rotation.

Returns: The number of RCS modules updated (0 if none, more than 0 if any RCS are installed).

Enable or disable RCS rotation control.

fc.SetRCSTranslate(bool active)

  • active: Whether RCS should be used for translation.

Returns: The number of RCS modules updated (0 if none, more than 0 if any RCS are installed).

Enable or disable RCS translation control.

fc.SetRCSThrustLimit(double limit)

  • limit: A value between 0 (no thrust) and 1 (full thrust).

Set the maximum thrust limit of the RCS thrusters.

fc.ToggleRCS()

Toggle RCS off-to-on or vice versa.

fc.ToggleRCSRotate()

Returns: 1 if rotation is now on, 0 otherwise.

Toggle RCS rotation control.

fc.ToggleRCSTranslate()

Returns: 1 if translation is now on, 0 otherwise.

Toggle RCS translation control.


Reaction Wheels Category

Methods for controlling and reporting information from reaction wheels are in this category.

Unlike other categories, the reaction wheels methods can be used to inspect the reaction wheels installed in the current pod (when currentPod is true), or the methods can be used to inspect all reaction wheels not in the current pod (when currentPod is false). To inspect values for all reaction wheels (current pod and rest of vessel), sum the results together (with the exception of ReactionWheelState).

fc.GetReactionWheelActive()

Returns 1 if at least one reaction wheel is on the vessel and active. Returns 0 otherwise.

fc.GetReactionWheelAuthority()

Returns: Reaction wheel authority in the range of [0, 1].

Returns the current reaction wheel authority as a percentage of maximum.

fc.GetReactionWheelDamaged()

Returns 1 if at least one reaction wheel is damaged. Returns 0 otherwise.

fc.ReactionWheelPitch()

Returns: The net pitch, between -1 and +1.

Returns the net pitch being applied by reaction wheels as a value between -1 and +1. Note that if two wheels are applying pitch in opposite directions, this value will cancel out and reprot 0.

fc.ReactionWheelRoll()

Returns: The net roll, between -1 and +1.

Returns the net roll being applied by reaction wheels as a value between -1 and +1. Note that if two wheels are applying roll in opposite directions, this value will cancel out and reprot 0.

fc.ReactionWheelTorque()

Returns: A number between 0 (no torque) and 1 (maximum torque).

Returns the total torque percentage currently being applied via reaction wheels.

fc.ReactionWheelYaw()

Returns: The net yaw, between -1 and +1.

Returns the net yaw being applied by reaction wheels as a value between -1 and +1. Note that if two wheels are applying yaw in opposite directions, this value will cancel out and reprot 0.

fc.SetReactionWheelAuthority(double authority)

  • authority: The new authority percentage, between 0 and 1. Value is clamped if it is outside that range.

Returns: The new reaction wheel authority, or 0 if no wheels are available.

Update all active reaction wheels' authority.

fc.ToggleReactionWheel()

Returns: 1 if any reaction wheels are installed, otherwise 0.

Toggle the reaction wheels.


This documentation was automatically generated from source code at 18:30 UTC on 13/Jun/2018.

Clone this wiki locally