Creating commands with names, not keystrokes

I’m attempting to attach functions/commands (behaviors) to game pieces. The problem is the limited namespace for these functions, since they can only be invoked by keystrokes.

First, imagine how easy it will be if TriggerAction can “perform function” for any arbitrary function name, not just keystrokes.

For each function, a gatekeeper ActionTrigger will decide whether to execute the function; the ActionTrigger will check a global property PARAM_STR_1 to see the function (function name) that is supposed to be executed. Eg, if PARAM_STR_1 = InfectCity, perform keystroke “whatever is assigned to that function”.

ActionTrigger can be the if-condition for an if-block. It will execute the if-block if its if-condition is true.

Say we’re now executing function InfectCity. Say its structure is like this (assume top-bottom Java-like execution order):

SetGlobalProperty SetGlobalProperty if (blah) { // level-1 if-block SetGlobalProperty if (innerblah) { SetGlobalProperty } // level-2 if-block if (innerbleeb) { SetGlobalProperty } // level-2 if-block } // level-1 if-block if (not blah) { // since there is no such thing as "else" here SetGlobalProperty } SetGlobalProperty SetGlobalProperty

Now, I’ll need some way to denote nesting level of blocks. In the above, there are 6 level-0 elements (4 SetGlobalProperty and 2 TriggerAction), all of which can be lumped as a single TriggerAction performance: InfectCity (assuming TriggerAction can perform function names). Further, there are 2 level-1 blocks, the first containing 2 inner level-2 blocks, and the other containing just 1 SetGlobalProperty command.

I can easily name the above blocks, for performance by TriggerAction(s), such:
Entire chunk (level 0): InfectCity
First level-1 block: InfectCity_L1a
Second level-1 block: InfectCity_L1b
First level-2 block: InfectCity_L2a
Second level-2 block: InfectCity_L2b

The possible numbers of functions and function complexity is near limitless, given the vastly expanded namespace for functions and their constituent blocks.

Now, for contrast, let’s assume we use keystrokes as namespace for functions and their constituent blocks.

Each game piece will have a map between FunctionName and Keystroke. Eg.
InfectCity → Ctrl+1
TreatInfection → Alt+1
BuildResearchStation → Ctl+Alt+1

Notice that I’m using pre-modifier keystrokes to denote different functions attached to a game piece. That limits me to just 4 or 5 functions per game piece! Why I can’t avoid such limitations will be evident below. Please read on.

For the 2 level 1 blocks, I must assign them keystrokes Ctrl+2 and Ctrl+3, respectively. That limits me to just 9 such blocks for the ENTIRE chunk of code! I’m reserving Ctrl+a to Ctrl+z for level 2 blocks.

For the 2 level 2 blocks, I must assign them keystrokes Ctrl+a and Ctrl+b, respectively. At least I can have 26 level 2 blocks throughout the ENTIRE chunk of code.

As for level 3 blocks? I may still eek out some more namespace from non-alphanumeric keys.

And we now see how pitifully limited the “keystroke” namespace is. Moreover, using the human brain to keep track of keystroke-to-chunk mapping can be deviously tedious.

Am I doing something wrong here? It seems even Java imported classes for game pieces will be limited to performing keystrokes, and not be able to perform function names.

This is fixed in Vassal 3.2. See https://forum.vassalengine.org/t/namedkeystroke-issues-and-questions/4331/1

Note to self. Please read forums more thoroughly, especially current development threads!