I’m futzing around editing modules and thought to change a layer from being a simple incremental numeric thing to working with a dynamic property so you can select the layer directly by a drop-down menu. I’m basically directly copying this from another module so I’m baffled and frustrated that it doesn’t work for me. Since I’m at a loss for what is pertinent, have some images.
The text label is just to check the dynamic property is updating (it is) and the expression doesn’t give me a Bad Data warning, but the piece stubbornly refuses to change layer no matter how much I click menus. So what am I doing wrong?
I’m not familiar enough with “If” expressions to help with that part of it (I didn’t know they work w/o a negative value for each, and in-line like that), but could you substitute numeric values for Banker DP instead:
Banker — Fugger (Orange) — set value directly=1
Banker — Medici (Yellow) — set value directly=2
(etc)
Seq — levels follow expression=Banker — Level 1=1
If the original (non-numeric) values are necessary for Banker DP, and the complex expression ends up not working for you, you could also add another Dynamic Property (SeqLayer) and tie it (invisibly, with no menu commands) to the Banker one:
SeqLayer — no menu command — key command=CTRL F — set value directly=1
SeqLayer — no menu command — key command=CTRL M — set value directly=2
(etc)
Okay, curious I just ran some “If” expression tests. I realized the subsequent “If”'s were the negative value (I hadn’t realized that), so it just needed a final negative at the end (at least for me).
In general, it is a VERY bad idea to have a Layer follow a Calculated Property (CP). The CP doesn’t ‘listen’ for changes in the variables that make it up, every time the layer needs to be redisplayed, the CP has to be recalculated.
In a small module, this doesn’t matter, but if you have many units with multiple layers following CP’s, your module will die as all of the layers on multiple units are recalculated multiple times per second.
It is FAR better to have your Layer follow a Dynamic Property (DP) and have the actions that affect which Layer to display directly modify the value of the DP. You can use CP’s with complicated logic to modify the value of the controlling DP. This is fine, because the CP is only evaluated once at the time of the action that changes the Layer to be displayed.
This does fix it, thanks. Uh, in the most layman’s term you can manage: what is that 6 at the end doing there? So all these nested Ifs is telling the program to riffle down through possible markers, and then assign it the correct layer, and the 6 at the end promises that if it doesn’t find anything that matches, it doesn’t matter? Or rather, that the world still makes sense.
See below for another way of writing it show what is happening. The If function has to have 2 values to return, 1 for true and 1 for false, so you have to have something at the end if Banker doesn’t match any of the options. Even if it will never happen, you have to have the final ‘else’ option.
If(Banker=="null")
then return 1;
else If(Banker=="Fugger")
then return 2
else If(Banker=="Medici")
then return 3
else If(Banker=="Coeur")
then return 4
else If(Banker=="Marchionni")
then return 5
else
return 6
Right (well, maybe not the last part ). Although the final 6 would be a non-applicable level for the layer, it’ll will never get that far anyway. I suppose you could cut the last section completely and just have this instead:
The second one saying if it’s not any of those four, then it’s “null”.
Just to be clear, a Dynamic Property’s “follow expressions” set-up is handled in exactly the same way as if it were a Calculated Property trait… expending exactly the same amount of energy (for lack of a better way to describe it)?
It is vastly more ‘expensive’ (in Energy ) to find the current value of a Calculated Property than it is to find the value of a Dynamic Property. The Energy cost is paid every time the CP is referenced, there is no caching of the value.
So, you want to design your module so that Calculated Properties are evaluated as little as possible.
Let’s say it costs 1 Energy to read the value of a Dynamic Property, and 50 Energy to read the value of the big If Calculated Property above.
In the example above, the Banker changes between players once per turn, say every two minutes and let’s say 1 unit we are looking at is redisplayed 100 times in that 2 minute period.
Scenario 1 where you reference a Calculated Property directly as the Level following property, it will cost you 50 Energy each time the unit redisplays for 100x50 = 5000 energy to handle the display of that layer for that unit for 2 minutes.
Scenario 2 - When the banker changes, you modify the module to use the big If Calculated Property to pre-calculate the correct Layer level to display and store it in a Dynamic Property, say called BankerLevel. This will cost you 50 Energy. You then use BankerLevel as the property to follow and it now only costs you 1 Energy to redisplay the layer each time , for a total of 50 + 100 x 1 = 150 Energy over the 2 minutes.
These numbers are arbitrary, but not unrealistic. If the CP is used in just one layer in one counter, it is not a problem. But if CP’s are being followed by multiple layers in multiple units, you end up with a big problem.