Keyword - MOARdV/AvionicsSystems GitHub Wiki

MAS allows several keywords to be used in config files. These keywords provide values that would be difficult or impossible to provide in other ways. Each keyword is listed below, along with where it's valid and why you may want to use it.

%AUTOID%

The %AUTOID% keyword tells MAS to generate a string comprised of the current prop's name and ID. The intent of this keyword is to make a unique name for a persistent variable when a specific name isn't required, such as for a dummy switch (irrelevant fields omitted for clarity):

MODULE
{
  name = MASComponent

  COLLIDER_EVENT
  {
    onClick = fc.TogglePersistent("%AUTOID%")
    ...
  }
  ANIMATION_PLAYER
  {
    variable = fc.GetPersistentAsNumber("%AUTOID%")
    ...
  }
}

This configuration will toggle the animation on or off each time the switch is clicked. A similar trick can be used to make a momentary button:

MODULE
{
  name = MASComponent

  COLLIDER_EVENT
  {
    onClick = fc.SetPersistent("%AUTOID%", 1)
    onRelease = fc.SetPersistent("%AUTOID%", 0)
    ...
  }
  ANIMATION_PLAYER
  {
    variable = fc.GetPersistentAsNumber("%AUTOID%")
    ...
  }
}

The keyword can be part of a string, eg fc.TogglePersistent("%AUTOID%-value1"), if multiple variables need to be tracked on the same prop. The %AUTOID% keyword is a simple string substitution, so it should only be used within quotation marks.

Be aware that if the order of props in an IVA is changed, or props are added or removed, the automatic ID for the props may change. This won't make much difference once an IVA has been released, but you likely will notice it when you're still working on the IVA prior to release.

%DRAG%

This keyword is used with onDragX and onDragY in a COLLIDER_EVENT.

%FLAG%

The %FLAG% keyword tells MAS to use the current part's flagURL for the texture. Most of the time, the flagURL is the flag that was set for the part when the craft was launched. You can use this keyword to display the flag texture on a MASMonitor using the IMAGE page node, or you can use it on other props with the MASComponent IMAGE node.

%ITEMID%

This keyword is used in dynamically-sized MENU nodes in a MASMonitor page.

%MAP_ICON%

The %MAP_ICON% keyword may be used in an IMAGE node of a MASMonitor page to select KSP's map icons texture atlas. This atlas can then be used to display various icons seen in from the Map View of KSP, such as vessel types, node markers, and so forth. To display specific icons from the atlas, the tiling field for the IMAGE node needs to be set to 0.2, 0.2, and the uvShift field should be set to fc.MapIconU(iconId), fc.MapIconV(iconId)(see).

%NAVBALL_ICON%

The %NAVBALL_ICON% keyword is used in IMAGE nodes of a MASMonitor page to select KSP's built-in navball icons atlas (the icons for prograde, retrograde, normal +, etc.). It is used in conjunction with fc.NavballU(iconId) and fc.NavballV(iconId), as described in the IMAGE entry.

%PROPCOUNT%

The %PROPCOUNT% keyword provides the number of props in the IVA's config. If the count can not be queried for some reason, it returns 1.

%PROPID%

The %PROPID% keyword only provides the prop ID, which is a number that tells you the index of the prop in the IVA's config. It provides a shorter unique identifier for a given prop. Be aware that if the order of props in an IVA is changed, or props are added or removed, the prop ID for props may change.

%X%, %Y%, %Z%

Used in conjunction with the COLLIDER_ADVANCED MASComponent node, these three keywords are used to transform a collider's hit location into values used for touch screen or other touch-enabled props.