Using Some Basic Beanshell in the DP Prompt User Text Area

A while ago I posted the following in: Dynamic Property - numeric - min/max values - Technical Support & Bugs - Vassal (vassalengine.org)

To reiterate that text:
I’ve tried using an expression in the prompt area of a DP (Prompt user to select from list). I’ve tried BasicName, $BasicName$, {$BasicName$}, {BasicName}, GetProperty(“BasicName”), the last also with enclosing $ and {}. No joy. I’m guessing that adding an expression to the prompt field of a DP is not possible. However, if it is possible, how to do so?
The reason I want to do this is I do need to identify which counter the DP Prompt applies to. The DP Prompt popup window would be fine if there was only 1 counter that triggered the event. However, there can be more than 1 counter triggering the DP.
I’m guessing that the DP Prompt text area is just that - no chance at all to add in a {something} (similar to the way you can use the ‘mouse over stack viewer’ in the text above field.

If you’re looking for input from the user (the Type field is set to either Prompt user or Prompt user to select from list), I believe the Prompt field is just for text that will be displayed, not for an expression whose result will be displayed. However, you can have multiple text prompts defined as long as each has its own Key Command, Named Command or Menu Command (I’m not sure if you can just have a Menu Command without a Key or Named Command). Then you would need multiple Trigger Actions to activate the correct prompt for the counter triggering the event via the Trigger when properties match field.

1 Like

What I have is the potential for aircraft with Naval Air factors flying missions into sea zones. They can stay there until they hit the 0 box. Some of these acft have extended range and, when used halves their naval air. I have set things up so that at each end of impulse and end of game turn for a popup window that states “aircraft still at sea”. The popup seeks a yes/no response. Said response then triggers other key commands. Trouble is, what flaming acft does the popup refer to when there are more than 1 at sea? Sea zones are across the world.
I need a way to positively identify which aircraft the popup refers to.
Thought here. Maybe an old zone/current zone change may do the actual popup trigger! I’ll have a look at that.
At days end though, been able to do a bean shell expression in the ‘prompt user’ text field of a DP would be better.

Maybe you could use a Trigger Action to execute an Alert (see: Using Alert()) to identify the counter needing the input and then seeking that input with the DP Prompt user.

Edit:
If your popup happens for each counter for which player input is needed, maybe you can add a Text Label to identify the counter.

Re the edit add in. The counters all have a BasicName, different for each counter.

Re using Alert(). That may work, need to experiment though. Trouble is, as I see it, there will then be 2 popups per counter.

I’ll keep plugging away. Who knows what may happen.

How about adding a new Layer trait that can be toggled that adds some sort of “highlight” to the piece, to help identify which one is in question? You could also add a Move Camera button to the map and trigger it with a Global Hotkey to center the map on the piece in question (you would need to copy the piece’s coordinates to Global Properties first for this to work, I think).

Maybe you could make the popup work with a small map window that is shown when your popup is triggered. This map window could have a text label displaying the identifying information about the counter causing the popup and another text label displaying the value of the DP for which you seek input.

I did something similar only it was to simulate the transfer of money in a financial game. Here is a stripped down module I used to test the concept and now use to illustrate it to others:

The map window that is shown similar to a popup is PayWidget. It’s in the Utility Windows folder. The Bank (also in the Utility Windows folder) and PlayerA windows have a Pay button on their toolbars that shows the PayWidget window. In the calling routine one of the DPs of the PayWidget piece has its value set to the name of the map from which the PayWidget map was “called.” This is displayed in a text label. Other information, the payee, amount of payment and item bought are also stored in DPs and shown via text labels. An action button overlapping these text labels triggers player input popups for these DPs. The Pay button in the bottom right executes the transaction per the DPs displayed and then hides the PayWidget window. The cancel button in the bottom left just hides the PayWidget window.

Solved. Added a few extra traits and a bunch of extra trigger key cmds.
1 GP to store the current unit’s BasicName
2 send to traits to move the current unit out of any stack it may be in and then move it back into the stack it just left.
1 KC to toggle a red lined box (transparent in the middle) to surround the current unit and repeat at the end to toggle that off.
All done on the extended range prototype. Yeehah.
Many thanks to all contributors.
PS - Also a move camera function triggered by the unit trigger trait (using BasicName==the GP) to move focus to the actual unit. Did need to use an X offset for the move camera function as the dialogue box covered the unit though.