Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   HL - Pathfinder Roleplaying Game (http://forums.wolflair.com/forumdisplay.php?f=62)
-   -   Hero Lab scripting 104: Using Math & Text (http://forums.wolflair.com/showthread.php?t=21668)

Mathias June 17th, 2012 07:05 PM

Hero Lab scripting 104: Using Math & Text
 
This article is part of a collection of editor and scripting articles: http://forums.wolflair.com/showthread.php?t=21688

In Hero Lab's scripting languages, the standard math operations are of course available:

+
-
*
/

So, you can write instructions like:

hero.child[skClimb].field[Bonus].value = hero.child[skClimb].field[Bonus].value + 2

There's also a way to abbreviate that, so you don't have to type as much:

+=
-=
*=
/=

Here's the same instruction, with the abbreviation:

hero.child[skClimb].field[Bonus].value += 2

These abbreviations remove the need to repeat the base thing.

Other common math operations:
  • maximum(A,B)
    • Returns the value of whichever of A or B is higher
  • minimum(A,B)
    • Returns the value of whichever of A or B is lower
  • round(A,# of decimal places,direction]
    • # of digits is the number of decimal places you want. Pathfinder almost never uses decimals, so this will almost always be 0.
    • direction is the direction to round the number. Entering a number that's less than 0 (like -1) will make it round down. Entering 0 will use normal rounding (0.5 and above rounds up, 0.499999 and below rounds down). Entering a number greater than 0 (like 1) will make it round up. The Pathfinder rules say that rounding down is the default, so you'll almost always be using -1 as the direction to round.
For a more complete list, see here: http://hlkitwiki.wolflair.com/index....age_Intrinsics (operations like raising something to a power, finding roots, and taking the modulus are also available, but won't be commonly used)

Mathias June 17th, 2012 07:06 PM

Here's how to add one piece of text to another in Hero Lab's scripting language:

string = "The quick brown fox" & "jumped over the lazy dog."

will set the variable 'string' to:

"The quick brown foxjumped over the lazy dog"

Note how I forgot to put an extra space in there. Correcting that:

string = "The quick brown fox" & " " & "jumped over the lazy dog."

Let's say 'string' has already been set to "The quick brown fox", and you want to add more text to it. Here's how to do that:

string = string & " " & "jumped over the lazy dog."

or, you can abbreviate that, in order to save typing:

string &= " " & "jumped over the lazy dog."



Other common string operations:
  • compare(A, B)
    • TRUE/FALSE - this will return 0 if A and B are identical, and a non-zero number if they are not.
  • string replace(A, B, C, 0)
    • This will return a string. A is your base string - the one you want to change. B is what you want to look for within A (capitalization counts). Every time it finds B in that string, it will replace it entirely with C. That 0 at the end needs to be there (it's an advanced setting that I've never needed to use).
  • empty(A)
    • TRUE/FALSE - this will return the number 1 if A is blank and return 0 if there's text in it.
For a more complete list, see here: http://hlkitwiki.wolflair.com/index....age_Intrinsics (operations like finding the length of a string, changing all the characters to uppercase or to lowercase, etc. are also available, but aren't commonly used).

zarlor March 22nd, 2013 01:32 PM

Great stuff. Thanks, Mathias!

Pathfinder11 January 14th, 2015 07:07 AM

"hero.child[skClimb].field[Bonus].value = hero.child[skClimb].field[Bonus].value + 2"

Is there a write-up on what a string like this means? What is it telling HL to do? Is there a breakdown?

Thanks,

Edward

Nevermind, I saw it on the next post Location Location Location :)

Adoxon_Thanatos February 22nd, 2015 07:09 AM

String in fields selection
 
Why doesn't something like this work?

var id as string
hero.childfound[id].field[cGiveSpec].value+=1

What am I getting wrong?
Is there a way to do something like this?


All times are GMT -8. The time now is 01:19 AM.

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