Best way to display “derived” data?
I am putting on a npc sheet a numeric field that contains AC in descending (as god so intended...) representation and also have in the npc sheet/DB a field for ascending (heretical) AC.
I only want to display the AC on the sheet and for editing (since ascending AC can be derived as a function of descending AC) but would like it to look like this on the sheet:
AC: 8 [11]
My xml has an overall script=... referencing an npc.lua file with the handlers and code for the camp.
So I expected I’d use a string control (or derived from string control with features I also wanted) And would just add an onInit which initialized acasc to a value from ac. Then I could add an onValueChanged handler to ac to update acasc.
Thing is, on that lua script, how do I access acasc_control (for bland example name)? I saw on another npc.lua that folks did self[sControl].update(arg1, arg2)
The index, sControl, was a string with the xxxx portion of the xml attribute: name=“xxxx”.
But if I try:
self[acasc_control].setValue(“...”);
It is rejected. I played with other combos to no avail.
That was the background and what I tried, is there a better (correct) way to populate string controls with label-like values but ones not constant, instead dependent on the particular npc?
And finally, I want the answer above, but I wondered also if I SHOULD include the “formatted” ac field as a string in the npc dv. To me it did not sit well since it is purely derived and never used in play, just for visual formatting.