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.

I am very interested in this thread.

I made some attempts and noticed that the proposed syntax {Prop1 + “Prop2”} works perfectly with dynamic properties, but not with global ones : a global property not found error is highlighted in the chat.

In defining the global property I used the exact same syntax that works with dynamic properties.

Maybe I made something wrong in the definition of the global property.

Someone can help, please.

Thank you. :smiley:

It should work just fine with Global Properties. Have you double-checked that you don’t have a case mismatch (red is different than Red, for example), or are you trying to access a Zone-level GP from a different Zone, or Map-level from a different Map?

If those all look correct, please post screenshots of your GP definition and the expression that’s failing to work, along with the error text.

Hello jrwatts,

thank you for the reply.

Here are the requested screenshots and the error log.

2024-03-28_075736

  • Bad Data in Module: Source: Property Expression=[{CD +“TargetHex”}], Property Name=DTargetHex]. Error: A PS 1 [Set Global Property] . Unable to locate Global Property in Current Zone/Current Map/Module… Turn on the Audit Trail preference to generate more details in the errorlog.

I noticed that the Property name is wrong, as it should be D0502, where 0502 is the correct TargetHex value.

Maybe this syntax is wrong.

Be well.

Panther_2010

I see two problems here:

  1. You can’t use an expression in the Name field of a Property; you need to create a separate property for each individual hex.
  2. In your Set Global Property trait, you are trying to add the value of the Property CD to the literal text “TargetHex” to determine the Property to modify; it looks like you actually want the values of 2 Properties, CD and TargetHex, which would be {CD + TargetHex}.

Hello jrwatts,

thanks for your help on this matter.

Of course, you are right : the syntax was wrong; I simply used the sintax used by pawnpusher that I found of this thread, that seems to work with dinamic properties. What I was trying to do is avoid to be forced to use a lot of Global Properties, one of each target hex. I believed that the definition of only one Global Property was sufficient, adding a Code to the Target Hex. I will try to use another approach to this problem.

Be well.

Panther_2010 :smile: