• 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

Selector on Trait

AndrewD2

Well-known member
I've got a component called "Traits" (named Trait2 to avoid messing with the Trait that comes in the skeleton file).

Traits can be Good/Bad and can be Major/Minor/Special.

I've got 5 tags covering this: Trait.gbGood, Trait.gbBad, Trait.mmMajor, Trait.mmMinor, Trait.mmSpecial.

Minor Traits cost 1 CP
Major Traits cost 2 CP
Special Traits cost something else. Sometimes CP, sometimes Story Points or Both.

I have field: trStorCost, and trCharCost

Currently the internal logic sets those fields to either 1, 2, or whatever the value set in the field is.

Some traits can be Minor/Major/Special and I want to have it put a selector on it to select which it is based on the tags on it. So if it has the Minor/Major tags, the selector would just give those options, if you had Major/Special, just those, if you had all 3, all three would show up. I have a script that assigns the tag User.UserSelect if more than 1 of those tags are found on the trait.

I was originally going to have a different copy for each version and then put prereqs in that prohibited taking the same grouping twice, but doing like the "Bad Eyes" hindrance in Savage Worlds seemed like a better way to go. That uses a preset array, which obviously wouldn't work for this, I figure it needs candidate expression. But I wasn't sure if I could do an expression wit just tags or if I needed things attached to them. I know in Pathfinder the usrChosen fields use things, even in the ones that are pre-done (All Weapons, Energy Type, etc). Do I need to make a basic thing that can attack to this? Or is there some better way to do this?
 
At least in the Core Rules there are no examples of Minor/Special, just Minor/Major, Major/Special, or Minor/Major/Special
 
In that case, would an incrementer work? 1 = minor, 2 = major, 3 = special?

You'd use a finalize script to display a name instead of a number, and depending on what options were available, you can set the minimum and maximum values of the field that the incrementer is displaying.
 
Also, I recommend changing the name of the core Trait component, if your system uses that name to mean something else.
 
Well I've got an incrementer setup there the min and max is set based on the tags The display I want it to say is the type and good/bad for example "(Minor Good)" but all I'm able to get to show in the text is "(M".

Attached is an image of how it looks. I'm trying to modify the incrSimple style, created a copy of it called incrTrait. I've been adjusting the textwidth and fullwidth to give more room but nothing but the first 2 characters seems to show up.
 

Attachments

  • traits.jpg
    traits.jpg
    20.6 KB · Views: 4
Also I am going to change the base trait, but I wanted to work on the system while I was in a good working mood and not spending a lot of time renaming fields and references in a whole folder worth of files.
 
In case it helps this is my position script and the style.

Code:
      ~set up our height based on our tallest portal
      height = portal[info].height

      ~if this is a "sizing" calculation, we're done
      doneif (issizing <> 0)

      ~position our tallest portal at the top
      portal[info].top = 0

      ~center the other portals vertically
      perform portal[name].centervert
      perform portal[delete].centervert

      ~position the delete portal on the far right
      perform portal[delete].alignedge[right,0]

      ~position the info portal to the left of the delete button
      perform portal[info].alignrel[rtol,delete,-8]
      

      ~position the name on the left and let it use all available space
      portal[name].left = 0
      
      var edge as number
      if (tagis[User.UserSelect] = 0) then
        portal[select].visible = 0
        edge = portal[name].right
        
      else
        perform portal[select].alignrel[ltor,name,15]
        edge = portal[select].right
        endif
        
     if (tagis[User.NeedDomain] = 0) then
       portal[lbldomain].visible = 0
       portal[domain].visible = 0
       
     else
       portal[lbldomain].left = edge + 15
       perform portal[domain].alignrel[ltor,lbldomain,5]
       portal[domain].width = minimum(150,portal[info].left - portal[domain].left - 10)
       endif
       ~position the trait rank
      perform portal[rank].alignrel[ltor,name,8]
      portal[name].width = minimum(portal[name].width,portal[info].left - 5)

      ~if the ability is auto-added, change its font to indicate that fact
      if (candelete = 0) then
        perform portal[name].setstyle[lblAuto]
        endif

Code:
   <style
    id="incrTrait">
    <style_incrementer
      textcolorid="clrnormal"
      font="fntincrsim"
      textleft="13" texttop="0" textwidth="84" textheight="20"
      fullwidth="110" fullheight="20"
      plusup="incplusup" plusdown="incplusdn" plusoff="incplusof"
      plusx="99" plusy="0"
      minusup="incminusup" minusdown="incminusdn" minusoff="incminusof"
      minusx="0" minusy="0">
      </style_incrementer>
    </style>
 
And this is the component I'm working with

Code:
<component
      id="Trait2"
      name="Trait"
      autocompset="no">
      <field
        id="trCharCost"
        name="Character Point Cost"
        type="derived"
        defvalue="0">
        </field>
      <field
        id="trStorCost"
        name="Story Point Cost"
        type="derived"
        defvalue="0">
        </field>
        <field
          id="trMax"
          name="Selector Max"
          type="derived">
          </field>
      <field
        id="trMin"
        name="Selector Min"
        type="derived">
        </field>
      <field
        id="trSelect"
        name="Type Selector"
        type="user"
        maxfinal="3">
          <!-- Bound the user value to the limits established for the trait -->
      <bound phase="Traits" priority="1000" name="Bound trtUser">
        <before name="Calc trtFinal"/><![CDATA[
        @minimum = field[trMin].value
        @maximum = field[trMax].value
        ]]></bound>
        <finalize><![CDATA[
          if (field[trSelect].value = 1) then
            @text=" (Minor"
          elseif (field[trSelect].value = 2) then
            @text = " (Major"
          else
            @text = " (Special"
            endif
            
          if (tagis[Trait.gbGood] <> 0) then
            @text &= " Good)"
          else
            @text &=" Bad)"
          endif
        ]]></finalize>
        </field>
      <identity group="HasTrait"/>
      <identity group="Opposite"/>
     <!-- Each trait that is added by the user costs the story and/or character point cost -->
    <eval index="1" phase="Setup" priority="5000"><![CDATA[
      
      ~we must ignore bootstrapped abilities from races and abilities added via advances
      if (isuser + origin.ishero >= 2) then
        if (tagis[Trait.gbBad]  <> 0) then
          #resmax[resStory] += field[trStorCost].value
          #resmax[resCP] += field[trCharCost].value
        else      
          hero.child[resStory].field[resSpent].value += field[trStorCost].value
          hero.child[resCP].field[resSpent].value += field[trCharCost].value
        endif
      endif
      ]]></eval>
      
      <eval index="2" phase="Setup" priority="5000"><![CDATA[
        perform forward[HasTrait.?]
        ]]></eval>
        
      <eval index="3" phase="Setup" priority="2500"><![CDATA[
      ~ set the default values of the traits if the values are left blank

       if (tagis[User.UserSelect] = 0) then
        if (tagis[Trait.mmMinor] <> 0) then
          field[trCharCost].value = 1
          field[trStorCost].value = 0
        elseif (tagis[Trait.mmMajor] <> 0) then
          field[trCharCost].value = 2
          field[trStorCost].value = 0
        elseif (tagis[Trait.mmSpecial] <> 0) then
          field[trCharCost].value = field[trCharCost].value
          field[trStorCost].value = field[trStorCost].value
        else
          if (tagis[Trait.mmMinor] + tagis[Trait.mmSpecial] = 2) then
            field[trMin].value = 1
            field[trMax].value = 3
          elseif (tagis[Trait.mmMinor] + tagis[Trait.mmMajor] = 2) then
            field[trMin].value = 1
            field[trMax].value = 2
          else
            field[trMin].value = 2
            field[trMax].value = 3
            endif
          endif
          if (field[trSelect].value = 1) then
            field[trCharCost].value = 1
          elseif (field[trSelect].value = 2) then
            field[trCharCost].value = 2
          else
            field[trCharCost].value = field[trCharCost].value
            field[trStorCost].value = field[trStorCost].value
            endif
          endif
          
      ]]></eval>
      
      <eval index="4" phase="Setup" priority="2000"><![CDATA[
      if (tagcount[Trait.mm?] > 1) then
        perform assign[User.UserSelect]
        endif
        ]]></eval>
      </component>
 
Well I figured out a work around that actually looks cleaner than what I was trying to do. I actually shrunk the incrementer and eliminated the text so it just showed the two arrows, then based on the value it filled in the label that I was already using for I didn't have the incrementer. Now it looks like this attachment.

I'm noticing another problem, involving the values, but I'll do a little more troubleshooting before posting a new thread.
 

Attachments

  • trait2.JPG
    trait2.JPG
    25 KB · Views: 3
Code:
   <style
    id="incrTrait">
    <style_incrementer
      textcolorid="clrnormal"
      font="fntincrsim"
      textleft="13" texttop="0" textwidth="5" textheight="20"
      fullwidth="30" fullheight="20"
      plusup="incplusup" plusdown="incplusdn" plusoff="incplusof"
      plusx="20" plusy="0"
      minusup="incminusup" minusdown="incminusdn" minusoff="incminusof"
      minusx="0" minusy="0">
      </style_incrementer>
    </style>

It'd be nice if there was a way to set the text as blank in the style instead of in the finalize script for the field.
 
This portal:

Code:
    <portal
      id="value"
      style="incrSimple">
      <incrementer
        field="trtUser">
        </incrementer>
      <mouseinfo mousepos="middle+above"><![CDATA[
        call SkillHist
        ]]></mouseinfo>
      </portal>
 
oh Sorry

Code:
    <portal
      id="select"
      style="incrTrait">
      <incrementer
        field="trSelect">
        </incrementer>
      
      </portal>
 
I can't see any reason this isn't working. The style you posted earlier should have worked - it's constructed just like some of the wide incrementers I've got in Shadowrun.

At this point, my recommendation is to start looking for the type of errors that will make you facepalm when you find them - not saving before you re-compile HL, saving to the wrong folder, having HL set to a different folder, etc.

Here's a set of incrementers that are used in Shadowrun, in case this helps:
Code:
  <!-- style used on 'narrow incrementers'
        -identical to the "simple" incrementer, except a bit narrower in width
  -->
  <style
    id="incrNarrow">
    <style_incrementer
      textcolorid="clrnormal"
      font="fntincrsml"
      textleft="12" texttop="0" textwidth="16" textheight="20"
      fullwidth="40" fullheight="20"
      plusup="incplusup" plusdown="incplusdn" plusoff="incplusof"
      plusx="29" plusy="0"
      minusup="incminusup" minusdown="incminusdn" minusoff="incminusof"
      minusx="0" minusy="0">
      </style_incrementer>
    </style>

  <!-- style used on 'somewhat wide incrementers'
        -identical to the "simple" incrementer, except a bit wider in width
        (displaying 3 digits and a slash is the goal for this one)
  -->
  <style
    id="incrSWide">
    <style_incrementer
      textcolorid="clrnormal"
      font="fntincrsim"
      textleft="13" texttop="0" textwidth="30" textheight="20"
      fullwidth="56" fullheight="20"
      plusup="incplusup" plusdown="incplusdn" plusoff="incplusof"
      plusx="45" plusy="0"
      minusup="incminusup" minusdown="incminusdn" minusoff="incminusof"
      minusx="0" minusy="0">
      </style_incrementer>
    </style>

  <!-- style used on 'wide incrementers'
        -identical to the "simple" incrementer, except a bit wider in width
  -->
  <style
    id="incrWide">
    <style_incrementer
      textcolorid="clrnormal"
      font="fntincrsim"
      textleft="13" texttop="0" textwidth="44" textheight="20"
      fullwidth="70" fullheight="20"
      plusup="incplusup" plusdown="incplusdn" plusoff="incplusof"
      plusx="59" plusy="0"
      minusup="incminusup" minusdown="incminusdn" minusoff="incminusof"
      minusx="0" minusy="0">
      </style_incrementer>
    </style>

  <!-- style used on 'very wide incrementers'
        -identical to the "simple" incrementer, except about 3x as much text space
  -->
  <style
    id="incrVWide">
    <style_incrementer
      textcolorid="clrnormal"
      font="fntincrsim"
      textleft="13" texttop="0" textwidth="75" textheight="20"
      fullwidth="100" fullheight="20"
      plusup="incplusup" plusdown="incplusdn" plusoff="incplusof"
      plusx="90" plusy="0"
      minusup="incminusup" minusdown="incminusdn" minusoff="incminusof"
      minusx="0" minusy="0">
      </style_incrementer>
    </style>

  <!-- style used on 'extra wide incrementers'
        -identical to the "simple" incrementer, except about 3x as much text space
  -->
  <style
    id="incrXWide">
    <style_incrementer
      textcolorid="clrnormal"
      font="fntincrsim"
      textleft="13" texttop="0" textwidth="80" textheight="20"
      fullwidth="105" fullheight="20"
      plusup="incplusup" plusdown="incplusdn" plusoff="incplusof"
      plusx="95" plusy="0"
      minusup="incminusup" minusdown="incminusdn" minusoff="incminusof"
      minusx="0" minusy="0">
      </style_incrementer>
    </style>
 
Sadly I've double checked all that, it just seems that with the finalize script it wouldn't show more than 2-3 characters in an incrementer, but I'm actually pretty happy with the way it currently looks, but I've approached another problem. Is there a way to set an incrementer interval with a field?

I've found some Special Traits have a Variable cost associated with them, usually no more than 2 values, it might be 1/3 or 2/4, in fact I think there are a whole 3 do that, I guess since they all seem to be incremented in 2s I could setup an incrementer that has an interval of 2 and set the minimum/maximum based on a value entered.

Although I did just come across a since trait that is Minor/Special, which kinda makes the incrementer not work with 1 being mindor, 2 being Major and 3 being Special because of that one trait, is there a work around for this, or am I not making any sense?
 
Back
Top