Senior Member
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632
|
I have a piece of code I'm trying to understand, its probably very simple but still giving me some big grief. I'm fairly certain I've seen information on the forums before regarding it but I cant find it.
However, I have some code I'm trying to take from HL and move it to roll20.. And while this is a little off topic for a LoneWolf Forums but still.. The power attack code is: Code:
field[abValue].value += round(#BAB[]/4,0,-1) + 1 field[abValue2].value += field[abValue].value * 2 |
#1 |
Senior Member
Join Date: Jul 2008
Posts: 1,321
|
Javascript doesn't use the multi-parameter rounding syntax. For the equivalent (which is truncating the result), use Math.floor(bab/4)
Currently Running: Pathfinder Second Edition Currently Playing: Pathfinder First Edition, Star Trek Adventures Former HL Games: D&D 4e & 5e, Mutants & Masterminds 2E & 3E, Savage Worlds |
#2 |
Senior Member
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632
|
Thank you, that fixes things.
Out of curiosity and for future reference what do the other parameters do for the round() function do in HL? So the third parameter, the "-1" means rounds down, aka the "floor()" function, and by extention a 1 would be round up or ceil(). What does the second parameter do? the "0" Is that a numeric base? or precision? |
#3 |
Senior Member
Join Date: May 2013
Posts: 1,458
|
Quote:
|
|
#4 |
Senior Member
Join Date: Feb 2015
Posts: 676
|
I believe he's asking about the 0 that's being used in the second parameter. That's for precision (i.e. number of decimal places to round to, which is usually zero for us because Pathfinder almost never deals in fractions).
|
#5 |
|
|