[messages] [Module Design] Strange behaviour from a Trigger Action - please help.

shilinski stan at hilinski.net
Wed Jan 3 03:01:29 CET 2018

Trigger actions are the most wonderful things in Vassal because we can
create small, discrete commands, bundle them into one package, and
execute the lot with one keystroke. The trouble is triggers don't always
work as expected. I can test my small, discrete commands one at a time,
and they work perfectly, but when I put them into a trigger, I often end
up in a what-the-hell?! moment. I've wasted HOURS debugging them. (I'm
writing a longer explanation for anyone who stumbles upon this thread
after wasting hours fooling with a trigger.)

I think any reasonable person would expect a trigger, which invokes a
list of commands in order, to do the first command to completion, then
the second one, and so forth. Well, this is NOT what it does, especially
when it involves commands that move pieces. Here's an example.

I have a command that shifts all pieces on the map 200 pixels to the
left (shiftLeft).
I have a second command that looks for any pieces at region R0 and flips
them over (flipR0).

I put them into a trigger to invoke shiftLeft followed by flipR0
expecting the flip at R0 to happen after all pieces have shifted. I
would be wrong.

What happens is a trigger won't update a piece's movement state until
the trigger completely finishes. CurrentLocation, CurrentX, CurrentY and
probably others do NOT update after a piece moves--in my case after
shiftLeft, so when I do flipR0, I am only flipping over pieces that
STARTED at R0, not any that finished there.

So writing a command that depends on the state left by the previous
command is very suspect. In your case, you wanted to move (shift) an
airplane two hexes NE, but the trigger put it in some bizarre space. I
have no idea what happened there. I know triggers don't respect a pieces
state with moves; I don't know what it does to other commands like
rotate and mask.

I tinkered some more with your module. (I recently fought with my own
triggers, and yours was small so I could test things easier.) I found if
I didn't put more than one command in a trigger that moves pieces, then
I could get it to work. It meant I couldn't put "move, move, rotate" in
a trigger. It had to be "move 2, rotate." You seem to have discovered
this yourself. 

This is one nasty bug.

Read this topic online here:

More information about the messages mailing list