Expression for a Restrict Command

Hi all; :raised_hand:
My latest problem is I have 9 Pieces which have the same Layer shared through a Protype Definition. I am attempting to apply a Restrict command so that only one of the Pieces will have a particular Level (StockerMG) displayed at the one time. There is only supposed to be one of the piece represented by these Levels in the game ( if that makes sense).

It can also only be available when there is a particular version of B-17 in play. So I tried the following Expressions for the Restrict Command

{MissionChart !=5 || Count(“{GetMapProperty(StockerMG_Level == 2,"Main Map")}”) > 1}


{MissionChart !=5 || Count(“{GetMapProperty(StockerMG_Level,"Main Map" == 2)}”) > 1}

The first part of the Expression works but not the second.

What I want it to say is;

If the YB-40 is not displayed OR The number of Pieces in the game that has the StockerMG Level of 2 is greater than one, the Restriction will be applied. Is this the correct expression or is there another way. I can’t add a module link with instructions at the moment because Windows or something has installed a stupid “Snip” tool which is interfering with how I do my screenshots and now I have to go get some sleep.


Ok, So you can download the module and Savegame and right click on the MG icons as shown in the pic…

the Ammo Stacker Level is supposed to appear but it is not. Once it appears the Ammo Stacker option is supposed to be disabled - not before. The Expression and Restrict command are here…

Hope that makes sense and thank you as always for your help. I am running late seriously need to get some sleep.


The syntax on these expressions is wrong and you don’t need GetMapProperty at all for what you are trying to achieve here.

{MissionChart !=5 || Count(“{StockerMG_Level == 2}",“Main Map”) > 1}

Have you tried using the Expression Builder? It is especially useful with things like Count() where the syntax can get quite convoluted. (Calculator icon to the right of the expression input field).

Finally, when you copy expressions over to a post like this, I recommended enclosing it as code (select the expression and press this button at the top of the posting window:
It’s a good habit because some characters can be stripped out otherwise, though not in this case.

Hope this helps.

1 Like

Can you expand on this?

I’m not following what you want to achieve. Describe it is terms of the Game Mechanic you are trying to implement, not in terms of pieces and levels. e.g. How is it implemented in the physical game?

There may be a better, or easier to implement way of doing this, but it is hard to tell exactly what you need to do.

It surely does, thank you very much for this. I can see now that Count(expr, map) is all that was needed and this is where I get stuck with Expressions - the where and how to start. I had to change it to …

{MissionChart != 5 || Count("{StockerMG_Level == 2}","Main Map") == 1}

…because the > I was using meant there were 2 Ammo Stockers displayed before the Restrict command worked and I wanted a limit of one but that was my fault as usual.

Yes and I made both of those expression I posted with it. They got the Green Tick. When I copied your Expression from here into the builder it showed a red cross but was OK when I reproduced yours from scratch using the Builder. Possibly because of what you said about not using the </>?

This is great I can soldier on now, much obliged!


1 Like

Hello Brent;
My apologies once again, time got away from me last night and a Microsoft update was causing me some grief so this post was rushed out while it was still in my head. I am not sure however if I can improve on my previous comments ( in the physical game? :grimacing:) but will try.

There are 9 Pieces that share a layer called StockerMG through a Prototype Definition. There is one Level in the layer which represents an Ammo Stocker Game Piece. When the Ammo Stocker Level is shown on one of the pieces I wanted to use A Restrict Command to prevent the level from appearing on the other 8 Pieces, limiting the availability to one at any one time. The Expression I needed was for the Restrict Trait and Mark has come to the rescue. :+1:

I had previously provided a download for the Module and a savegame as well as the location of the Restrict Command yesterday. If there is another, better way I of limiting the Layers to one Piece at a time I am always grateful for suggestions.