VASSAL Reference Manual

Home > Module > Expressions > Property Expressions


Property Functions

Overview

Vassal provides a set of functions to read the value of properties where the name of the property is not known in advance, or where the property exists in a different part of Vassal.

There are several groups of functions, depending on where the property you want to access resides.

General Functions

These functions are useful to access properties in specific situations where standard Property access can’t be used.

GetProperty Returns the value of the specified property.

GetProperty(prop)

This function is useful in two situations in Vassal:

  • Where the property name contains spaces or special characters that affect the creation of an expression.

  • Where the property name is not known in advance and needs to be generated from other Properties.

GetProperty("M-3 Result")

Return the value of the property named 'M-3 Result'.

GetProperty("Table" + x + "-" + y)

If x currently has a value of 2 and y has a value of 6, then this will return the value of the property 'Table2-6'.

GetString Returns the value of the specified property as a String.

GetString(prop)

This function returns the value of the property as a String, even if it is a Number.

GetString("X")

Return the value of the property named 'X' as a String.

Map-based Functions

These functions return the value of a Map-level property defined on another map.

GetMapProperty Return the value of a property from a different Map.

GetMapProperty(prop, map)

Return the value of the property that resides on the named Map.

GetMapProperty("SupplyLevel", "SupplyMap")

Return the value of the Global Property named 'SupplyLevel' that is defined on the Map named 'SupplyMap'.

Zone-based Functions

These functions return the value of a Zone-level property defined in another Zone.

GetZoneProperty Return the value of a property from a different Zone.

GetZoneProperty(prop, zone)

[ Trait Only ]

Return the value of the property that resides in a different named Zone, but on the same Map as the source piece.

GetZoneProperty("Supplies", "zone2")

Return the value of the Property named 'Supplies' that is defined in the Zone named 'zone2' on the current Map name.

GetZoneProperty(prop, zone, map)

Return the value of the property that resides in a named Zone on the named Map.

GetZoneProperty("Supplies", "zone2", "East")

Return the value of the Property named 'Supplies' that is defined in the Zone named 'zone2' on the Map named 'East'.

Attachment-based Functions

These functions return the value of a Property from a piece attached to the current piece using the Attachment trait.

All Attachment-based Functions will return the value of the property from the first attached piece it that meets the criteria of the function.

Note that if your Attachment includes the 'Allow attachment to self' option, then it is possible for these functions to find and return the Property value from the same piece that is calling the property.

GetAttachProperty Return the value of a property from a piece attached to the current piece.

GetAttachProperty(attach, prop)

[ Trait Only ]

Return the value of a property 'prop' from the first piece attached to the current piece using the attachment named 'attach'.

GetAttachProperty("SUP", "Supplies")

Return the value of the Property named 'Supplies' from the first piece attached to the current piece using the attachment name 'SUP'.

GetAttachProperty(attach, prop, index)

[ Trait Only ]

Return the value of the property from a specific attached piece.

GetAttachProperty("SUP", "Supplies", 4)

Return the value of the Property named 'Supplies' from the 4th piece attached to the current piece using the attachment name 'SUP'.

GetAttachProperty(attach, prop, basicName)

[ Trait Only ]

Return the value of the property from an attached piece with a specified name.

GetAttachProperty("SUP", "Supplies", "RU-2")

Return the value of the Property named 'Supplies' from the piece attached to the current piece using the attachment name 'SUP' that has a Basic Name of 'RU-2'.

GetAttachProperty(attach, prop, expr)

[ Trait Only ]

Return the value of the property from an attached piece that matches a Property Match Expression.

GetAttachProperty("SUP", "Supplies", "{Suppressed==false}")

Return the value of the Property named 'Supplies' from the piece attached to the current piece using the attachment name 'SUP' that has a value of false for the property name 'Suppressed'.