Thread: Hero.Epic
View Single Post
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old November 29th, 2016, 10:39 AM
Quote:
Originally Posted by Nightfox View Post
ok, I thought I'd put this little bit of code (for certain definitions of little) up for those more skilled with coding to look at and see if they could find a better way of doing everything so that it would not be quite as intensive.

Note that this is rather ugly so those of you who are code-aphobic, you may want to look away.

As it stands, I'm thinking I may need to create separate specials to run the code for the sake of space and timing, but that could end up drastically increasing the number of foreach statements and therefore processing requirements.
My confusion in going over this is the way you structured the foreach loops:
Code:
foreach pick on hero where (field[cIndex].value < 20)
If you are going to do a foreach loop then at least limit the context down by component sets. This loop here goes after every PICK on the hero then tries to subset by a field that may or may not even exist on the picks list of fields.

Limit the foreach scope like this:
Code:
foreach pick in hero from BaseClHelp where "TagGroup.Tag"
or 
foreach pick in hero from BaseClHelp
Always better to use a tag then any field for searching. HL is optimized to deal with Tags not so much with fields. By saying "from BaseClHelp" we are limiting HL down to just the Class Helper Picks on the hero which will be ALLOT smaller subset of Picks to deal with then every Pick.

Please note I can't remember if BaseClHelp is correct for d20 as I am not near HL. You can see which "Components" make up a Pick by looking at its tags and the 'component.?' group section.

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.
ShadowChemosh is offline   #18 Reply With Quote