[messages] [Module Design] Calculated Property - Timing of Calculation and ???s

Rommel14 pfell.688 at gmail.com
Mon Aug 19 17:12:20 MST 2013


Brent,

Thanks for the valuable info--I was beginning to wonder if I had
committed a forum no-no since nobody had replied.   :? 

To clarify a few items:


> 
> > 1a) If the CP is called "Total" and the expression is "A+B", then
> > when are A and B summed? Are A and B summed when that trait is
> > reached in the list of traits, or is it summed when "Total" is
> > called the first time? Or is it neither?
> 
> Each and every time a trait referencing Total is evaluated.

This answers a big question of mine, as I thought you had to add a
trigger in there somewhere to specifically force the CP to calculate. 
Man, that's gonna simplify some code in a hurry!


> 
> > 1b) If the CP is called "Total" and the expression is (pseudo-code)
> > "If DeckName==DiscardPile || CurrentZone==AllocatedZone, Cards =
> > Cards + 1, Cards", when is "Cards" calculated?
> 
> I do not understand the 'Cards = Cards + 1, Cards' part. A CP can
> never change the value of a property, it only returns a value. It is
> recalculated each time it is needed.

Ah...I was thinking of this in terms of addition in Java and I messed up
the code.  "Cards" should be "Total".  Oops.   :oops:  I wanted to
increment the total number of cards by 1.  If I had used "Total", would
this work, or would I need to code it differently?


> 
> > 4) If the "Compare" command for properties allows you to compare
> > objects, can it accept "null" as a parameter? I tried to use this to
> > test whether or not something had been set by another trait, but a
> > null value just generated an error. How do you use this?
> 
> Use the empty string "" to compare to something that has not been set.
> Everything in Vassal is strings.

Is there a way to use null for anything at all, or is that an invalid
parameter at all times?  Should I always use the "empty string"?  The
reason I'm being this specific is that I need to check for whether some
items are "offboard" or not.  In the past, using "offboard" as a
parameter didn't work, so I had tried using "null", meaning that the
piece did not have a valid location set, but to no avail.  Would "empty
string" be the logical way to handle this at present, or is there
something that I'm missing?


Also, on a somewhat related note, has anyone expressed interest in
setting up a howto or "learn by example"-type subforum for coding?  I've
been doing a lot with automation and I know Dr. Nostromo has in the past
as well.  If I was to submit some of my examples or code walkthroughs,
where would be the best place--here in Module Design, or in a
different/new location?  Just wondering...it's taken me a while to
figure some of this stuff out, but I'd love to learn more and trade
ideas.

Thanks again!

_______________________________________________
Read this topic online here:
http://www.vassalengine.org/forum/viewtopic.php?p=41709#p41709


More information about the messages mailing list