|
Senior Member
Volunteer Data File Contributor
Join Date: Nov 2009
Posts: 1,502
|
This is probably something super-obvious that I'm just not getting at the moment, but I have Components for certain skill bonuses in my system like the following:
Code:
<!-- SkillBonus component --> <component id="SkillBonus" name="Starting Skill Bonus" autocompset="no" panellink="basics"> <field id="skbName" name="Name" type="user" maxlength="20"/> </component> Code:
<thing id="fRPlusSk" name="Skill Bonus" compset="cmpsetSB" description="Gives a bonus to the selected skill."> <fieldval field="usrCandid1" value="component.Skill"/> <tag group="Hide" tag="Special"/> <eval index="1" phase="PreTraits" priority="4900"> <before name="Calc trtFinal"/><![CDATA[ var bonus as number var penalty as number bonus = tagvalue[Bonus.?] penalty = tagvalue[Penalty.?] if (bonus = 0) then if (penalty = 0) then bonus = 2 else bonus = penalty endif endif if (bonus > 0) then field[livename].text = "+" & bonus & " " & livename else field[livename].text = bonus & " " & livename endif ~build the candidate expression out of our Skill and Skills tags var skills as string skills = tagids[Skill.?, " | "] var skilltypes as string skilltypes = tagids[Skills.?, " | "] var combined as string if (tagis[Skills.?] <> 0) then if (tagis[Skill.?] <> 0) then combined = skills & " | " & skilltypes else combined = skilltypes endif else combined = skills endif ~ debug combined & ", " & empty(combined) if (empty(combined) = 0) then field[usrCandid1].text &= " & (" & combined & ")" endif perform field[usrChosen1].chosen.field[trtBG].modify[+,bonus,field[skbName].text] ]]></eval> </thing> Code:
<thing id="bckCrime" name="Crime Lord" description="You probably didn’t get your lawless hands very dirty, but you definitely know some people who did — and they did it on your orders.\n\n{b}Bonus Skill Ranks:{/b} +2 Deceive, +2 Economics {i}or{/i} History, +2 Inspire {i}or{/i} Negotiate" compset="Bckgrnd" uniqueness="unique"> <bootstrap thing="fRPlusSk2"> <autotag group="Skill" tag="skDeceive"/> </bootstrap> <bootstrap thing="fRPlusSk"> <autotag group="Skill" tag="skEcon"/> <autotag group="Skill" tag="skHistory"/> <autotag group="explicit" tag="1"/> </bootstrap> <bootstrap thing="fRPlusSk"> <autotag group="Skill" tag="skInspire"/> <autotag group="Skill" tag="skNegot"/> <autotag group="explicit" tag="2"/> </bootstrap> </thing> |
#1 |
Senior Member
Volunteer Data File Contributor
Join Date: Nov 2009
Posts: 1,502
|
Ah, I think "root" is what I want.
|
#2 |
Senior Member
Volunteer Data File Contributor
Join Date: Nov 2009
Posts: 1,502
|
Hmm... and either I misunderstand something about field histories or I implemented this incorrectly. My current SkillBonus:
Code:
<!-- SkillBonus component --> <component id="SkillBonus" name="Starting Skill Bonus" autocompset="no" panellink="basics"> <field id="skbNamCst" name="Custom Name" type="user" maxlength="20"/> <field id="skbName" name="Name" type="static" maxlength="20" maxfinal="20"> <finalize><![CDATA[ if (this.field[skbNamCst].isempty = 0) then @text = field[skbNamCst].text elseif (this.isroot <> 0) then @text = this.root.field[name].text else @text = this.field[name].text endif ]]></finalize> </field> </component> Code:
perform field[usrChosen1].chosen.field[trtBG].modify[+,bonus,field[skbName].text] Code:
<mouseinfo mousepos="middle+above"><![CDATA[ @text = field[trtBG].history[", "] & "{BR}" & field[trtUser].value & " spent in creation" ]]></mouseinfo> Last edited by Duggan; September 8th, 2019 at 05:12 PM. |
#3 |
Senior Member
Volunteer Data File Contributor
Join Date: Nov 2009
Posts: 1,502
|
And, with further debug statements, it seems that I'm not getting the field I expect. field[skbName] is empty at the time of evaluation.
|
#4 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
I am pretty sure that finalize script is meant to set a value for the UI. Meaning its done very late in processing. For example from Pathfinder the abDC field would finalize with a script that sets a value of "DC X" where X is the value of abDC.
I think you want to not use a finalize script and instead use a component script that runs semi early so that skbName gets a name. This way you are 100% in control of when the script executes. Hero Lab Resources: Pathfinder - d20pfsrd and Pathfinder Pack Setup 3.5 D&D (d20) - Community Server Setup 5E D&D - Community Server Setup Hero Lab Help - Hero Lab FAQ, Editor Tutorials and Videos, Editor & Scripting Resources. Created by the community for the community - Realm Works kickstarter backer (Alpha Wolf) and Beta tester.- d20 HL package volunteer editor. |
#5 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
Also, I would not use a static field for something you intend to use a finalize script for. I'm not certain about it, but that seems likely to run into HL's speed optimizations - where if a field's doesn't change, HL doesn't recalculate things based on it, which may include the finalize script - see the acHPSumm field in actor.str in the skeleton files for an example of how a field that's only used for its finalize value has been set up - as a numerical derived field that stores a value that's designed to change if any of the elements that go into it change, and then with the finalize script to handle the text.
|
#6 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
But, in order to use the field in a history, you'll need to change it to be a derived string field (skip the finalize), and make sure to set it before the script that's trying to use it to build the text for the history entry.
|
#7 |
Senior Member
Volunteer Data File Contributor
Join Date: Nov 2009
Posts: 1,502
|
Minor follow-up, that's exactly what I needed to do, was to move it into an eval and do it earlier.
Code:
<!-- SkillBonus component --> <component id="SkillBonus" name="Starting Skill Bonus" autocompset="no" panellink="basics"> <field id="skbNamCst" name="Custom Name" type="user" maxlength="20"/> <field id="skbName" name="Name" type="derived" maxlength="20"> </field> <eval index="1" phase="Initialize" priority="3005"><![CDATA[ if (this.field[skbNamCst].isempty = 0) then field[skbName].text = field[skbNamCst].text elseif (this.isroot <> 0) then field[skbName].text = this.root.field[name].text else field[skbName].text = this.field[name].text endif ]]></eval> </component> Last edited by Duggan; December 22nd, 2019 at 05:08 PM. |
#8 |
|
|