Report displays variable name instead of a property value

This game has hidden movement, and dummy counters exist. I want to report when a counter disappears and appears on the map, and this can easily be achieved with a report expression like
$PieceName$ has disappeared at $location$

However, because the dummy counters need to look like normal counters, I have put an appropriate string in a marker property called DisplayName, and non-dummy counters simply have $PieceName$ in the DisplayName.

However the report expression
$DisplayName$ has disappeared at $location$
shows
DisplayName has disappeared at 0705

How can I get the report expression to show the value of DisplayName instead of the name?

Rather than use a Marker trait to contain the DisplayName, try using a Dynamic Property.

1 Like

It’s not clear to me if you are referencing the auto-report formats that you set in a map’s config, or the contents of a Report Action piece trait. Can you supply screenshots of which things you’ve configured?

For instance, I don’t believe you can get user-defined piece properties to appear in the reports generated by the multiple “Auto-report format for…” lines in a map’s configuration. You’d have to do some jockeying to temporarily copy the values into a Global Property. Some background here.

1 Like

Thanks both of you for the suggestions. It was the Report Action Piece trait that I was talking about.

I solved the problem by turning the Marker trait into a Dynamic Property. There was some head-scratching because Dynamic Properties remove any variable name surrounded by $ as the initial value, but I could change the value into $PieceName$ by letting it listen for a command.

The result works very well.

Hi,

It seems like you have something like

Mark Trait:
   name: 'DisplayName'
   value: 'some-name' or '$PieceName$'

Report Trait:
    key: some key
    report: '$DisplayName$ has disappeard at $location$' 

Perhaps try

Mark Trait:
     name: 'DiplayName'
     value: 'some-name' or '{BasicName}'

Report Trait:
     key: some key 
     report: '{DisplayName+" has disappeard at "+LocationName}'

That is, use BeanShell expression rather than old-style property references. You may also want to consider to use the Basic Name trait in your dummy counters so that they get an appropriate BasicName property.

If you cannot set the Mark Trait value by a BeanShell expression, i.e., to set DisplayName={BasicName} then you can use a conditional in your Report Trait

Report Trait:
     key: some key 
     report: '{(DisplayName==""?BasicName:DisplayName)+" has disappeard at "+LocationName}'

or the DisplayName property for regular pieces can be set via a Calculated Property Trait as

Calculated Property Trait:
    name: 'DisplayName'
    expression: '{BasicName}' 

You only need a Dynamic Property Trait if the property value can change according to some key command.

Yours,
Christian

Thanks a lot for the comprehensive catalog of ideas.

The concept of a DisplayName is now also used for some units that need to have more attributes shown than others, and these attributes can change, so I am not sure if I should leave DP, but your ideas could help with other problems that I have encountered.