Applying a Restrict Command to a Zone

Hi all;
I am trying to prevent a layer “Spray Fire” from being applied in a particular Zone I have named “Forward Sector” The Zone has been marked on the Map board, the problem I think is how to tell this trait where the Zone is. Again, I believe it is my lack of knowledge with beanshell and if I can’t find some kind of tutorial on how to use it then I am wasting my time here
Regards;
Darren

The expression you want is {CurrentZone == "Forward Sector"}.

1 Like

For a full list of built-in Vassal Properties, such as CurrentZone, see the table at half way down this page in the Reference Manual.

Thanks but how do you learn how to put all these expressions together? Another thing I tried was to make the restriction apply for all above Y=578. 578 is approximately the position of the top turret so I wanted the restriction to apply to the area above that {CurrentY== < 578} or something?. I also tried your expression and it still doesn’t work so either the Zone is not working or I do not have the RC configured properly. Very frustrating.

Hell Mark yes I have that page bookmarked, a list of these terms is also found here…
Sample 3
but where can I found how to put all these together so they actually work?

Whew!! OK, I got the Y coordinate restriction to work. The correct expression should be {CurrentY <578} This took me 3 hours to work out [sigh]

You make a fair point that there is not a step-by-step tutorial for Vassal expression building. A Java tutorial will be overkill and likely hard for you to see the wood for the trees, as much of the context would not be relevant. That said, the information you needed can be found on the Expressions ref manual page. It may help you to work through the examples given in that table, at least down to the “Logical” section for now, you can skip “Substitution”.

Also, the Expression Builder offers a degree of help. For example, you will have noticed that it displays the red X when your expression is invalid and a green tick when it is valid (that doesn’t mean it does what you intend, of course, just that it is valid syntax!). You may also have noticed that Comparison operators section, which might have saved you the ==< error, at least, if you’d missed it from the reference manual:

There is a learning curve and I sympathise with your struggle to get past this early part of it. We’ve all been there at some point. You will accelerate in progress and productivity if you persevere.

1 Like

Hello Mark, Thanks for taking the time to help and being so patient with me. Since my last post I have been fiddling with that expression builder and came up with this…

Spray fire will ONLY be available if the counter is in Zone “Blue” (the outer blue band on the board) and if it is below Y axis 540. This will exclude 10:30, 12:00 and 1:30 on the board from being able to use SF which is what I was trying to do. I had to add the Zone as an extra condition because it was possible to enable Spray fire then move it to one of the forward positions.

Now I need to create some kind of pop-up that will explain why SF is not always available but that is for another day. I have a headache. :slightly_smiling_face:

1 Like

I think the reason that Zone did not work initially is that I had that particular Zone inside another. With my second attempt there was no overlap and it worked fine.

A minor tip, get in the habit of putting spaces around operators. You’ve done it with < but not with || or != ; the spaces will make your expressions more readable, especially for the more complicated ones.

Alert() is the function that will put up a popup; it’s the last item described on the Expressions table. If I want to use one, I would typically put it as the “catch-all” at the end of an expression in an Action Button loop, Trigger or one of value fields in a Property trait. I don’t think it’s advisable for a Restrict Command trait however, because the Alert will popup any time the context menu is activated whilst the AddSpray command is not valid.

You might consider:

(a) not worrying about it; by Disabling rather than Hiding the command you are at least alerting the user to the possibility of using the command, and hopefully they can work out what to do with it. This is a decent option if the use is obvious.

(b) Using a Mouse-Over component on the relevant map(s) that will target only the piece with the AddSpray command. You would configure it to detect the same condition as your Restrict Command trait, and display your advisory message.

Mouse-over is a component that you can add to any map. Here is one of mine that does similar to what I have suggested:

The key fields are “Summary text above pieces” and “Piece selection property filter”. It generates this text display when the user hovers over the piece:
image

I can’t get the mouse-over to function at all with this game and I set it up exactly the same as you have it. Never mind i will leave it as is I suppose.

Maybe to do with this setting in Preferences… if it is set to a long time, mouseover can appear not to activate:

Failing that, if you want to post a shot of your mouseover config here I’ll see if I can spot anything.

Hello Mark;
I got the mouse-over thing working again, the box for non-stacking pieces wasn’t checked. After all the work I did yesterday to get the restrict command working, I decided to scrap it because even though I had disabled the ability to add SF outside the Blue Area of the display and in the Front sector of the B-17, it was still possible to enable SF in the Blue Area and move it to the Front Sector. I tried for several hours to add a trigger which would return the marker to it’s original position if the marker was moved after Spray Fire was Active but was not successful.

I worked this out just now after searching the forum. The Trigger needs a command to activate it, movement on it’s own won’t work, so on the bottom of the Main Map properties: " Key Command to apply to all unit…" I added the command “MoveOnMap” then set the trigger as follows…

“Addspray” is the command to add Spray fire to the Piece. So now, if The Piece moves into the forward Sector with SF, or activates SF while in the forward Sector, it is returned to the original position (SendLocation). This took me all day and I only found the solution by chance on the forum. An obscure box in the Map Properties was the answer. There are too many things like this to remember.

Darren

Hello Mark;
I set the mouse-over exactly the same as you, and tested this on the Tail Gun only but nothing happens.

I have decided to add a visual explanation to the Map board rather than waste too many hours on it.

Thanks;
Darren

I got this to work as well, I was having trouble finding a PME that would be exclusive to all the counters that this Pop-Up needed to apply to and ONLY those pieces AND would actually work. I added a Basic Name trait, called it “Bomber MG” and added this to the protype for these pieces.

If you want to classify pieces with values that you can filter/identify them with later on, there are 2 good options.

For piece values that are static (will never be altered), use the Marker trait. For piece values that can change, use a Dynamic Property trait.

2 Likes

Yes that worked out good thanks for the info Joel

Darren