View Single Post
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,213

Old August 21st, 2020, 10:10 AM
In retrospect, I really wish we had never used "x" as the prefix for "this can be in many compsets". It just ends up looking really bad in the code. Pick a prefix based on the Id of the component these fields are really in, and use that.

From the description of what you need to solve, you don't need the full complexity of a level-based count and index (which looks to be copied from PF1). All you need is single-ability handling.

Here's an example script that only needs a single script on this ability, and just needs a generic "value" field to store the number of copies beyond the first on the main copy of the ability - not a special script on a mechanic that has to run even if nothing it applies to is present on the character.

Code:
      ~see if a quickfind has been created by another copy of this ability
      perform quickfind.setfocus

      ~if we didn't find a redirection, we're the first copy of this ability to run this script, so we'll make ourselves the FirstCopy.
      if (state.isfocus = 0) then
        perform quickadd
        perform assign[Helper.FirstCopy]

        ~add +1 to our value
        field[abValue].value += 1

      ~otherwise, redirect hero.child[] to the FirstCopy, and make us an upgrade
      else
        perform focus.redirect

        ~add +1 to the focus's value
        focus.field[abValue].value += 1
        endif
Mathias is offline   #3 Reply With Quote