• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Set Min-Max by Race

Yeah, I don't have any code for this, as nothing I've done has worked so I keep deleting it.

Code:
    <!-- Calculate the Damage Modifier trait as appropriate -->
    <eval value="1" phase="Traits" priority="4000">
      <after name="Calc trtFinal"/><![CDATA[
      var dammod as number
      dammod = #trait[attrStr] + #trait[attrSiz]
      field[trtDisplay].text = round( dammod / 5, 0, 1)
      ]]></eval>
    </thing>

I set this up like the die type from Savage Worlds but it just doesn't seem to be working.
 
Last edited:
Yeah, I don't have any code for this, as nothing I've done has worked so I keep deleting it.

Code:
    <!-- Calculate the Damage Modifier trait as appropriate -->
    <eval value="1" phase="Traits" priority="4000">
      <after name="Calc trtFinal"/><![CDATA[
      var dammod as number
      dammod = #trait[attrStr] + #trait[attrSiz]
      field[trtDisplay].text = [B]"-" &[/B] round( dammod / 5, 0, 1) [B]& "d8"[/B]
      ]]></eval>
    </thing>

I set this up like the die type from Savage Worlds but it just doesn't seem to be working.

Okay, does the above bolded area add what you needed? Basically, add your text around the calculation.
 
No, if trtDisplay is being updated it is not visible on the screen. All that's being displayed is the derived traits table, and the damage modifier is reading 0. With this code in place trtBonus.value is still 0.
 
Look at the value of the fields via the floating info windows and see if the field does get updated or not. Or put in debug statements to test that it gets to those lines of code?

Hmm. Is this an eval on trtBonus? If so, you are telling it not to evaluate until after trtFinal is done. The <after name="Calc trtFinal"> line is what is doing that.
 
Here's the whole derived attribute

Code:
  <!-- Damage Modifier Trait -->
  <thing
    id="trDamMod"
    name="Damage Modifier"
    compset="Trait"
    isunique="yes"
    description="The bonus amount of damage a character inflicts when they physically strike or apply force.">
    <fieldval field="trtAbbrev" value="Dam"/>
    <fieldval field="trtDisplay" value="+0"/>
    <tag group="explicit" tag="2"/>
    <tag group="User" tag="Combat"/>
    <tag group="DashTacCon" tag="Combat"/>
    <tag group="DashTacCon" tag="Traits"/>

    <!-- Calculate the Damage Modifier trait as appropriate -->
    <eval value="1" phase="Traits" priority="4000">
      <after name="Calc trtFinal"/><![CDATA[
      var dammod as number
      dammod = #trait[attrStr] + #trait[attrSiz]
      field[trtDisplay].text = "-" & round( dammod / 5, 0, 1) & "d8"
      ]]></eval>
    </thing>

And in the info window there's the trtDisplay that has the value, but it's not showing.
 
aha. Maybe.

I think it's timing again. On your trait component, when do you calculate Display? Is it after this and it sets it to the blank?
 
I stopped try to calculate the derived trait, so the only thing that it's racing against here is trtBonus.value which is being displayed instead.
 
Code:
    <!-- Calculate the Damage Modifier trait as appropriate -->
    <eval value="1" phase="Traits" priority="4000">
      <after name="Calc trtFinal"/><![CDATA[
      var dammod as number
      dammod = #trait[attrStr] + #trait[attrSiz]
      field[trtDisplay].text = "-" & round( dammod / 5, 0, 1) & "d8"
      ]]></eval>
    </thing>

The scripting language doesn't usually like it when you try to put math operations like round() on the same line as text operations like &. Try this:

Code:
    <!-- Calculate the Damage Modifier trait as appropriate -->
    <eval value="1" phase="Traits" priority="4000">
      <after name="Calc trtFinal"/><![CDATA[
      var dammod as number
      dammod = #trait[attrStr] + #trait[attrSiz]
      dammod = round( dammod / 5, 0, 1)
      field[trtDisplay].text = "-" & dammod & "d8"
      ]]></eval>
    </thing>
 
Alright, trtDisplay is updated via the info panel. But the tab_basics is still displaying the derived trait as Damage Modifier: 0
 
It's the default portal from the starter files

Code:
  <portal
    id="baTrait"
    style="tblInvis">
    <table_fixed
      component="Derived"
      showtemplate="baTrtPick"
      showsortset="explicit"
      scrollable="no">
      </table_fixed>
    </portal>

And here's the code that actually sets the displayed value (I finally found it!):

Code:
    <portal
      id="details"
      style="lblLeft">
      <label>
        <labeltext><![CDATA[
          @text = field[trtFinal].text
          ]]></labeltext>
        </label>
      <mouseinfo><![CDATA[
        ~insert appropriate code to explain how the trait was derived
        @text = "???"
        ]]></mouseinfo>
      </portal>

It's in the code for the labeltext element. However, if I try to override trtFinal.text from my eval script I'm not allowed.
 
Code:
    <portal
      id="details"
      style="lblLeft">
      <label>
        <labeltext><![CDATA[
          @text = field[trtDisplay].text
          ]]></labeltext>
        </label>
      <mouseinfo><![CDATA[
        ~insert appropriate code to explain how the trait was derived
        @text = "???"
        ]]></mouseinfo>
      </portal>
 
You need to change which field's text is being displayed - you want trtDisplay to be what's shown, not trtFinal.
 
Yes, but only for the single derived trait, the rest should use trtFinal.value
What I want to do is to go into
Code:
  <component
    id="Derived"
    name="Derived Trait"
    autocompset="no">

    <!-- Derived traits are based on other traits. The "calculate" script on the
        "trtFinal" field value will work great for most traits, but NOT for derived
        traits. Consequently, derived traits need to re-calculate the field value AFTER
        the traits derived from are properly calculated. So the individual calculation
        scripts for each derived trait must occur AFTER the initial "trtFinal"
        calculation and BEFORE this derived calculation. We can also omit any "user"
        value from the calculation since derived traits have no user-defined facet.
        -->
    <eval index="1" phase="Traits" priority="6000" name="Derived trtFinal"><![CDATA[
        field[trtFinal].value = field[trtBonus].value + field[trtInPlay].value
      endif
      ]]></eval>

    </component>

Ideally I'd use an if statement. Something like:
Code:
    <eval index="1" phase="Traits" priority="6000" name="Derived trtFinal"><![CDATA[
        if( displayText ) then ~ Not sure how to set/test for this
           field[trtFinal].value = field[trtDisplay].text
        else
           field[trtFinal].value = field[trtBonus].value + field[trtInPlay].value
        endif
      ]]></eval>

That would enable me to switch to use the trtDisplay when I need to by setting something (a tag of some sort) and being able to test for it.

Thanks for the advice here, this has been a blast to learn.
 
Here's where you want the If statement, to do what you want in this case:

Code:
    <portal
      id="details"
      style="lblLeft">
      <label>
        <labeltext><![CDATA[
          if (tagis[thingid.trDamMod] <> 0) then
            @text = field[trtDisplay].text
          else 
            @text = field[trtFinal].text
            endif
          ]]></labeltext>
        </label>
      <mouseinfo><![CDATA[
        ~insert appropriate code to explain how the trait was derived
        @text = "???"
        ]]></mouseinfo>
      </portal>
 
I keep getting the error

Syntax error in 'label' script for Template 'baTrtPick' (in Portal 'details') on line 2 -> invalid use of a reserved word in script

The culprit is:
Code:
if (tagis[thingid.trDamMod] <> 0) then

And no matter what tag I try, even tags that are used fine elsewhere, I still get this error.

Thanks again!
 
Why don't you copy and paste exactly what's in your XML for this whole portal. I think we'd better rule out typos before we continue.
 
Here it is

Code:
    <portal
      id="details"
      style="lblLeft">
      <label>
        <labeltext><![CDATA[
          if( tagis[component.Advance] <> 0 ) then
            @text = field[trtDisplay].text
	  else
            @text = field[trtFinal].text
          endif
          ]]></labeltext>
        </label>
      <mouseinfo><![CDATA[
        ~insert appropriate code to explain how the trait was derived
        @text = "???"
        ]]></mouseinfo>
      </portal>
 
Back
Top