[messages] [Module Design] Calculated properties

Sebaestschjin sebastian.naehring at gmail.com
Mon Apr 14 09:01:58 CEST 2014

Hi Panter2010

To A)
DP can also increment by another given property, not only by a fixed
value. The only problem is that you have to take care how you expression
looks like. If you simply type



Vassall will handle this as a string, so it will not use the actual
property value. You have tu sorround it with curly braces:



This will be done automatically if you use the expression generator by
clicking on the calculator icon. But sometimes I quickly wanted to enter
an expression and I often forgot the curly braces which won't work. So
maybe this is also the case for you?

Your example of a CP with
Name: Prop1
Expression: Prop1 + Prop2
won't work, because it will create an infinite loop while evaluating the
expression of Prop1. Prop1 will be recalculated whenever the properties
of its expression changes. Since Prop1 itself is part of its own
expression this is always the case.

To B)
The If-Then-Else syntax is as follows:



Where the names in <> are actual expressions. So in your case this would
look like this:


Expression: { If($Prop1$ == true, X, Y) }

You have to use == instead of = for an equality check and again the
curly braces are needed. What I am not sure about is how Vassal actually
handles boolean values. It works in this example but to on the safe side
I always use string comparison.

I attached a dummy module which uses all the mechanics I described
above, if you want to have a look at it. However I think a CP is not
required for your needs here. In principal a CP and a DP are the same.
Both can use the same expressions. The only difference is that a DP can
only change on a Trigger, so either a click by the user on a menu, or
some other key command from somewhere else. A CP is always recalculated.
As Brent Easton already said, its behaviour very similar to a spread
sheet cell with a formular.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testModule.vmod
Type: application/octet-stream
Size: 2577 bytes
Desc: not available
URL: <http://www.vassalengine.org/pipermail/messages/attachments/20140414/ccad7041/attachment.obj>
-------------- next part --------------

Read this topic online here:

More information about the messages mailing list