Senior Member
Join Date: Nov 2011
Location: South Riding, VA
Posts: 841
|
I have a container that needs to perform some actions on anything that is put inside it. I am implementing the container as a piece of gear that has the Helper.Helper tag.
How can I check that a container 1) has stuff in it, and 2) do a foreach through that stuff in order to perform the actions I want to do? |
#1 |
Senior Member
Join Date: Oct 2011
Posts: 6,793
|
1) Use the gHeldCount field, or if that isn't available, use gearcount
2) From the sbgear procedure foreach gear in focus ammo = splice(ammo,eachpick.field[stackQty].value," and ") ammo &= " " & eachpick.field[sbName].text nexteach |
#2 |
Senior Member
Join Date: Nov 2011
Location: South Riding, VA
Posts: 841
|
Ah! Thank you!
|
#3 |
Senior Member
Join Date: Sep 2015
Posts: 435
|
Hm. Could this somehow be used to add a field to all items in a container that would flow through to the "Save Custom Output" XML file? That would allow a character sheet to know which items were in which containers, something that HL doesn't currently export.
Thanks. |
#4 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
Quote:
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. |
|
#5 |
Senior Member
Join Date: Sep 2015
Posts: 435
|
I'm looking into using a JavaScript library that can read ZIP files so that the char sheet could be put in the same folder as the .por file and when the sheet was opened up, it would read the container information directly from the portfolio. I don't know how practical this is yet; it's only in the idea stage. But the containers and their contents are easily found within the portfolio... (And I filed a bug report on this. Maybe if enough people file bug reports they'll make a change. Can't be very tough, right? )
|
#6 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
Quote:
Granted its been awhile sense I looked but thats what I saw the last time I looked at one. Just FYI. This is true.... 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. |
|
#7 |
Senior Member
Join Date: Sep 2015
Posts: 435
|
Quote:
Quote:
Sample snippet is below. Note that the backpack has index="1001" and the caltrops have holder="1001": Code:
<pick thing="fBackpack" index="1001" batchindex="835" refcount="0" fieldcount="5" source="gTable"> <field id="slOriPrice" text="50 {size 32}GP{size 40}"></field> <field id="usrChosen1"></field> <field id="usrChosen2"></field> <field id="usrChosen3"></field> <field id="usrChosen4"></field> </pick> <pick thing="fCaltrops" index="998" batchindex="832" refcount="0" fieldcount="5" source="gTable" holder="1001"> <field id="slOriPrice" text="50 {size 32}GP{size 40}"></field> <field id="usrChosen1"></field> <field id="usrChosen2"></field> <field id="usrChosen3"></field> <field id="usrChosen4"></field> </pick> My plan is to make the .por file optional. If it's there, the JS will only use it to construct the container hierarchy -- the rest of the file will be ignored. I have some time off next week so I'll look into this more pretty soon; I'd like this sheet to work as completely as possible. My main concern is performance: will reading the ZIP in an interpreted language be too slow to be usable? (As an aside, I am pretty impressed with the design work LW did with the XML data. They broke a few rules, but probably for expediency. For example, the text attribute in those two picks contain presentation information (font size) and it really should be two separate fields (perhaps "amount" and "unit"?), then the software should control the presentation by reducing the font size for the unit. But as I said, I'm being pedantic and overall they did a great job with it.) Last edited by Azhrei; May 19th, 2016 at 07:25 AM. |
||
#8 |
Thread Tools | |
Display Modes | |
|
|