Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - Authoring Kit

Notices

Reply
 
Thread Tools Display Modes
Duggan
Senior Member
Volunteer Data File Contributor
 
Join Date: Nov 2009
Posts: 1,316

Old September 8th, 2019, 08:14 AM
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>
They exist within a compset that is then used to used for specific bonus types like the following:
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>
Those bonus things are bootstrapped into backgrounds like the following. I would like to only use skbName if specified and, if not, to use the thing name it's bootstrapped to:

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>
I'd like the modification line to pull from a field value on SkillBonus since I use SkillBonus's compset in a few different contexts and I'd prefer them to all be using the same field instead of duplicating the logic.
Duggan is offline   #1 Reply With Quote
Duggan
Senior Member
Volunteer Data File Contributor
 
Join Date: Nov 2009
Posts: 1,316

Old September 8th, 2019, 09:42 AM
Ah, I think "root" is what I want.
Duggan is offline   #2 Reply With Quote
Duggan
Senior Member
Volunteer Data File Contributor
 
Join Date: Nov 2009
Posts: 1,316

Old September 8th, 2019, 04:15 PM
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>
My code for updating the skill bonus is:
Code:
perform field[usrChosen1].chosen.field[trtBG].modify[+,bonus,field[skbName].text]
And yet, when I look at my mouseover, defined as follows:
Code:
<mouseinfo mousepos="middle+above"><![CDATA[
    @text = field[trtBG].history[", "] & "{BR}" & field[trtUser].value & " spent in creation"
    ]]></mouseinfo>
I see something like "+2 Skill Bonus: Dodge, +1 Skill Bonus: Dodge" instead of "+2 Crime Lord, +1 Ob'enn" like I might expect from the source of the skill bonuses.

Last edited by Duggan; September 8th, 2019 at 05:12 PM.
Duggan is offline   #3 Reply With Quote
Duggan
Senior Member
Volunteer Data File Contributor
 
Join Date: Nov 2009
Posts: 1,316

Old September 8th, 2019, 05:11 PM
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.
Duggan is offline   #4 Reply With Quote
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,700

Old September 8th, 2019, 06:53 PM
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.
ShadowChemosh is offline   #5 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 12,607

Old September 8th, 2019, 09:03 PM
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.
Mathias is offline   #6 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 12,607

Old September 8th, 2019, 09:04 PM
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.
Mathias is offline   #7 Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 10:19 PM.


Powered by vBulletin® - Copyright ©2000 - 2019, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.