Dynamic token values possible?

Is it possible to set the value of a token property based on where on the map the token is located? For example, if I have a market area with 3 boxes for values 1, 2, and 3, can I drag a generic token into the 1 box and have that token’s value set to 1 (or 2 or 3 if I go to those boxes instead)? Then, once I’ve made all my purchases, I could drag everything to another box, my shopping cart, which would display the sum of all the token values?

Sure.

Add irregular grid to your market area boxes. Make the market area boxes read location from $gridLocation$. Named them locations accordingly.

Give each token a calculated property. Have it calculated as per If(CurrentZone==“Market Area”, stuff, not stuff).

Give each token a text label to display its value.

EDIT: to sum up value of tokens in an area: vassalengine.org/wiki/How_to … tion/state.

Thanks, but unfortunately that won’t quite work for my goal. What I had hoped to do was to assign those values as you suggest, but then have the player drag out only what they want to buy from the market. They would drag it to a “Buy Box” which would then add up all those values and show them the total they need to pay.

Isn’t this no longer a best practice? I thought the new supported syntax was of the form:

expression ? true-result : false-result

I need the tokens to retain their value so that, when a bunch are dragged to the shopping cart, the total value is automatically calculated and displayed.

Old habits die hard.

Sure. That is what that IF or condition ? if_true : if_false. The calculated value will be updated if and only if token’s current zone is MARKET. Whenever it leaves this zone, its value will not be changed i.e. it will be retained.

I believe it needs to be announced loudly and clearly: so far I only saw forum comments and replies to bugs. Or maybe I missed something?

I appreciate the help but these examples, “stuff” and “not stuff”, just aren’t specific enough for me to figure this out. Are there any modules that do this sort of thing that I can take a look at?

Here, d/l this module: dropbox.com/s/qz1u23gp44vud … .vmod?dl=0

Token value is set to 0 when it leaves zone named “market”, you may want to change this behaviour.

Thanks, that does help! What do you change “0” to to get a null effect, so the token retains its previous value?

THANK YOU! I think I’ve got it now, coming soon to a Power Grid module near you!

Happy to hear it worked for you. To have token retain its value I would use:

CurrentZone == "market" ? LocationName

i.e. get rid of " : 0" (which is ELSE condition in the above IF-ELSE statement).