• 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

"Undeclared variable"

Paragon

Well-known member
I'm getting an error message on an eval script I'm trying to put together, and my suspicion is its a timing issue, but fiddling with that has not fixed the problem, so perhaps I'm missing something. I'm trying to put together an if-then result using two hero fields, and I'm getting an error that one is an "undeclared (not undefined) variable". Any thoughts about what the problem might be from anyone?
 
All too often, I find that "undeclared variable" means "typo" - there's a mistake, and Hero Lab can't interpret it, and falls back on the assumption that you were trying to use a variable that it hadn't already recorded.
 
I'll try it again and see; since I was referring to a floating window with hero fields, a typo is not beyond the realm of reason.
 
Okay, I tried it again and I'm getting the same error. I'm going to list the full XML here, and see if anyone sees anything obviously wrong (yes, I'm aware that people won't know the specifics of the system, but since the 4e forum is a graveyard, posting it there is the same as not posting it, where at least here people with general understanding of HL's syntax usage might be able to suggest something). My suspicion is that its timing related because ACHPNow is current hit points, but I don't know how to figure out what timing would help.

Code:
 <thing id="fRDBFuX" name="Dragonborn Fury" description="While you are bloodied, you gain a +1 racial bonus to attack rolls." compset="RaceFeat">
    <eval phase="Initialize" priority="1000"><![CDATA[ doneif (ACHPNow <= ACHPBlood)

      ~add +1 to attacks with weapons
      foreach pick in hero from WeaponBase
        perform eachpick.field[wpBonus].modify[+,1,""]
        nexteach]]></eval>
    </thing>
 
In that first line, you're using two variables - ACHPNow and ACHPBlood. You'll need to define them before using them, and then set them to some value. Otherwise, you're comparing 0 <= 0, which will always be true
 
In that first line, you're using two variables - ACHPNow and ACHPBlood. You'll need to define them before using them, and then set them to some value. Otherwise, you're comparing 0 <= 0, which will always be true

They're Hero Fields from the system code; do I need to tell the program to look at the Hero before I can do that?
 
If they're fields on the hero, then you need to tell Hero Lab that it's looking for a field on the hero:
Code:
doneif (herofield[acHPNow].value <= herofield[acHPBlood])

Remember, capitalization matters - acHPNow, not ACHPNow.

Also, both of those values aren't calculated until Final/9000, so your script, running at Initialize/1000 will always see the value of both as 0, so it will always exit the script.
 
Ah. I'd thought that last ,might be part of the issue, but it didn't seem to matter where I positioned it, timing-wise. Now that I understand that I was using the hero fields improperly, I can see why.

Thanks, Mathias.

(And yeah, I probably screwed up the capitalization when I was setting it up--and that's one where I know how fussy HL can be from my various SW projects; my only excuse is I'm fighting with a massive headcold...)
 
Finally got back to this and when I the code Matthias suggested I'm getting an "invalid field syntax used" error. Any idea why?
 
I don't have enough information to figure out why without seeing the code.

Also, the error message would have included a line number. You can right-click on error messages in HL and copy them, so please paste both the error message and your code here so I can look at them.

And as a homework assignment, find out which line number it says the error is on, look at the line number in the error message, count lines in the script, and identify which line is the problem.
 
Okay, but understand this is not currently really doing what I want it to; I'm kitbashing and trying to find problems piecemeal before I move on to the next part, so it uses code components from a couple of other things (a class ability and a feat) and they may not work right either.

What I have currently:
Code:
<thing id="fRDBFuX" name="Dragonborn Fury" description="While you are bloodied, you gain a +1 racial bonus to attack rolls." compset="RaceFeat">
    <eval phase="Final" priority="9001"><![CDATA[ doneif (herofield[acHPNow].value <= herofield[acHPBlood])
      foreach pick in hero from WeaponBase
        perform eachpick.field[wpBonus].modify[+,1,""]
        nexteach]]></eval>
    <eval phase="Final" priority="9001" index="2"><![CDATA[       doneif (herofield[acHPNow].value <= herofield[acHPBlood])
       foreach pick in hero where "EquipIndex.? & ImplemType.*"
          perform eachpick.assign[Helper.AttBonus]
        nexteach]]></eval>
    </thing>

and the error is:

Hero Lab was forced to stop compilation after the following errors were detected:

Syntax error in 'eval' script for Thing 'fRDBFuX' (Eval Script '#1') on line 1
-> Invalid field syntax used
Syntax error in 'eval' script for Thing 'fRDBFuX' (Eval Script '#2') on line 1
-> Invalid field syntax used
 
It's a copy/paste error since both have the same problem. Look at your doneif statements and compare how you wrote the herofield identifiers out.
 
Back
Top