Follow-Up to Grid Numbering Problems

Folks,

I’m still having serious issues with grid-related stuff:

http://www.vassalengine.org/forum/viewtopic.php?f=6&t=4595

and I’ve found something else that seems strange.

Whenever I try to trigger an event based on the movement of a piece along a track, the trigger does not fire until I LEAVE the grid location / region in question. It is as though the detection code does not run until I’m exiting the place named in the trigger. Is there a specific reason for this?

Also, when I start a new game and try to advance a counter from the beginning of a track, it doesn’t move on the first key press. The first key press appears to cause the detection code to run, thereby telling the piece where it actually sits, but doesn’t actually move it. When I set up a report to test this, it reports that the piece has entered the first location on the track. ??? On the second key press, the piece moves forward, as though the piece now has some idea of its location. When I try to reverse direction, the piece still moves one more space forward before it reverses direction, and the reports indicate this as well. ??? Is this normal?

More importantly, is there a way to tell the pieces to update their current location at the beginning of the game, that way they function normally right from the start? I’m having to do all kids of code yoga to get what would seem to be very simple results.

Thanks for any help! With all the weird things happening with grids, I’m ripping out my hair.

Hi,

It sounds to me like there is a bug in your module. It is next to impossible to diagnose these sort of problems based on a description of what is happening. Even with the module available, they are often so complex, that it is extremely difficult and time consuming to debug.

So, the recommended procedure is to try and recreate the problem you are having in a new, cut-down module with just one track and a couple of pieces and just the minimum traits you need to implement the behavior and illustrate the issue. That has 2 benefits:-

  1. You may well be able to diagnose the problem yourself once you simplify the situation to the simplest case. If it works in the simplest case, start adding your other layers of complexity in until it breaks.

  2. Isolating a bug into a simplified module will save many hours, if not days of our time when we try and debug the cause of the problem.

When you get to this point, post the simplified module, plus a log file illustrating the problem occurring including commentary of what you expected to happen.

Regards,
Brent.

Brent,

Ahem… :blush: :unamused:

I think I have figured out part of the problem. The reason that the counter was not moving immediately and was not reversing direction immediately was due to the placement of a Set GP trait. This GP sets the numerical suffix of the next Region name on that track (for example Track1, Track18, etc.). Since the GP was not be incrementing the suffix number BEFORE the move happened, the counter was seeing the track’s starting / current value, NOT the value of the Region to which it should move. I hope that made sense.

At the same time, I am still at a loss regarding my Triggers firing based on the location that a counter is LEAVING. This has been the case for me across multiple modules, new and old, so it appears to be part of the VASSAL code. Can someone tell me if VASSAL is designed to work this way all the time? If so, no problem, I’ll just figure that into my code. If VASSAL should be firing Triggers when a counter ENTERS a location, then I’ll keep looking for a reason why my modules don’t do this.

BTW, I’ve dumped all rect. grids from my modules at this point and am just using Irreg. Grids with named Regions. This allows me to name each Region and have better control over automation, even if I have to include more code. I’m not working with any modules that use maps made entirely of rectangular / hex grids right now anyway, so it’s not a show-stopping issue.

Thanks again for any help with this, and sorry for prematurely pulling the fire alarm. That’s what I get for programming when I have a cold!

I normally do something a bit different but similar. Most of the time a model has a prototype for most of it’s traits. So I rename the prototype trait with a 1 after it’s name so the original counter can no longer see it, and then create a new prototype and start copying each layer of functionality from Prototype1 to the new Prototype, checking at each step.

It all depends on exactly how you set it up and exactly what property expressions you are using and exactly what properties you are referencing. It is impossible to make any sort of sensible comment on your question without a close examination of your module.

Generally it fires a command every time a piece is moved in or out of an area (as long as you have set up the Map to send out that call), how you add logic to that trigger is very much up to you.

Brent,

Thank you for your patience. I understand that you cannot say definitively what’s happening without seeing my module, and I appreciate that you do not want to make any specific comments about my circumstance. I just wondered if VASSAL was coded with this behavior in all modules, as I had never been able to reproduce triggering upon entering an area. It appears that some modules can do this, which means that I’m doing something incorrect, which is fine. I’m no module-building expert by any means.

Ratty,

I’m assuming that “it” is VASSAL itself. That being the case, what trigger on the Map will fire when you move a piece INTO an area? Are you referring to an option in the Map Window dialog box? Can you point me to a dialog box or option somewhere? I’m not sure that I’m understanding your comment fully. Sorry–I don’t mean to be dense.

Both,

If either of you can point me to a module that detects pieces when they ENTER a Zone/Region/area, I could probably dig out the information I need. I just need an up-to-date module that definitely displays this behavior. Any example will do.

Thanks again for helping out a rookie.

If you go to the Map properties it’s the last option right at the bottom.

All the Players in my module use it to increase an internal counter when they enter the pitch area and reduce it when they leave it

vassalengine.org/wiki/Module … l#Comments

Although the topic was not quite the same, I recently posted an extremely small proof of concept module that demonstrates this. As Ratty said, everything hinges on the use of the Map window-level setting where you can specify a keystroke to be applied to all pieces ending movement on the map. That keystroke fires a Trigger on your piece, and the Trigger uses a property match expression to basically query if the piece is now in a certain zone and wasn’t previously (to avoid spurious activations of the Trigger from someone reorganizing pieces or moving things around in the zone).

Thread: Can you count pieces in a zone?

Ratty and Joel,

Thanks a million! I have been skirting the edges of this problem, looking for an answer since 3.0.x came out! Like I said, I have a work-around using triggers based on a Calculated Expression (essentially TriggerZone-1), but that seemed like a kluge. I knew there had to be a way to do this.

As for using the Map Details, I was too locked into thinking about hex maps with lots of counters that can move all over the place within one turn. I wasn’t thinking about using “Moved on Map” to trigger this type of event. I am assuming by “ending movement” you mean that a Piece is selected, moved either via mouse or keyboard, and then de-selected.

I’ll try this out and see if I can adapt it to my module. Thanks again!

Right, but “ending movement” on a map isn’t just confined to things that you move by hand–it also applies to pieces that land on a map from the result of a Send to Location (i.e., automated things you might be doing).

It doesn’t even need to be deselected… just end it’s move… so if you use forward, it will trigger as soon as a move moves it over the Zone threshold.

Moves caused by traits (Send to Location, Move Fixed Distance, Return to Deck, Pivot) will also trigger the map automove key.

Some times I wish you could test for Send to Location (IE if the Drop was caused by it), if your not careful you can get loops. Especially when you Send to Location as a response to entering a zone.