• 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

Counter variables in scripts (Pathfinder, 3.5)

tatteredking

Well-known member
I am attempting to write a script that counts how many skills have X ranks in them .

My thought was to define a counter variable, and then go through each skill, and if the skill had sufficient ranks, it increments the variable. I looked at the Master Craftsman feat, which has a requirement of 5 skills in any 2 Craft or Profession skills, but there was no script in there.

Having some skill in coding in other languages, I assumed I needed to define a variable. Then I banged out this script...

Code:
@valid = 0

   ~ reset counter
   @skcounter = 0

   ~ count how many skills have ranks 6 or more
   if (#skillranks[skAppraise] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skAcrobat] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skBluff] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skClimb] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skCrafAlch] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skDiplo] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skDisable] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skDisguise] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skEscape] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skFly] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skHandleAn] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skHeal] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skIntim] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skKnowArca] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skKnowDun] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skKnowEng] >= 6) then
      @skcounter = @skccounter +1
   endif
   if (#skillranks[skKnowGeog] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skKnowHist] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skKnowLoc] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skKnowNat] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skKnowNobl] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skKnowOth] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skKnowRel] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skKnowPlan] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skLinguist] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skPercep] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skRide] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skSenseMot] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skSleight] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skSpellcr] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skStealth] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skSurvival] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skSwim] >= 6) then
      @skcounter = @skccounter +1
   endif

   if (#skillranks[skUseMagic] >= 6) then
      @skcounter = @skccounter +1
   endif

~ valid if two or more skills have rank 6 or more
if (@counter >= 6) then
   @valid = 1
endif

Syntax error in 'pre-requisite rule' script for Thing ... on Line 4
-> Unrecognized name for a special symbol in current context: 'skcounter

So it appears I am not defining the variable correctly. So, a couple questions...

1) is there an easier way to script a prerequisite of "Any two skills at rank 6"?

2) how does one properly define a user defined variable?
 
in the scripted you defined the counter as skcounter, but in the code you call it as skccounter. you have an extra c in the code. just a syntac error
 
DOH. Well then.....

OK, so changed that and still getting

Syntax error in 'pre-requisite rule' script for Thing ... on Line 4
-> Unrecognized name for a special symbol in current context: 'skcounter
 
Last edited:
Do you need the @ symbol for each counter? I cant take a look at my HL ATM, but i dont remember doing that for any of the scripts I have done.

Just a guess though.
 
"@" may not be used in general variables - only in "special symbols" that are built into Hero Lab, like @valid.

You also need to define a variable before you use it:

Code:
var skcounter as number

Here's a way you can save some typing:

instead of

Code:
skcounter = skcounte + 1
Code:
skcounter += 1

Will do the same thing.
 
Do you mean "any 2 skills at rank 2?" or do you mean "Any 2 skills from this list at rank 2", because your current script isn't checking a lot of skills (most of the craft, profession, knowledge and perform skills)
 
I mean any two skills at rank 6. I know I didn't put all the craft, Professions and Perform skills in. I figured I would get it working first.

Thanks Mathias, that's exactly what I was looking for. Didn't know how to define the variable
 
I believe you should use a "foreach" statement to iterate over all the skills on an actor. Unfortunately, I don't know anything about the guts of Pathfinder, so I can't tell you the proper syntax for this within Pathfinder.

Mathias, could you please provide a quick example of the "foreach" statement that is needed here?
 
thanks rob, a foreach statement is what I am looking for, but not sure of the syntax for the HL scripts. Would definitely make it easier!
 
Can you think of any examples of other things that have to check many different skills in a prereq?

Student of War prestige class (Seekers of Secrets)
Dilettente feat (Seekers of Secrets)
Instrumental feat (Classic Treasures Revisited)
Loremaster Prestige Class (core rulebook)

(I have the advantage of being able to search the text of everything in the files)

All of those have prereqs of "X ranks in each of Y skills" (usually only skills of a specific type). For the prestige classes, you can copy the class level, where the prereqs of a prestige class are, without having to go through the whole new class wizard.
 
Thanks Mathias, I tried Master Crafter, but it didn't have the script. I looked through my list but, Dilettante, Student of War and Instrumental didn't jump out at me. Having to look through all the books for an example, is tedious. I appreciate pointing me in the correct direction.

Tried looking at Loremaster, but when I copied the class, the prereq's didn't seem to come over. But I didn't think of copying the Class Level.

Thanks!
 
Edit: didn't see this had multiple pages -- also didn't know about the BaseSkill collection

~foreach pick in hero where "component.BaseSkill"
foreach pick in hero from BaseSkill
if (eachpick.field[skRanks].value > 6) then
~ do stuff with eachpick or the hero, or something
endif
nexteach
 
Last edited:
Back
Top