VASSAL Reference Manual

Home > Module > Game Piece Palette > Game Piece > Calculated Property

Calculated Property

A Calculated Property defines a Property which has a value that is calculated by a formula each time it is needed. The property can be referred to by name in other traits in the piece, either for creating Message Formats to display messages or in e.g. Property Match Expressions. Each place the property name is referred to in an expression, the value will be recalculated and substituted.

Unlike many fields in VASSAL, Calculated Properties exclusively support BeanShell Expressions. Thus "Old Style VASSAL" comparisons e.g. with single = sign, and the ~= operator, are not supported here. The traditional {..} marks around BeanShell expressions also do not appear in this context.

VASSAL will recalculate the value of the Expression each and every time its value is asked for: whether it is referenced in another Calculated Property, an Expression or field in another type of trait, or is displayed in a message or a text field. This ensures the value will be kept accurately updated, though module designers should be aware that long complicated chains of Calculated Properties can therefore lead to "lag" and slower performance.


A short description of this property for your own reference.

Property name:

The name of the property that is used to access the formula value.


A BeanShell Expression that defines the formula that calculates the property value. Immediately to the right of the expression field, a green tick or a red cross appears as you are typing that tells you if your BeanShell Expression is valid or not.


Use the Insert button to access the Expression Builder to add expression components such as property names, operators and functions. You can also type the formula in directly.