I’m trying to make a module for my friend to test out a battle system for their campaign. I’ve managed to get the actual pieces and board working, but I’m at a loss for how to accomplish my final goal. As my system is still early in testing, I want to keep the character stats editable by the player. Is there any way to create text that’s editable by the players during gameplay in a private window? I’m not savvy enough with Vassal yet to really know where to begin in this regard. Any help would be greatly appreciated!
The most basic way to approach this is to ensure the pieces have Dynamic Properties (to store and modify stats) and then one or more Text Labels that would display the values of those Dynamic Properties.
I’m sure it’s possible, but the hard part would be holding it still long enough. How many legs does a fly have anyway? Maybe use one of those sticky traps.
Thanks so much for responding! Would it be possible for me to have the label text start at 100, and then when a button is clicked, the player would get to type whatever they like? Would it have to be in hard coded increments? Like pushing button A increases the value and pushing button B decreases the value?
You can do any or all of that as commands within the Dynamic Property configuration–increment/decrement by fixed amounts, or allow a user to type in a specific value. From there, your Text Label just prints the value of the property. E.g., if your Dynamic Property is HitPoints, the content of the Text Label would be the expression {HitPoints}, and VASSAL will plug in whatever value that happens to be and update it as it changes.
Could all of that be done within Vassal, or would any of this require Javascript classes?
Everything I described is out of the box functionality right in the Editor with very little expertise required. Custom Java classes are the realm of truly advanced, bespoke functionality that very few users are equipped to attempt, let alone implement successfully.
Ok cool! Thanks so much for your help!
Give your unit (prototype) the Text Label trait, one for each factor you want to be able to adjust. For example, if your units have a combat factor (CF) and movement factor (MF), add traits a la
- Text Label
- Description:
Combat factor - Label text:
0 - Name format:
$pieceName$ - Menu command:
Change CF - Menu command:
Ctrl-C - Font:
Dialog - Font size: 12
- Text color:
0,0,0 - Background color:
Cancel - Vertical position and offset:
bottomand6 - Horizontal position and offset:
leftand6 - Vertical justification:
bottom - Horizontal justification:
left - Rotate text:
false - Property name:
CF
- Description:
- Text Label
- Description:
Movement factor - Label text:
0 - Name format:
$pieceName$ - Menu command:
Change MF - Menu command:
Ctrl-M - Font:
Dialog - Font size: 12
- Text color:
0,0,0 - Background color:
Cancel - Vertical position and offset:
bottomand6 - Horizontal position and offset:
rightand6 - Vertical justification:
bottom - Horizontal justification:
right - Rotate text:
false - Property name:
MF
- Description:
When a user selects the piece context menu items Change CF or Change MF, then the user is prompted to enter a new value for the factor.
Note that there’s no check on what kind of value is entered: The label will equally accept and display the number 10 and the string foo.
Note that you do not need Dynamic Properties to store the factors in - unless you perhaps want to inforce some constrains on the entered value.
To use Joel’s suggestion, you would have Dynamic Properties CF and MF a la
- Dynamic Property
- Description:
Combat factor - Property name:
CF - Initial value:
0 - Is numeric:
true - Minimum value:
0 - Maximum value:
40 - Wrap:
false - Key commands:
- Direct change:
- Menu command:
Change CF - Key command:
Ctrl-C - Type:
Prompt user - Prompt:
Enter new CF value
- Menu command:
- Direct change:
- Description:
- Text Label
- Description:
Combat factor display - Label text:
{CF} - Name format:
$pieceName$ - Menu command:
- Menu command:
- Font:
Dialog - Font size: 12
- Text color:
0,0,0 - Background color:
Cancel - Vertical position and offset:
bottomand6 - Horizontal position and offset:
leftand6 - Vertical justification:
bottom - Horizontal justification:
left - Rotate text:
false - Property name:
- Description:
and similar for MF.
Note, using a BeanShell expression for the Text Label Label text (e.g., {CF}) above has some overhead, because each time the piece needs to be redrawn - for example because the piece was moved, it came into view, or some other piece moved on top of it, and so on - the BeanShell expression will need to be evaluated, which can be a costly (in terms of execution speed) thing to do.
Both approaches have their pros and cons.
Note, when you save a game, the current values of the factors will be written down in the save file. You can then in principle extract these values from the save file, allowing you to record what your current best values of factors are. To do that, you could use pywargame - a Python module - which allows you to extract information from a save file.
Yours,
Christian