Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - Pathfinder Roleplaying Game
Register FAQ Community Today's Posts Search

Notices

Reply
 
Thread Tools Display Modes
TobyFox2002
Senior Member
 
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632

Old November 23rd, 2017, 04:28 PM
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
Javascript doesn't seem to like Math.round(bab/4,0,-1) + 1 Anyone have an idea what the heck is going on?
TobyFox2002 is offline   #1 Reply With Quote
charlieluce
Senior Member
 
Join Date: Jul 2008
Posts: 1,321

Old November 23rd, 2017, 05:44 PM
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
charlieluce is offline   #2 Reply With Quote
TobyFox2002
Senior Member
 
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632

Old November 24th, 2017, 04:53 AM
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?
TobyFox2002 is offline   #3 Reply With Quote
EightBitz
Senior Member
 
Join Date: May 2013
Posts: 1,458

Old November 24th, 2017, 11:02 AM
Quote:
Originally Posted by TobyFox2002 View Post
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?
0 means use the normal rounding rules. If it's .5 or higher, round up; otherwise round down. So 4.5 rounds up to 5, and 4.4 rounds down to 4.
EightBitz is offline   #4 Reply With Quote
TheIronGolem
Senior Member
 
Join Date: Feb 2015
Posts: 676

Old November 24th, 2017, 11:17 AM
Quote:
Originally Posted by EightBitz View Post
0 means use the normal rounding rules. If it's .5 or higher, round up; otherwise round down. So 4.5 rounds up to 5, and 4.4 rounds down to 4.
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).
TheIronGolem is offline   #5 Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 04:14 PM.


Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.