Make VASSAL do something when pieces stack

I’m trying to create a chess module that records moves in chess notation. I want to log it as $pieceName$x$location$ and remove the piece that was originally there. What I can’t figure out is how to trigger that. I have experience coding JavaScript, so I should be able to understand Java if I need to.

Set a delete trait on all pieces. (probably you have done this already)
On Main Map, trigger a key command on all pieces on movement ending. ex. Ctrl-E
On all pieces add traits that do the following (use prototypes):
Trigger action that is triggered from the movement ending (Ctrl-E above) and does two things.
First is to write the piece name to a global property ex. testGP .
Second is to trigger a Global Key Command trait (with restricted and fixed range of 1). That will activate a new trigger action trait on all pieces in the same location.
Finally, set this new trigger to activate the delete trait of the piece if the $BasicName$!=$testGP$
You are done!

Andreas