vassalengine / vassal

VASSAL, the open-source boardgame engine
https://vassalengine.org
GNU Lesser General Public License v2.1
411 stars 97 forks source link

Implement Dynamic Arrays and Global Arrays #13481

Open BrentEaston opened 1 month ago

BrentEaston commented 1 month ago

Dynamic and Global Arrays will create extended versions of Dynamic and Global Properties that allow multiple values to be stored.

Access to these values will be via a new Beanshell function Get("propertyName", "index")

These will be associative arrays. The index can be, but does not need to be numeric, it can be a String, and will be converted to a String before being used to access the property value.

The Array Configuration component will allow initial values to be set up for any indexes you like to preset a value for.

Access to non-existent array entry will return "", unless the array is defined as Numeric, in which case it will return 0.

Attempts to set a non-numeric value in an element of a Numeric array will fail and generate a Bad Data in Module error.

The Set Value functionality of Dynamic properties, Global properties, Set Piece Property and Set Global Property will be extended to allow for an Index variable to be specified via an Expression. The value of the Index variable determines which element of the target array will be modified.

riverwanderer commented 1 month ago

Possibly redundant note to highlight also GP "Change-Property" and GKC, Replace with Other & Place Marker (iirc) that can set property values.