Cant get conditional arguments to Trigger Action correctly

Referring to this screenshot may help put the stuff below in context.

I am making a dice roller where I want the dice to be visible as discrete dice. I got this idea from the person that posted a dice roller example a few days ago here in the forums (or at least I found it a few days ago), because that example helped me understand the way Vassal works.

I made a button layout to choose the number of dice to be shown. It has action buttons over the numbers that store the number of the button that was pressed in a global variable, Number_Pressed.

I made a die Prototype and created 5 At Start stacks of die images using this prototype. I stored the position (1-5) of each specific die in its respective At Start stack, using a marker called Position_of_die.

I made another button to start processing the dice images once the user is satisfied with the number of dice to be shown. It sends out a global key command, ALT CTRL R (for Roll), that gets picked up by any piece with a Position_of_die between 1 and 5. (This part seems to work fine. If, for example, I change the ALT CTRL R global key command definition to affect only dice with Position_of_die values between 1 and 3, only the first three die images are affected by later commands).

I plan to put the die images in layers and have the layers tied to the results of the Java dice roller or the ShadowDice roller (haven’t gotten far enough to decide). I want to control visibility of each individual die by defining their Basic piece image as a transparent .PNG, so that when layers are turned off, the die is not visible (for the sake of this test module, though, I made them a black square so they could be seen for testing purposes).

I put a Trigger Action in the Basic Die prototype that turns the global key command ALT CTRL R into a key command ALT CTRL S (for Show/Hide) that activates/deactivates the layers for each individual die. I have a conditional in this Trigger Action which states that an ALT CTRL S should be triggered by ALT CTRL R ONLY when the Number_Pressed global property is greater than Position_of_die, which is an individual piece marker.

What I’m trying to accomplish is this. All dice start visible in my module (in the testing module, they all start with layers off, but I don’t think it matters for purposes of this discussion). I also assume that after each dice roll, between 1 and 5 dice will be visible until the next roll. So when I process the next roll, I want to hide (by turning layers off) each die image that will NOT be used. In other words, for any die whose position is greater than the number of dice the user wants to roll for the next roll, I want to toggle layer activation if two things are true:

(1) the layer is active, meaning that die starts visible before the roll and therefore needs to be hidden (for example, Basic_Die_Active = true)


(2) Number_Pressed < Position_of_die
So, if the user presses 3 to roll three dice, I want the fourth (3 < 4) and fifth (3 < 5) dice to be triggered by the Trigger Action, turning the ALT CTRL R into an ALT CTRL S and activating/deactivating the layer.

That’s where I’m going with this. Problem is, I can’t even get half of this conditional argument to work.

In the attached test module, I’m not even checking for visibility yet. I’m just trying to get the layers toggled on the correct dice. In the Trigger Action of the prototype for the dice (to read the ALT CTRL R, or that the dice were rolled, and turn that into ALT CTRL S to show/hide layers for the affected dice), I have the conditional argument Number_Pressed < Position_of_die. What I’m hoping is that each die will run the conditional, and for those whose position is greater than Number_Pressed, its layers will be activated/deactivated.

The problem is that ALL the die pieces think the conditional is being met and are toggling layers, not just the ones with Number_Pressed < Position_of_die. The debug script shows the right values for each die and Number_Pressed value, but it runs the Trigger Action anyway.

I cannot figure out why this conditional is triggering for ALL the die pieces and not just some. I added in debugging Report Actions to show me the values as I go, and the values seem to be correct the entire way. So the issue is with the conditional being met and triggering the Trigger Action when it should not.

As part of the debugging action, I changed the ALT CTRL R Global Key Command to affect only die positions 1 and 2. Both of these dice report (through a Report Action) that they are receiving the ALT CTRL R, and dice 3, 4, and 5 do not. So that works, and these two dice appear to be the only ones selected.

Then, to continue that debugging action, I choose Number_Pressed of 3. The two affeced dice should run the conditional (Number_Pressed < Position_of_die) as (3 < 1) and (3 < 2) respectively. So the conditional should be FALSE for EVERY piece that gets the ALT CTRL R keypress in the first place and the Trigger Action should NEVER activate for any piece. But it still does. So the problem again appears to be with the conditional, and not with my selection of game pieces.

Trying to brainstorm about what the issue is, I realize that, in the conditional, I’m comparing a Global Property to a Marker of a Game Piece. Is this the problem?

Is it a bug? Am I making a conditional that’s not allowed or am I not phrasing the conditional correctly? (I’ve tried enclosing both variables in $…$ and it makes no difference.) Is there an error in my code? I’ve typed it twice from scratch and the probem reproduced both times I wrote the code.

The attached code is about as simple and distilled as I could make it to illustrate the problem. I know this is a lot to ask, but I hope someone might be able to look at this and run through it and see what the problem is, because otherwise I’m stuck. The module should spit out some debugging info into the log window to let whoever looks through this know what’s happening as it works.

Swap the marker for a DP and make it numeric. Also your PME in the trigger
is incorrect, you cant compare this way. I’ll fix it for you tomorrow and
post corrected mod tomorrow unless someone else explains/does likewise
before then so I don’t have to go in to all the technical mumbo jumbo - bit
late here :slight_smile:

Post generated using Mail2Forum (

Thanks. IIRC, you’re the one who made the dice roller that gave me the inspiration for this, so having you help me out is even better than I was expecting. I’m glad to have someone who knows Vassal like you do and is so willing to help people like me.

I was afraid of that. I was really hoping that wasn’t the case. But I felt like that (an invalid way of defining the trigger) was the only possible source of my issue. It seems on some level like you should be able to (by querying for a value of a marker variable and querying for a value of a global property, resolving them down to two numeric values, and comparing them regardless of where the values came from), but I understand the reality is that what we “should” be able to do is just what’s programmed in Vassal- no more, no less.

At some point I would be interested to hear what exactly can be put in a trigger argument. The Report Action can access both values and report them to the text screen. And the Trigger Action examples in the documentation all use Marker values (as best as I can recall) to make their arguments. Is it a case of the Trigger Action conditional not being able to “access” or “see” the value of a Marker or a Global Property, or is it just that the conditional can’t compare a Marker value to a Global Property value (even though both are integers)? I only ask because I’d like to avoid this situation in the future as I plan out more code. Do I need to avoid Marker references in Trigger Action conditionals (such as hitpoints > 5), or Global Property references? Or is it just that I can’t put BOTH in a conditional at the same time?

I think I understand what you’re saying. I’ll wait until I see your post of the fix, though. Thanks again.

Here is the updated demo mod.

The dice will automatically show/hide depending on the button you push.
I went a little further per your original explanation and replaced the show/hide counter with a roll counter that will roll the shown dice via right click (could do action button to if you wanted - either way will work)

Ive taken out all the reporting/test stuff but you can always just throw it back in to follow if you need it. From this should be able to adjust to suit

What you can’t do with standard vassal properties is evaluate/compare them against each other.
If you wanted to compare a property ‘Hitpoints’ with a property ‘Damage’ to see if a piece was eliminated, to get around the direct comparison issue what you would normally do is add a third placeholder Dynamic Property or GP and run a trigger routine that would first set the placeholder to the value of $hitpoints$ and then increment the placeholder by -$damage$, then you evaluate the placeholder to see if it is < 0 (eliminated) etc…

Usually doing this type of sequence youll also need to have a reset for the placeholder if you refer to it often so that the values it uses are always correct

Hi Tim,

Actually, there is no reason why:

Damage > $HitPoints$

should not work perfectly.

It turns out there is a bug in the Property Expression evaluator that is not correctly evaluating the value of the second property. A 2 line program fix and you can happily compare any two properties with each other!

Joel, Rodney, I have commited a fix to for this bug into swampwallaby-merge@3063 - this will be a good one to get into the 3.1 beta.


Messages mailing list …

Post generated using Mail2Forum (

swampwallaby-merge@3064 also - neater and more efficient than my first version.

Messages mailing list …

Post generated using Mail2Forum (

Thus spake “Brent Easton”:

Meged to trunk@3065.


Messages mailing list …

Post generated using Mail2Forum (

Excellent - Will help eliminate the need to do a lot of unnecessary variable passing!

Thanks Brent :slight_smile:

I can attest that this is working now for my Snit’s Revenge module, thanks Brent!

Can someone explain when to use the $property$ in place of just ‘property’ in a property expression?? I can’t find this in the documentation.

For example if I roll 3d6 and compare the result against the ‘speed’ property:

speed < 3d6_result … fails
$speed$ < 3d6_result … fails
speed < $3d6_result$ …works!!
$speed$ < $3d6_result$ …fails

I would be grateful for this illumination! Cheers, jas…

Found the answer myself:

Thanks, Brent for this great explanation. Sorry for wasted bandwidth! jas…