-
Notifications
You must be signed in to change notification settings - Fork 27
MASFlightComputerProxy2
- Maneuver Node
- Mass
- Math
- Meta
- Orbit Parameters
- Orientation
- Periodic Variables
- Persistent Vars
- Position
- Power Production
- Procedural Fairings
- Radar
- Random
- RCS
- Reaction Wheels
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:
- MASFlightComputerProxy (Abort - Lights),
- MASFlightComputerProxy2 (Maneuver Node - Reaction Wheel), and
- MASFlightComputerProxy3 (Resources - Vessel Info).
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.
Methods for querying and controlling maneuver nodes are in this category.
-
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.
Returns: 1 if any nodes were cleared, 0 if no nodes were cleared.
Clear all scheduled maneuver nodes.
Returns: New Ap in meters, or 0 if no node is scheduled.
Returns the apoapsis of the orbit that results from the scheduled maneuver.
Returns: Approximate burn time in seconds, or 0 if no node is scheduled.
Returns an estimate of the maneuver node burn time, in seconds.
Returns: ΔV in m/s, or 0 if no node is scheduled.
Delta-V of the next scheduled node.
Returns: ΔV in m/s; negative values indicate anti-normal.
The normal component of the next scheduled maneuver.
Returns: ΔV in m/s; negative values indicate retrograde.
The prograde component of the next scheduled maneuver.
Returns: ΔV in m/s; negative values indicate anti-radial.
The radial component of the next scheduled maneuver.
Returns: New eccentricity, or 0 if no node is scheduled.
Returns the eccentricity of the orbit that results from the scheduled maneuver.
Returns 1 if there is a valid maneuver node; 0 otherwise
Returns: New inclination in degrees, or 0 if no node is scheduled.
Returns the inclination of the orbit that results from the scheduled maneuver.
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).
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.
Returns: New Pe in meters, or 0 if no node is scheduled.
Returns the periapsis of the orbit that results from the scheduled maneuver.
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.
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.
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.
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.
Returns time in seconds until the maneuver node; 0 if no node is valid.
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.
Vessel mass may be queried with these methods.
-
wetMass
: wet mass if true, dry mass otherwise
Returns: Vessel mass in tonnes.
Returns the mass of the vessel in tonnes.
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.
Returns: The absolute value of value
.
Returns the absolute value of value
.
-
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
andvalue
<=upperBound
, return 1. - Otherwise, reutrn 0.
-
value
: The value to round
Rounds a number up to the next integer.
-
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
.
-
value
: The value to round
Rounds a number down to the next integer.
-
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
-
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
-
angle
: The de-normalized angle to correct.
Returns: A value between 0 (inclusive) and 360 (exclusive).
Normalizes an angle to the range [0, 360).
-
angle
: The de-normalized angle to correct.
Returns: A value between -180 (inclusive) and +180 (exclusive).
Normalizes an angle to the range [-180, 180).
-
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].
-
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
-
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.
-
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 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.
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.
-
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.
-
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.
-
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.
-
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:
-
When there is no power available (the config-file-specified power variable is below 0.0001), or
-
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.
-
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.
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.
Returns 1 if the KSP UI is configured for the Kerbin calendar (6 hour days); returns 0 for Earth days (24 hour).
-
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].
-
iconId
: The Icon Id - eitherfc.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()
.
-
iconId
: The Icon Id - eitherfc.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()
.
Returns: MAS Version in string format.
Returns the version number of the MAS plugin, as a string,
such as 1.0.1.12331
.
-
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".
-
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".
-
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".
-
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".
-
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".
-
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.
-
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.
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.
Returns: The number of scripts executed.
Run the startupScript
on every monitor and prop in the pod that has a defined startupScript
.
-
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.
-
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).
Returns: 1 if the craft can be recovered, 0 otherwise.
Returns 1 if the vessel is recoverable, 0 otherwise.
-
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.
Information on the vessel's current orbit are available in this category.
Returns the orbit's apoapsis (from datum) in meters.
Return the eccentricity of the orbit.
Returns: Inclination in degrees.
Return the vessel's orbital inclination.
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.
Returns the time to the next SoI transition. If the current orbit does not change SoI, returns 0.
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.
Returns: Orbital period, seconds. Zero if the craft is not in flight.
Returns the orbital period, in seconds.
Returns the orbits periapsis (from datum) in meters.
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.
Variables related to the vessel's orientation in space, relative to a target, or relative to the surface, are here.
Returns: The angle of attack, in degrees
Returns the angle of attack of the vessel. If FAR is installed, FAR's results are used.
Return heading relative to the surface in degrees [0, 360)
Return the heading of the surface velocity vector relative to the surface in degrees [0, 360)
Return pitch relative to the surface [-90, 90]
Pitch of the vessel relative to the current SAS prograde mode (orbit, surface, or target).
Pitch of the vessel relative to the orbit anti-normal vector.
Pitch of the vessel relative to the vector pointing away from the target.
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.
Pitch of the vessel relative to the next scheduled maneuver vector.
Pitch of the vessel relative to the orbit normal vector.
Returns the pitch rate of the vessel in degrees/sec
Pitch of the vessel relative to the orbital prograde vector.
Pitch of the vessel relative to the orbital Radial In vector.
Pitch of the vessel relative to the orbital Radial Out vector.
Pitch of the vessel relative to the orbital retrograde vector.
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.
Pitch of the vessel relative to the surface prograde vector.
Pitch of the vessel relative to the surface retrograde vector.
Pitch of the vessel relative to the vector pointing at the target.
Pitch of the vessel relative to the target relative prograde vector.
Pitch of the vessel relative to the target relative retrograde vector.
Pitch of the vessel relative to the active waypoint. 0 if no active waypoint.
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.
Return roll relative to the surface. [-180, 180]
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;
Returns the roll rate of the vessel in degrees/sec
Returns: Sideslip in degrees.
Returns the vessel's current sideslip. If FAR is installed, it will use FAR's computation of sideslip.
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.
Yaw of the vessel relative to the current SAS prograde mode (orbit, surface, or target).
Yaw of the vessel relative to the orbit's anti-normal vector.
Yaw of the vessel relative to the vector pointing away from the target.
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;
Yaw of the vessel relative to the next scheduled maneuver vector.
Yaw of the vessel relative to the orbit's normal vector.
Returns the yaw rate of the vessel in degrees/sec
Yaw of the vessel relative to the orbital prograde vector.
Yaw of the vessel relative to the radial in vector.
Yaw of the vessel relative to the radial out vector.
Yaw of the vessel relative to the orbital retrograde vector.
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.
Yaw of the vessel relative to the surface prograde vector.
Yaw of the vessel relative to the surface retrograde vector.
Yaw of the vessel relative to the vector pointing at the target.
Yaw of the vessel relative to the target relative prograde vector.
Yaw of the vessel relative to the target relative retrograde vector.
Yaw of the vessel relative to the active waypoint. 0 if no active waypoint.
Periodic variables change value over time, based on a requested frequency.
-
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.
-
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.
-
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 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.
-
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.
-
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 addingamount
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 addingamount
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.
-
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 addingamount
would make the variable less thanminValue
, MAS sets the variable tomaxValue
minus the difference. -
maxValue
: The maximum value of the variable. If addingamount
would make the variable greather thanmaxValue
, MAS sets the variable tominValue
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).
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
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.
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.
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.
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.
Returns 1 if landing predictions are valid. Automatically selects MechJeb if its landing computer is active.
Return the vessel's latitude.
Return the vessel's longitude.
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.
Returns: Number of alternator modules.
Returns the number of alternators on the vessel.
Returns: Units of ElectricCharge/second
Returns the current net output of the alternators.
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).
Returns: Units of ElectricCharge/second.
Returns the current output of installed fuel cells.
Returns: Number of generator.s
Returns the number of generators on the vessel. Generators
are and ModuleGenerator that outputs ElectricCharge
.
Returns: Output in ElectricCharge/sec.
Returns the current output of installed generators.
Returns: 1 if any fuel cell is switched on; 0 otherwise.
Returns 1 if at least one fuel cell is enabled; 0 otherwise.
Returns: The number of solar panel modules on the vessel.
Returns the number of solar panels on the vessel.
Returns: 1 is all solar panels are damaged; 0 otherwise.
Returns 1 if all solar panels are damaged.
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.
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).
Returns: 1 if any solar panels are moving (deploying or retracting).
Returns 1 if at least one solar panel is moving.
Returns: Solar panel output in ElectricCharge/sec.
Returns the current output of installed solar panels.
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.
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.
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.
Returns: 1 if at least one panel is moving; 0 otherwise.
Deploys / undeploys solar panels.
This section contains the functions used to interact with the stock procedural fairings system.
Returns: 1 if any fairings deployed, 0 otherwise.
Deploys all stock procedural fairings that are currently available to deploy.
Returns: 1 if any fairings can deploy, 0 otherwise.
Returns 1 if at least one installed stock procedural fairing is available to deploy.
Returns: The total number of stock p-fairings on the vessel.
Returns the number of stock procedural fairings installed on the vessel.
The Radar category provides the interface for controlling MASRadar modules installed on the craft.
Returns: 1 if any radar is switched on; 0 otherwise.
Returns 1 if any radars are turned on; 0 otherwise.
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.
Toggle any installed radar from active to inactive.
Random number generators are in this category.
Returns: A uniformly-distributed pseudo-random number in the range [0, 1].
Return a random number in the range of [0, 1]
-
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.
The RCS controls may be accessed in this category along with status variables.
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.
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.
Returns: 1 if any disabled RCS ports were enabled, 0 if there were no disabled ports.
Enables any RCS ports that have been disabled.
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.
Returns: 1 if the RCS group is enabled, 0 otherwise.
Returns 1 if RCS is on, 0 otherwise.
Returns 1 if any RCS thrusters are firing, 0 otherwise.
Returns 1 if any RCS thrusters are configured to allow rotation, 0 otherwise.
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.
Returns 1 if any RCS thrusters are configured to allow translation, 0 otherwise.
Returns 1 if there is at least once RCS module on the vessel.
-
active
:true
to enable RCS,false
to disable RCS.
Set the state of RCS.
-
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.
-
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.
-
limit
: A value between 0 (no thrust) and 1 (full thrust).
Set the maximum thrust limit of the RCS thrusters.
Toggle RCS off-to-on or vice versa.
Returns: 1 if rotation is now on, 0 otherwise.
Toggle RCS rotation control.
Returns: 1 if translation is now on, 0 otherwise.
Toggle RCS translation control.
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).
Returns 1 if at least one reaction wheel is on the vessel and active. Returns 0 otherwise.
Returns: Reaction wheel authority in the range of [0, 1].
Returns the current reaction wheel authority as a percentage of maximum.
Returns 1 if at least one reaction wheel is damaged. Returns 0 otherwise.
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.
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.
Returns: A number between 0 (no torque) and 1 (maximum torque).
Returns the total torque percentage currently being applied via reaction wheels.
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.
-
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.
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.