Dynamic Properties / Triggers and Piece Palette

I have Text Label value which is complicated expression using many other Dynamic Properties (which are set by many different prototypes and change throughout game).
The expression:

{If(DB>0, ("<"+DB+">"), "")+If(HasA20!="", (A20+"V"), "")+If(HasHvyFtr!="", (HvyFtr+"H"), "")+If(HasFtr!="", If(Ftrx2%2==1, If(Ftrx2>1, (Ftrx2/2+"⯅"), "⯅"), Ftrx2/2), "")+If(Pmax!="", (If(P==0, "", If(P==1, "P", "PP"))+If(((Pmax+0)-P)==0, "", If(((Pmax+0)-P)==1, "p", "pp"))), "")+If(Gmax!="", (If(G==1,"G", If(G==2,"GG", If(G>0,"G"+G, "")))+If(((Gmax+0)-G)==0, "", If(((Gmax+0)-G)==1, "g", If(((Gmax+0)-G)==2, "gg", "g"+((Gmax+0)-G))))), "")+If(PPD>0, "●", "")+If(E>0, "◼", "")+If(J>0, If(J==1, "J", ("J"+J)), "")+If(N>0, If(N==1, "N", ("N"+N)), "")+If(R>0, If(R==1, "R", ("R"+R)), "")+If(Crip_Active!=true, (If(HasFCRFtr!="", ("["+FCRFtr+"]"), "")+If(HasFCRPF!="", ("["+PF+"P]"), "")+Hospital+Shock+Transport), "")+W+D+Fast+SFG+If((EW>0&&PGB<1),"◆","")}

This bogs down after a few hundred pieces on map. A work around was setting Text Label value to $CalculatedText$ and creating a Dynamic Property “CalculatedText” with a “recalc” command with “Set value directly prompt” equal to above complicated expression. Then trigger “recalc” on all the things that may change expression (which is huge PITA).

But, Triggers and/or Dynamic Properties(other than initial value) don’t seem to “work” in Piece Palettes. So the Text Label is blank there.


  1. is there better way to make such a dynamic and complicated text label performant?

  2. any ideas on how I can get the Dynamic Property to work in Piece Palette?
    (without having to copy and set “initial value” to 100’s of pieces.


Don’t use if()! Use the Java ternary operator, :?, instead; it is much faster. I’m not going to try to rewrite your entire expression for you, but it would start with (DB > 0 ? "<" + DB + ">" : "") + (HasA20 != "" ? A20 + "V" : "")

Basically, everything between the ? and the : is what to use if the expression is true, while after the : is for if the expression is false.

Edit: And to respond to question 2, the answer is no: Dynamic Properties are deliberately not calculated in Piece Palettes because doing so can cause errors if they try to reference any location properties of the piece (since it doesn’t actually have a location yet).