Is it possible to assign Properties by Layer? I have a counter with a Marker trait that denotes a resource level on the game map. As the resource is damaged the value changes. I’ve got an Inventory window working to count the current levels.
This would force me to make a bunch of counters (one for each state), I’d rather make one and just use a Layer to display the current value. For the Inventory to count it I need to change a Property. so my question is can I assign that Property to the Level?
Does that make sense?
In VASSAL terminology this works the other way around–see the “Levels follow expression value” portion of the Layer documentation. This sounds like a straightforward application of that technique. A changing value belongs in a Dynamic Property rather than a Marker. The user is presented with commands in the Dynamic Property to set it to different values, and the Layer automatically tracks that property to know which image to display.
A basic hypothetical usage: you have a two-sided counter, one side is “full health” and the other is "damaged’. You choose to create a Dynamic Property called
Health where a value of 1 represents full health and a value of 2 represents damaged. You create two commands inside your Dynamic Property that get exposed to the user–one sets the value to 1 and is called “Restore to Full Health”. The other command sets the value to 2 and is called “Damage”. Create a Layer trait called
Status (or something similar) and tell it to track the value of the property
Health. Set images for each level so the correct image gets shown when
Status = 1 and when
Status = 2.
Ok, thanks. Trying to get there…
Here is one of my pieces:
Did I reference the Dynamic Property right? (reference below)
Ultimately I’m going to have five of these counters that I want to sum at the hit of a button (Action Button or GKC?)
Struggling with this part. I did name the Layer (despite the last screenshot) and I have the Images loaded, not sure how to connect that to the Dynamic Property?
You are referencing the property correctly. However, to the right of that where it shows
Level 1 = 5, you are unintentionally setting up a scheme as follows:
Level 1: 5 (using Image 1, currently
Level 2: 6 (using Image 2)
Level 3: 7 (using Image 3)
Level 4: 8 (using Image 4)
…and so on.
Based on the initial value of your Dynamic Property and its allowable range, you want:
Level 1: 0 (Image 1 set to use
0.png, if that’s a thing)
Level 2: 1 (Image 2 using
Level 3: 2 (Image 3 using
…and so on, so you’d finish with Image 6 set to
Thanks, that seems to have sorted it.
one last question on this, here is the Inventory window that displays and (hopefully) counts up the Dynamic Property total. It does show the counters just fine, the highlighted expression does not return the sum of the two Properties. Can I put an Expression there? Or is there some other way to do it?
Old-style property references (where you have a
$ signs enclosing things) do not support math operations at all, and that label field doesn’t support BeanShell evaluation (where you can do math). You’d need a Calculated Property somewhere to compute this sum and reference the value of that property here.
ok, thanks again I will continue fiddling with it…
BeanShell works here even though there’s no editor assistant (calculator icon).