Using the Global Key Command Trait

I am working on a game feature where when a unit enters (Unit A) a zone it queries for other units (Unit B)in that zone and activates a feature on the second unit. So for that the Global Key Command Trait should be ideal.

I would think the matching properties field should read something like

LocationName==$LocationName$ or CurrentZone==$CurrentZone$ or any combination thereof.

In this, I am assuming that the first location name is the location name property of Unit B and $LocationName$ would be the value in the LocationName property of Unit A.

However, I don’t get such a result. Instead, the trait attempts to activate every Unit B in every possible zone.

So, is this a bug?

Otherwise, I’m going to have to create a property on unit b and copy CurrentZone into it.

I am using Vassal 3.2.8

I think the problem is your trying to reference a local property on a piece from a Global Key Command, which can’t be done. Instead, during the triggering process of Unit A, it should also send their location name to a Global Property, temporarily of course. Then that Global Property can be referenced for the Global Key Command.

I hope that helps.

reddeblu,

Thanks for your suggestion. That is how I was planning on working through it. However, why have a Global Command Key trait within a game piece, if that is how you have to execute it?

The Global Command Key at the module level is a great and existing feature that a developer could use by pushing all their check values to the global domain and then execute a Global Hotkey from within the game piece to invoke it. I would think having the trait within the game piece level would allow a developer to use local or game piece properties as a check. That is why I ask if it’s a bug or a feature. It appears to me to be a feature not fully developed. Perhaps it is the limitations of java. I just don’t know enough to determine how to proceed without asking.

Clicking on the help button shows an example of exactly what I’m trying to do, except for the range part. In the example, the game piece is checking all the units within range where the property nation = $nation$ (I assume as much as there is a cut-off in the display window)

I understand how the range property limits the radius, but that doesn’t work very well if you’re programming an area based movement game.

Okay, sorry let me try again, I think my head is more clearer now.

I think you can do this without a restricted range key command. Let’s see, Unit A moves into a zone, this should cause an ending movement key command from the map to trigger everything. To start we will need Unit A to store its current zone in a Global Property, I don’t think there’s anyway around this.

Next Unit A will fire a Global Key Command which applies to any unit in the same zone, using the Global Property for reference.

…Okay I think I understand your dilemma, if you skip the Global Property and try to reference the Local Property of Unit A’s location, it does not work right? Yeah, I just checked it myself and it seems Global Key Commands, no matter where they come from, are incapable of referencing local properties to be used as a comparison to another property.

I can see why this seems strange, I wonder myself now why a piece can launch a Global Key Command, as opposed to a Global Hotkey that launches a module level Global Key Command, when there doesn’t seem to be any difference between the two EXCEPT the restricted range option.

But there are actually quite a few odd cases like this in the many piece traits and their functions, like Place Marker and Replace With Other almost having the exact same functions, but one has a match current state option, and the other only has a match rotation option, which always puzzled me.

Okay I didn’t quite understand what was going on last time, but I do now better I think, been a little sick. Well I guess this odd issue is left up to the developers now and the future direction of vassals development. Anyway I hope you did get it to work, cheers.