Senior Member
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632
|
I have two new gear slots that I am trying to create or "Fake." I've tried twenty ways from Tuesday to force the editor to recognize a new gear slot including copy and paste the xml datafile section on gear slots with new information. It failed.
So, now I'm going to use exsisting mixing it with User tags and eval rules to fake the game into thinking there are two new types. I have code that I think "should" work but for some reason its not giving any errors when I think it should. I am trying to create a Horn Ring for Unicorns and other horned creatures and "Wing Attachment" for Pegasi and other feathered winged fliers. Both can only have one of each equipped. Code:
foreach pick in hero from BaseEquip where "gType.Ring" validif (each.tagis[User.HornRing] <= 1) then nexteach Any ideas on what I'm doing wrong. |
#1 |
Senior Member
Join Date: Jul 2010
Posts: 3,147
|
Yes. You aren't counting the number of items with that tag. It's just looking at each individual item and coming up valid if each item has one or less of that tag. Try this instead:
Code:
var test as number foreach pick in hero from BaseEquip where "gType.Ring & User.HornRing" test += 1 nexteach validif (test <= 1) |
#2 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
So just to but in here. I would go a different way and I would always try and NOT use a Foreach loop. Foreach loop should be last resort!
So as only your "new" gear items can be this type right? Then why loop around when you can set the tags onto the hero yourself. So I would name all the tags similar like "User.EqpRingHrn" and "User.EqpWing" for example. Then you place either of these on your new Things with the following script: Pre-Levels/10000 Code:
~ If not equipped get out now! doneif (field[gIsEquip].value <> 0) ~ Set the custom equipment slot tag onto the hero. perform pushtags[User.Eqp?] Code:
var tags as string ~ get which Custom Equipped tag is on our-self tags = altpick.tagids[User.Eqp?] ~ Test to make sure we are only wearing one of these pieces of equipment validif (hero.tagcountstr[tags] <= 1) 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. Last edited by ShadowChemosh; December 16th, 2014 at 10:59 AM. Reason: d20 uses User.? tags not Custom.? tags.... |
#3 |
Senior Member
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632
|
That might work, I'll have to give it a try, probably tomorrow though.
As a matter of curiosity why would you always save for each loops for the last resort and, could you explain the syntax you are using. I've seen some of it before but don't really understand it. pushtag I know forces a tag onto a given item. But I have never seen altpick.tagids[ ] or hero.tagcountstr[ ]. |
#4 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
Quote:
Eventually in systems like Pathfinders hundred to thousands of these "foreach" loops cause slow down even on a powerful computer. Add that overhead to an iPad and the drain and slow down is really seen. So my advice is to try and "future" proof yourself now against this by not using a foreach unless you have too... Quote:
altpick is used in Pre-req (not the same in eval script) scripts to force the check of tagids[] on to itself. By default all scripts in a pre-req section check the hero. So in essence: Code:
tags = tagids[User.Eqp?] Code:
tags = hero.tagids[User.Eqp?] hero.tagcountstr[tags] is the ability to do "tag count" but against a "string" of characters. Let me try an example: Code:
hero.tagcount[User.EqpRing] Code:
hero.tagcountstr["User.EqpRing"] So this allows me to have a "generic" script that works for any tag that starts as User.Eqp without making it specific to a unique tag. So if tomorrow you add a new tag called "User.EqpWand" it will work without changes. By not using tagcountstr[] I would have done the following instead: Code:
validif (hero.tagcount[User.EqpHorn] <= 1) Hope that helps... 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. Last edited by ShadowChemosh; December 18th, 2014 at 01:24 PM. |
||
#5 |
Senior Member
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632
|
Quote:
|
|
#6 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
Quote:
The first script has two little issues: Code:
~ If not equipped get out now! doneif (field[gIsEquip].value = 0) ~ Set the custom equipment slot tag onto the hero. perform hero.pushtags[User.Eqp?] 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: Nov 2013
Location: Andover, Ma
Posts: 632
|
Not my style, Besides I didn't notice it so I don't feel I'd have the right to do so anyway. It could have been me not entering it properly after all :P
Anyways thanks! |
#8 |
Senior Member
Join Date: Jul 2010
Posts: 3,147
|
|
#9 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
Ahhhh the dreaded grammar nazi!
Happy Holidays! Good luck on the game! Try not to lose a tooth.. 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. |
#10 |
|
|