Trigger Action doesn't trigger

Can someone look at this and figure out why Replace with Other never fires from the Trigger Action?

Hi;
I am definitely not an expert but where is the Global Property situated that you are referencing with VG2Stamina==0 ? If it is at Module level it should work OK, if the GP is Map level and the Piece is on that same map it should be Ok or if Zone Level it needs to be in that same Zone. Otherwise you might have to use the Get Property function instead. My 2c anyway.

Regards;
Darren

The double equal-sign == is BeanShell syntax, so you need to enclose that expression in curly braces {} to tell VASSAL you’re using BeanShell: {VG2Stamina == 0}. Alternatively, you can use the old-style syntax by simply removing one equals sign: VG2Stamina = 0.

(No, you don’t need to add those spaces, I just find expressions much easier to read with some spaces in them.)

P.S. If you click on the Expression Calculator button on the right of the field, it will automatically convert to BeanShell, and show a green checkmark if the Expression is valid (or a red X if it isn’t).

2 Likes

Ah of course!

It is set at the module level. I encased in beanshell brackets and it still doesn’t work. Ideas?

The simplest explanation would be that VG2Stamina is not in fact equal to 0. Do you have another way of confirming that it is? You can throw in extra Report Action traits for testing to print its value to the log, or make another Text Label.

EDIT: Looked at wrong images. Value is 0 as shown by Text Label trait.

Ok, now you’ve totally confused me. The value of VG2Stamina displays on the piece, when it equals 0 the TA should fire. How is 0 not equal to 0?

My apologies. Missed it in the one image. Are either of Shift+C or Ctrl+A doing anything to make the value become something other than 0? I don’t see that Shift+C is actually doing anything on the VG2 Stamina Box piece that has the Trigger, nor do I see it coming from a Global Key Command originating on a different piece.

Sorry I probably should have included this earlier. The Global Property is manipulated by other pieces on the board that use those key commands. The piece that displays does not. They are not Global Key Commands. Is that an issue?



Hi,

Just to understand: Your trigger action Ctrl-T on piece VG Stamina Box sends the key Ctrl-R, which, as far as I can tell is a Replace trait.

The same trigger action also listens for the keys Ctrl-A and Shift-C

Another piece VG2 1st Qtr Player Box also listens for Ctrl-A and does two Increment actions on the global property VG2Stamina based on some expressions. Are these two expression mutually exclusive? If so, could they not be combined into a single expression? E.g, if you have now

Cltr-A => {condition == 1 ? 1 : 0}
Ctrl-A => {condition == 2 ? 2 : 0}

to

Cltr-A => {condition == 1 ? 1 : condition == 2 : 2 : 0}

The piece VG2 Rebounds also listens for Shift-C which decrements the global property VG2Stamina by 1.

Finally, the piece VG2 Fouls Box also listens for Shift-C and also decrements the global property VG2Stamina by 1.

So how are these pieces supposed to work together? Are they all suppose to fire more or less at the same time? If, so, there might be race-conditions.

Instead of using a Replace trait, could it make more sense to use a Layer that follows the global property (or perhaps dynamic or calculated property) VG2Stamina?

What is the initial value of VG2Stamina, and how do you define that global property?

You could try to add Report traits to the keys Ctrl-T, Ctrl-A, and Shift-C, and perhaps Ctrl-R. You could also add another trigger trait that fires when VG2Stamina != 0 - just to see if something is reported.

I like to make Report traits with a report expression a la

{MyDebug?("!Hello, I'm debugging "+VG2Stamina):""}

and then define the user preference MyDebug so that I can easily toggle on and off debug messages.

Yours,
Christian

If you are familiar with Statis Pro Basketball (the original base 8 version) this is a vassal version of that. The players are assigned stamina ratings that are input to a piece on the scoresheet by the user. The 3 things that affect (read reduce) stamina are fouls, rebounds and shot attempts. If the players stamina reduces to zero his effectiveness both on offense and defense are reduced greatly. So, as the game goes on and you register those stats on the scoresheet the ‘display piece’ steps down each time. The replace piece is a marker that at this moment is just a solid red block (that will change later) that should pop up and serve as a visual marker to remind the user “this guy is used up”. I guess I could make it a layer but I don’t want it to fire by mistake and I’m not sure how I would go about setting it up to fire automatically. (Maybe a named command?)

The Trigger Action on the VG2 Stamina Box piece cannot execute if the VG2Stamina value is set to 0 by a different piece employing the Shift+C or Ctrl+A keystrokes.

Many different pieces can adjust the same Global Property, that part is fine–but if the earlier pictured VG2 Rebounds piece uses either of these Shift+C / Ctrl+A keystrokes to set VG2Stamina to 0, that doesn’t mean the Trigger in VG2 Stamina Box will go off. One of the keystrokes it’s listening for has to execute on the VG2 Stamina Box piece–not elsewhere. Does that help?

2 Likes

I’m not, but it’s not that relevant.

I guess this means that you have a number of “buttons” (pieces) on the score sheet, and these are meant to increase and decrease the stamina rating of another, player, piece. Is that correct?

I guess this is why you have three buttons for that then, and why these should reduce the stamina of the player piece.

The “display piece” is not exactly the player piece then, is that correct?

Some questions:

  • Is the stamina rating fixed or at least has a maximum value?
  • Is the stamina rating per “player” or global to all? If specific per player, is there a maximum number of players?

I ask, because it seems to me that each player will have its own stamina, and so the stamina should be a property of the player, not the module. Here’s how I see that you may accomplish something like this.

  • Your display piece has a Layer trait with as many layers as you can have in stamina plus one for “0”.
    • The Layer trait follows a [DynamicProperty]
      (VASSAL Reference Manual) of the piece - say Stamina
      • Make sure that it cannot wrap around
    • You can define one action that allows the user to set the initial Stamina value.
      • Make sure an appropriate range is set.
      • You can add a RestrictCommand trait to only allow that action to fire during a set-up phase or the like
    • The display piece a Mark property with the name PlayerNo and a specific value.
    • If the Stamina value should be reset at some point in the game, e.g. in the next quarter, then you may need to trampoline the initial setting command.
      • Make trigger that first calls the DynamicProperty command to set the property
      • Then it should fire another DynamicProperty - say InitialStamina which will take the current value of the Stamina property and store it.
    • The Layer and DynamicProperty part should of course be in a StaminaState prototype.
  • The foul, rebound, and shot pieces all uses the prototype StaminaDecrementer.
    • Concrete instances of the these pieces defines the Mark property TargetNo, and sets it to a specific player
  • The StaminaDecrementer prototype has te SetPieceProperty trait to decrement the Stamina property of a display piece.
    • This trait selects a piece by {PlayerNo==TargetNo}
    • Here, TargetNo is the value of a Mark trait set on the specific foul, rebound, and shot pieces.
    • The SetPieceProperty trait is triggered by a named command, say decrementStamina
    • The named command is triggered by an ActionButton or similar.
    • SetPieceProperty must be configured to not override the DynamicProperty value range, wrapping, etc.

Suppose you have 5 players on each side. Then you make five display pieces with PlayerNo 1 to 5.
Then, for each player you make one foul, rebound, and shot piece, each with their TargetNo set to the corresponding players PlayerNo value (1 to 5).

So what happens.

  • In the start up phase, a user clicks the display button and is prompted to input a Stamina value. This sets the initial value of the DynamicProperty to that value, and the appropriate layer is shown to the user.
  • Then you progress the phase and the Stamina value is locked for user input.
  • When a player makes a foul, does a rebound, or takes a shot, the user clicks the corresponding button.
    • This then fires the SetPieceProperty trait (in the DecrementStamina prototype) which will decrement the Stamina dynamic property in the display piece that has PlayerNo==TargetNo.
    • The layer trait picks up the change and display the appropriate piece image.

That’s my 2¢

Named commands are for internal use in the module, and should therefore be preferred for automatic actions. Named commands will only be executed by the module, never directly by the user.

Yours,
Christian

1 Like

Yes, unfortunately lol

Yes, it is a separate piece. the actual player pieces are on a separate board

It isn’t fixed. It can vary greatly from player to player. The lowest I’ve personally seen is 5 the highest around 40. It may go higher on some as I have only a couple seasons of player cards. The rosters are fairly uniform at about 12 players per team.

This would be easier to use a zone highlighter instead

Hi,

How would a ZoneHighlihter help you? It overlays a zone - not a piece - based on the name of that zone. There’s nothing particularly dynamic about that, or maybe I misunderstood something.

Yours,
Christian

I only need it for a visual reminder for the user so if I just make a zone and set it to the global property value, boom.