Create account / Log in

In-line expressions in global properties

Suggestions for additional features for the module editor and Vassal engine.

Moderators: uckelman, Tim M

In-line expressions in global properties

Postby barbanera » September 5th, 2012, 12:52 pm

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.
barbanera
 
Posts: 395
Joined: January 12th, 2012, 2:27 pm

Re: In-line expressions in global properties

Postby Brent Easton » September 5th, 2012, 9:11 pm

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.
User avatar
Brent Easton
 
Posts: 3226
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: In-line expressions in global properties

Postby barbanera » September 6th, 2012, 10:09 am

.. 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?

Adding this feature would be difficult.


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).
barbanera
 
Posts: 395
Joined: January 12th, 2012, 2:27 pm


Return to Feature Requests

Who is online

Users browsing this forum: No registered users and 2 guests