Senior Member
Join Date: Jul 2010
Posts: 149
|
Can anyone tell me what's wrong with the following? I've used similar code in other abilities and had no issue. I realize it's a cumbersome formula, but it's a weird progression to have to code.
Code:
field[abRange].value += (round(((field[xAllLev].value - 11) / 5), 0, 1) * 5) Hero Lab was forced to stop compilation after the following errors were detected: Syntax error in 'eval' script for Thing 'cDstAuFear' (Eval Script '#1') on line 1 -> Error parsing parameter 1 of function |
#1 |
Senior Member
Join Date: Jul 2010
Posts: 149
|
Nevermind. I should have tried a little harder to parse the error message. I understand what's making Hero Lab cranky.
|
#2 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
There is much easier methods to code Class Abilities. Plus make them totally generic so they can easily be reused. Take a look at THIS post I did in the project forum to help out those working on the Community Packs. Then crazy formulas like you have are not needed.
Hero Lab Resources: Pathfinder - d20pfsrd and Pathfinder Pack Setup 3.5 D&D (d20) - Community Server Setup 5E D&D - Community Server Setup Hero Lab Help - Hero Lab FAQ, Editor Tutorials and Videos, Editor & Scripting Resources. Created by the community for the community - Realm Works kickstarter backer (Alpha Wolf) and Beta tester.- d20 HL package volunteer editor. |
#3 |
Senior Member
Join Date: Jul 2010
Posts: 149
|
Yeah, I'm familiar with adding multiple instances of a thing and using xCount, but I appreciate it. In this particular case, the power is a chooseable class ability (like a rogue talent), so I'm not sure this applies. The final text I ended up with was:
Code:
var fearbase as number fearbase = (field[xTotalLev].value - 11) / 5 field[abRange].value += round(fearbase, 0, 1) * 5 |
#4 |
Senior Member
Join Date: Mar 2007
Location: Muskegon, MI
Posts: 2,975
|
You could cut out the variable and just do:
[code] field[abRange].value = field[xTotalLev].value - 11 field[abValue].value = round(field[abRange].value/5, 0, -1) [code] saves a little memory that way, but not necesarry |
#5 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
Quote:
As you found doing too much math in the "round" function does not always take. Like Andrew said I would always use "field[abValue].value" instead of making new variable. One less variable to clean up and does allow you to more easily adjust the value if you ever need to from an outside script. Hero Lab Resources: Pathfinder - d20pfsrd and Pathfinder Pack Setup 3.5 D&D (d20) - Community Server Setup 5E D&D - Community Server Setup Hero Lab Help - Hero Lab FAQ, Editor Tutorials and Videos, Editor & Scripting Resources. Created by the community for the community - Realm Works kickstarter backer (Alpha Wolf) and Beta tester.- d20 HL package volunteer editor. |
|
#6 |
Senior Member
Join Date: Jul 2010
Posts: 149
|
Quote:
Quote:
|
||
#7 |
|
|