Lone Wolf Development Forums Hero Lab scripting 104: Using Math & Text
 Register FAQ Members List Search Today's Posts Mark Forums Read

 Notices Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528. If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com. - The Lone Wolf Development Team

Senior Member
Lone Wolf Staff

Join Date: May 2005
Posts: 12,450

June 17th, 2012, 07:05 PM

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)

Last edited by Mathias; June 19th, 2012 at 09:40 AM.
#1
Senior Member
Lone Wolf Staff

Join Date: May 2005
Posts: 12,450

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).

Last edited by Mathias; January 7th, 2014 at 11:41 AM.
#2
Senior Member

Join Date: Nov 2010
Location: Metairie, LA, USA
Posts: 1,764

March 22nd, 2013, 01:32 PM
Great stuff. Thanks, Mathias!

Lenny Zimmermann
Metairie, LA, USA

Data files authored (please let me know if you see any issues with any of these if you have/use them):
50 Fathoms, Deadlands: Hell On Earth, Deadlands: Noir, East Texas University, Necessary Evil (requires Super Powers Companion), Pirates of the Spanish Main, Space 1889 (original file by Erich), Tour of Darkness, Weird War II, Weird Wars: Rome
Coming Eventually
Evernight (LWD has completed their review but I have some fixes to make first... although Pinnacle mentioned this might get an overhaul to SWADE so I may just wait for that first. If you just HAVE to have this now, though, just PM me)
#3
Junior Member

Join Date: Oct 2014
Posts: 3

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

Last edited by Pathfinder11; January 14th, 2015 at 07:11 AM.
#4
Junior Member

Join Date: Feb 2015
Posts: 1

February 22nd, 2015, 07:09 AM
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?
#5

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Lone Wolf Development Web Site Announcements Realm Works Forums     Realm Works Discussion         Realm Works in Action         Realm Works Feature Requests     Realm Works in Action     Realm Works Feature Requests Hero Lab Online Forums     Hero Lab Online Discussion     HLO - Pathfinder Playtest     HLO - Starfinder Hero Lab Forums     HL - Pathfinder Roleplaying Game     HL - D&D 5th Edition SRD     HL - Shadowrun     HL - Mutants & Masterminds     HL - d20 System     HL - World of Darkness     HL - Call of Cthulhu     HL - 4th Edition     HL - Savage Worlds     HL - Cortex System     HL - Authoring Kit     HL - User Projects     HL - Alternity (user-created)     Hero Lab Discussion Army Builder Forums     Army Builder Army Builder Data Files     Babylon 5: A Call to Arms     Battlefleet Gothic     Blood Bowl     Black Powder, Bolt Action, Hail Caesar, Judge Dredd, and Pike & Shotte     Confrontation - English     Kings of War (2nd Edition)     Lord of the Rings (Tabletop)     Mordheim     Necromunda     Starship Troopers     Star Wars: X-Wing and Armada Miniatures Game     The 9th Age     Warhammer Ancient Battles     Warhammer 40,000     Warhammer Fantasy 8th Ed.     Warhammer Historical: The Great War     Warhammer Fantasy 3rd Ed.     Warlord     Warmachine & Hordes     Warmaster Card Vault Forums     Card Vault Card Vault Data Files     MLB Showdown     Lord of the Rings CCG     .hack//ENEMY     Vs. System     Yu-Gi-Oh!     D&D Miniatures

All times are GMT -8. The time now is 11:05 PM.

 -- Default Style -- Majestic Contact Us - Lone Wolf Development Forums - Archive - Top