So I'm building and scripting my character sheet, and if I can figure out how to do one simple thing, my life will become a whole lot less complicated. I'm trying to write a script that uses references to fields to make calculations WITHOUT directly writing the Field Name in the script. I want to do one of two things.
There is a field with the name HP1, also STR and MELEE. I want to write a script to be placed in each of those field's Source which will set that Field Name to a variable, let's say "STAT". That way I could use that variable in a single script, but modify any data from other fields with it.
It would look like this: Field to be copied - [Field Name: STR ; Field Source: js.GetFieldName()] to then be used in the script in [Field Name: Stat_STR ; Field Source: js.calcSTAT()]. The GetFieldName() would create a variable, set the variable to whatever the Field Name was, and return it to be used as a variable in the main script. It would serve as a pointer to other Fields, essentially to gather up all other Fields that have STR in them - IE: Stat_STR, Mod_STR, Total_STR - so that the function can call each stat without having to create a script for each stat, ability, skill, etc.
The other method (highly prefered), seems a lot more simple if its possible. Is there some way to get a Field Name, from within a script that the script is being run from? Its basically the same as Example 1, except simplified. I'm trying to find a way to call a Field Name from within a script being run from the source of that field.
[Field Name: HP1 ; Field Source: js.STATS()]
Inside the STATS() function that basically runs a few calculations. I want to get the Field Name "STAT = FieldName.Name" so that it will be able to be combined with a preset string [var FullName = "Total_" + STAT]. This will allow me to call each stat, skill and ability with the same script. It all hinges on being able to get the Field Name WITHOUT directly referencing a specific field. It would be sort of like a script asking the Field that's running it "What's your Name?".