|
Senior Member
Join Date: Feb 2010
Posts: 874
|
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?
|
#1 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,243
|
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.
|
#2 |
Senior Member
Join Date: Feb 2010
Posts: 874
|
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.
|
#3 |
Senior Member
Join Date: Feb 2010
Posts: 874
|
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> |
#4 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,243
|
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
|
#5 |
Senior Member
Join Date: Feb 2010
Posts: 874
|
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?
|
#6 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,243
|
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]) 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. |
#7 |
Senior Member
Join Date: Feb 2010
Posts: 874
|
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...) |
#8 |
Senior Member
Join Date: Feb 2010
Posts: 874
|
Finally got back to this and when I the code Matthias suggested I'm getting an "invalid field syntax used" error. Any idea why?
|
#9 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,243
|
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. |
#10 |
|
|