Using Properties in Triggers - Position / Detect Pieces

Hello, folks! I’m new to posting, but I have modified several modules and I’m currently creating a new one. In particular, I’m very interested in trying to “automate” sections of my new module by using right-click menu items, triggers, and menu buttons. On my current project, I’ve run into a rather difficult situation.

Scenario - I have several Zones on my game board that are square matrices (1 row x 4 columns, 4 rows x 1 column, 2R x 2C, etc.). During the game, Pieces are moved from a Deck to these Zones. Each Piece needs to sit unstacked in a different square of the matrix. This allows you to flip them independently, to always see their characteristics, to manipulate them independently, and to add easily-visible Markers to them independently. In addition, when a matrix is full, the Zone should not allow more Pieces to be added.

Present Situation - I have created Zones to cover each matrix, and I can send the Pieces from the Deck to the Zone without issue. However, they all stack in the center of the Zone rather than segregating to the individual squares of the board’s matrix. While I have a rectangular grid set up for each (with numbering), I have not proceeded further. In addition, I have not implemented a “Zone full” checking system yet, as this solution may depend on the solution for the previous item.

Possible Approaches - I had thought about assigning a Region to each square in a Zone and naming the Regions sequentially (block1, block2, block3, etc.), after which I would set up a Dynamic Marker or Global Property to store the number of the next Region to be filled. When a new Piece was to be added, I wanted to do something like:

LocationName=block$nextAvailableRegionNumber$

thereby allowing me to simply increment the number at the end of the Region name rather than creating a whole separate set of commands for block1, block2, block3, etc. This would allow me to recycle more of the code for all the Zones / Pieces. It also seemed easier / less cryptic than using grid numbering and storing the grid location somewhere, as the origin of this number wouldn’t be readily identifiable if displayed somewhere else during the game.

Questions:

  1. Is my proposal about the LocationName possible? Is my usage correct? Would a variation on this concept work? If not, is there a simple way to send each Piece to a unique square in the Zone?
  2. Is there a simple way to detect whether a Region (or for that matter, a grid location) is currently occupied?
  3. What would be the easiest way to block the addition of Pieces once all the squares have been filled? Would this require a Global Property / Dynamic Marker, or is there some property like “PiecePresent” or “LocationOccupied” that already exists (I didn’t see anything like this in the documentation)?

My apologies for the long post, and thanks for any help you can provide! I’ve been beating my head against a wall on this module project for what seems like months.

Setting up Region points the way you did is a good start.

What you probably want to do is set up a Global Property …let’s call it BlockSpot and make it numeric.

In the Map Windows properties, assign a hot key to the line “Key command to send to all units ending movement on this map”. Let’s make it CTRL A.

In a prototype for your pieces, give them a Send to Location trait that sends the piece to Region point

block$BlockSpot$

Also include a Set Global Property that fires on a CTRL A to increment BlockSpot by 1

This way every time a piece is moved to the board, it increases the BlockSpot by 1 and the next piece will get sent to the next block.

DrNostromo,

Hey, thanks for the great advice! I thought that I could “combine” constant portions (block) and variable portions ($BlockSpot$) of a property together, but I wasn’t sure. This may actually help me with an unrelated problem that I’m having…

One small point…in my situation, the matrices are each part of unique Zones on the Map. If I do as you say regarding the Map window hotkey, will firing the CTRL A affect all pieces in all of the Zones on that Map? Since I have to track each of the Zones independently of each other (I think that I forgot to say that explicitly in my previous post), I had thought that I would need a GP for each Zone to keep the data separate. Am I mistaken?

Also, does the key command that you mentioned apply only to units that did not start on the map but were moved to it, or does it apply also to units that are just moving between locations on the map?

I think that I may be misunderstanding the correct usage of your CTRL A hotkey example, so I don’t want to make assumptions.

Thanks for the quick response and any additional thoughts you may have!

Since you would be sending pieces to Region Points, you would need to create unique points. So, you could use block1, 2 etc for one zone and point1, 2, etc for another zone. You could still use only the one GP but you would have to find some way to reset it back to 1 before distributing pieces to the next zone.

The map window hotkey will ONLY fire at the piece that moves there. If you did want a key to fire all pieces, then you would use a Global Key Command somewhere to send a CTRL A to all pieces with the following properties:

CurrentMap = (map the pieces are on)

The command will fire whenever the piece is placed on the board. This would include moving it TO the board and moving it ON the board. However, you could give the piece a Dynamic Property called something like CountTrigger with an initial value of 0.

Then you could create a Trigger Action on the piece that will fire on the CTRL A if properties match

CountTrigger = 0

Have this Trigger Action fire off a CTRL B and CTRL C

CTRL B would adjust the Set Global Property to increment your region point count
CTRL C would adjust the Dynamic Property to 1. Since the CountTrigger no longer = 0, the CTRL A will no longer have any effect on the piece once it’s place on the board.

DrNostromo,

Aha…I think I see where you’re going with this now. The CTRL A key command would by default only affect the units whose position actually changed, not all the units on the board in question. Got it. For some reason, in my version of the documentation (and the on-line docs, I think), the description of this command is missing from the Map window explanation. The documentation stops after all the reporting items.

If I do this correctly, it seems that using separate GP for each Zone would allow me to track of the relative “fullness” of each Zone separately. That might prevent the need to constantly reset a GP that was tied to the Map or Module.

Thanks again for all your help. I’ll give this a try and see how it works!