Help with variable range display

Hi everyone

I’m trying creat a module and need some help

I want to display the recon range of a naval task force based on the range of the type of aircraft that is in the task force at the time. I used a dynamic property and trigger combo to display the recon range of the task force. That part works as long as the range is always the same. The part I can’t figure out is how to adjust that range if a different type of aircraft is selected from a list of available types.

Any thoughts?

Thanks!

Hi @clestochi, It’s difficult to advise without more specifics about exactly how you have implemented this functionality.

How are you currently displaying the range? Via an Area of Effect (showing a shading of the range) or by displaying the range number somewhere?

How do you select ‘a different type of aircraft is selected from a list of available types’?

What is the range calculation? Is it simply a number dependent on the aircraft selected?

Regards.

I’m currently displaying the range for a task force by using a trigger action trait which displays a set range along with an area of affect trait to show how many hexes are within range of the task force.

Expanding along those lines, I’d like to be able to adjust what is currently a set range to be variable with the range depending on the type of aircraft available to the task force. For instance, the task force may have several types of aircraft available, each with their own maximum range. If the player chooses aircraft X then the recon range of the task force would be changed to the range of that aircraft.

I tried to use a dynamic property trait to allow the player to select a type of aircraft from a list. While each aircraft type has a set maximum range, I couldn’t work out how go from aircraft selection to a change in the TF range. - if that makes any sense.

From reading your last post, I think you could have the following traits executing in order:-

  1. Dynamic Property with user prompt to select aircraft type
  2. Dynamic Property that automatically converts aircraft type to a range (see below).
  3. Area of Effect trait using the range property. The property is entered into the trait like AoEradius in the example below (ignore map shading, that can be unchecked)

If these traits are fired by the same Key Command then they need to be listed in reverse order on the piece / prototype. All this is on a Task Force counter; if the game had separate counters for the different types aircraft you might do this from those counters rather than prompting the user.

For step 2, in the example, to convert from the user input to AoEradius, you can use Beanshell in the target property in a “set value directly” field, something like this…

{ aircraft_type == “best” ? 5 : aircraft_type == “not too bad” ? 4 : aircraft_type == “not_the_worst” ? 3 : 2}

OR you can simplify the expression if you first define a set of Global Properties to map the values e.g. aircraft_best set to 5, aircraft_not too bad set to 4 etc.
Then the example would be: {GetProperty("aircraft_"+aircraft_type)}

Does any of this chime with your problem, @clestochi ?

I’ll try it out. The steps you described follow what I was trying to do. I got hung up on how to implement Step 2 above. The Beanshell property was the part I was missing. I’ll have a go at it this evening and let you know how it turns out.

Thanks!

1 Like

Well I tried to set it up. but it didn’t work. I think your approach is correct but my implementation/syntax isn’t. Here are some screen shots.
1. TF Traits



The first shows the TF counter traits I’m using.
The second shows th dynamic property for aircraft type
The third shows the dynamic property to set the range. I only used one aircraft type just to see if it would work - it didn’t.

Any feedback appreciated.

The Beanshell looks ok to me.

A Min value of “4” … how does that work when you try a set a value of “2”.

I don’t see a Trigger, so I am guessing you aren’t actually executing on aircraft_range… if that might be the case - try moving aircraft_range Dynamic Property to sit above aircraft_type and change its key command to match (i.e. Ctrl+O rather than “aircraft_range”).

How are you determining whether it works or not? How are you using the result in the prototypes, Layer or Invisible traits?

The Min value of 4 was the range o the least worst aircraft. I guess I didn’t need to do that so i changed it to match the initial value of 1. I also re-ordered the traits as you suggested and expanded the Beanshell to include all types of aircraft. It still didn’t work.

When I put this together I started with the Trigger action to turn on the range and use the area of affect trait to display the range in hexes. That function worked when I had the range set to a single number. The next evolution was of the effort was to introduce the the traits to allow selection of various aircraft with different ranges. That part still doesn’t work.

The way I test it is by saving the edited module then drag a TF counter on to the map and run through the commands. It appears to be trying to trigger the display of range as designed but only highlights the hex the counter is in.

As for the invisible traits I’m using them to keep the TF hidden from the other player until it is detected and then the owning player unmasks it. That seems to work fine.

I’m including screenshots of the latest version of the traits/properties to see if you can see anything wrong. I appreciate the feedback and help!




D. Prototype Recon Aircraft Range Shading

1st question: Does your test piece have an image? If there’s no image, the AoE won’t show, either.

I just duplicated your setup as far as possible (based on the images you provided), and the only time the AoE didn’t work was when I didn’t have an image assigned to the piece. You must have a typo somewhere, but it’s not obvious where…

Where are dragging the “TF counter” from? If it’s a counter that already exists on a map somewhere, any changes you made won’t take effect unless you completely reload the module from scratch, or perform a Refresh Counters from the Tools menu. I strongly recommend performing Refresh Counters after you make any changes in the module before testing…

I do have a TF counter image. I saved the module, closed, and reopened it. I pulled the TF counter from the game piece palette onto the map. From that point I tried it out. I’ve attached two images of the results. The first is of that counter on the map just before I select the type of recon aircraft. The second image is taken after aircraft selection has been made and the aircraft range is on. Note, that it appears that the range shading is On, but at a radius of zero. This leads me to believe there is a typo somewhere. Maybe in the BeanShell expression as I am just becoming familiar with the syntax?

F.  TF Counter image before aircraft selection
G.  TF Counter after aircraft slected and range radius turned on

Without seeing the whole module, my best guess is that there’s a typo in the BeanShell code for the aircraft_range Dynamic Property. Can you paste it here (put it between back-ticks (`) so the forum doesn’t process it)?

Sure thing, thanks for look at this.

{aircraft_type == “F1M" ? 4 : aircraft_type == “A5M4" ? 5 : aircraft_type == “E8N" ? 5 : aircraft_type == “B4Y1” ? 6 : 2}

Please edit your response and replace the single quotes (’) with back-ticks (`, this is normally on the key to the left of the “1” key).

ok, I think I edited correctly. Never used that key before!

As I suspected, you have some funky double-quotes in your string. I’m guessing you copied-and-pasted from Mark’s previous post, and because he didn’t enclose it in back-ticks, the forum replaced the proper double-quotes with “smart quotes”, which BeanShell has no idea what to do with. This is what you want: {aircraft_type == "F1M" ? 4 : aircraft_type == "A5M4" ? 5 : aircraft_type == "E8N" ? 5 : aircraft_type == "B4Y1" ? 6 : 2}

2 Likes

Well that did it. It works now! Thanks you.

You are right, I did copy his post. In the future, when I build BeanShell expressions do I still use the " " on the keyboard or a different key. Or are you saying that by not enclosing the part I copied with that `` tick the forum converts the " " to something else? I guess I am not following what makes it a smart quote.

You need to use the double-quote on the keyboard. The forum software likes to convert quotes to fancier opening quotes and closing quotes (if you don’t protect it by enclosing it in back-ticks), because they look nicer, but VASSAL has no clue what those fancy quotes are supposed to be if you paste them in.

1 Like

Got it. Thank you and everybody who helped me with this. It’s greatly appreciated.

2 Likes

Well spotted! This problem is quite common, I think … e.g. on MacOS the double quote key is converted to “smart quotes” by other software. I had to disable the feature in Notes and TextEdit.