Referencing a property in another local/global property *name*

Example of what I’m thinking about doing (in psuedo-code).

SET (dynamic local property) Color = “Red”
SET Global Property $Color$OwnedWorlds
(an expression or two that leverages $Color$)

When I implemented this with hardcoded Global Property Names (e.g., RedOwnedWorlds) - it worked fine…

So questions…

  1. Can this be done?
  2. What would be the syntax for embedding a property-value in the name of another property?

I have had success with {Color + “OwnedWorlds”} as the syntax for a Global Property name where Color is the name of another property or Marker. So if Color’s value is “Red” then the expression evaluates to “RedOwnedWorlds”. If Color’s value is “Blue” then the expression evaluates to “BlueOwnedWorlds”.

I used this syntax in a Set Global Property trait in the box for the name of the Global Property to set.

Thanks! I will try that when I get a chance…

However, with the addition of Attachments which allows one piece to set another piece’s Dynamic Property I substituted keeping this kind of data as a Dynamic Property in a central piece for say the Red side. This allowed me to define the Dynamic Property once in a prototype for all the sides’ pieces keeping this data, and then use the Set Piece Property in another piece or pieces to modify the data as needed. Doing this saved me from having to define a bunch of Global Properties.

I’m working on a module for an 18xx game with around 54 entities (12 major companies, 31 minor companies, 6 players, and the bank) that may have money for use in the game. Before Attachments I set up 54 Global Properties to store the value of this money with a name format of {EntityAbbreviation+“Cash”}. With Attachments, I have a Dynamic Property named Cash in a CashBox Prototype for a cash display piece for the map windows for the players and the bank, and a Dynamic Property named Cash in a Charter Prototype for a charter piece for each of the major companies; and I will have a Dynamic Property named Cash in a Charter Prototype for a charter piece for each of the minor companies. So that’s 1 Dynamic Property in 3 Prototypes rather than 54 Global Properties.

I tried this, but couldn’t get it to work.

Doing some debugging, I found that even using a trivially simple expression in the Set Global Property Name wasn’t resolving…

Using the following trivial construct:
{“Purple” + “WorldSum”}

I get the following error message in chat log:

  • Bad Data in Module: Source: {“Purple” + “WorldSum”} Error: Expression evaluation error. See the errorlog for more details.
  • Bad Data in Module: Source: Property Expression=[{“Purple” + “WorldSum”}], Property Name=]. Error: (0 / 0) [Set Global Property] . Unable to locate Global Property in Current Zone/Current Map/Module… See the errorlog for more details.

Dump the beanshell braces { } when you specify the property name.

Beanshell Braces were needed…

I figured it out, it was my old enemy (bad eyesight). Computers are notoriously picky about exact wording for variable names :stuck_out_tongue:

Thanks for all the help!

1 Like

Could you have copy and pasted “smart” quotes along with the text from something like MS Word rather than type it all in including the quotes? If not, I’m scratching my head.

You are correct. Beanshell braces are necessary. My mistake.