In-line expressions in global properties

Following up on the question posed by Brent in this post http://www.vassalengine.org/forum/viewtopic.php?f=4&t=5101#p35771, I think another place where in-line expressions would be a welcome feature is in the definition of global properties.

By this I mean, either

A) have a check box “calculated”, next to the “is numeric” one, which replaces the “initial value” prompt with a “expression” one

or

B) add “Global Calculated Properties” folders at module and map level, so that all contained Calculated Properties therein are shared by all counters in the module/map.

Not sure how difficult this would be, but I think it would save a lot of time when re-using the same Calculated Expression in many counters or prototypes.

Adding this feature would be difficult.

When the value of the Global Property is changed by a Toolbar button or trait, an actual value withing Vassal is updated with the new value and all items that are ‘listening’ to that value are updated. A Calculated Property does not have a specific value, it is recalculated afresh every time it is referenced. This makes it extremely difficult to implement a Global Calculated property.

Also, a Global property would not be able to to reference any values within a counter, so I am not sure how useful it would be.

Well, my idea was that any Global Calculated Properties would be “global” just in the sense it is not specific to the given counter. It would only reference global properties.

For example, to let people individually choose language specific images (see other thread) I need layers to follow something like $playerSide$_language. Once you have actually updated the layer trait to accept in-line expressions (see this thread) I could do that easily, but at the moment I need to add to every single piece/prototype the same Calculated Property, such as Language with value GetProperty(playerSide+“_language”), and have layers follow that instead.

It would be much easier, I think, to add that CP just once at module level, instead. Extend this simple example to cases where a lot of pieces/prototypes need to use a much more complex in-line expression/CP (but one still only using global properties)… Any re-working of the in-line expression/CP would need to be copied over all over the module (pieces and prototypes), with much scope for error, instead of just one single edit trickling done nice and easy.

I have never really done any OOP, so please forgive me my approximate language/understanding of it… but I guess that the Global Calculated Properties could just be the exact same lines of code already there for “normal” CP’s, but placed at top level… inheritable from every other class, couldn’t they?

I understand, so that does it then, no problem. I guess a workaround for me is to simply add the common CP’s to a new “library” type prototype shared by every single piece in my module (still scope for error if I forget to add it to some piece somewhere, though).