Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - d20 System
Register FAQ Community Today's Posts Search

Notices

Reply
 
Thread Tools Display Modes
TobyFox2002
Senior Member
 
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632

Old December 15th, 2014, 10:11 AM
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
Is the code I have been trying to attach to the ring I have as a test item. Granted I know almost nothing about foreach and I'm just doing copy and paste from other sources. But it compiles properly. Also, I know this code isnt checking if the item is equipped. I'll get to that after I get this first part working.

Any ideas on what I'm doing wrong.
TobyFox2002 is offline   #1 Reply With Quote
Sendric
Senior Member
 
Join Date: Jul 2010
Posts: 3,147

Old December 15th, 2014, 10:28 AM
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)
Sendric is online now   #2 Reply With Quote
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old December 15th, 2014, 06:17 PM
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?]
Then do a pre-req with the following script
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)
Now you have a generic set of scripts that can be used over and over and all controlled by which "User.Eqp?" tag you assign to each piece of equipment.

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....
ShadowChemosh is offline   #3 Reply With Quote
TobyFox2002
Senior Member
 
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632

Old December 15th, 2014, 06:40 PM
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[ ].
TobyFox2002 is offline   #4 Reply With Quote
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old December 16th, 2014, 11:08 AM
Quote:
Originally Posted by TobyFox2002 View Post
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.
Foreach loops use up a "massive" amount of CPU and also energy. Maybe not important right this second for d20 as it only runs on laptops and its not very large. But as it grows and it gets to iPads or people that run on it on a windows tablet more CPU means more battery wasted.

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:
Originally Posted by TobyFox2002 View Post
pushtag I know forces a tag onto a given item. But I have never seen altpick.tagids[ ] or hero.tagcountstr[ ].
Correct Push tags here is taking what ever "User.Eqp?" tag and assigning it to the Hero container. The use of a "?" means its a wild card so that it will push a tag called "User.EqpHorn" or "User.EqpRing" in example. It also means if both tags are on the Gear Item it will push both of them.

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?]
is exactly the same as doing:
Code:
tags = hero.tagids[User.Eqp?]
In that we will build a string variable based on the User.? tags on the Hero not the gear item. So by using altpick in front we are telling HL to get the tags on the Gear Item instead.

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]
is the same as doing
Code:
hero.tagcountstr["User.EqpRing"]
The difference being that the compiler does not check that "User.EqpRing" is a valid tag until run time. So this also allows one to build a soft-coded "tag" in a string variable.

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)
Then I would have had to change the tag in the pre-req script to be equal to the tag I placed on the Gear Item. It means a 2nd step to remember when making a new item.

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.
ShadowChemosh is offline   #5 Reply With Quote
TobyFox2002
Senior Member
 
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632

Old December 22nd, 2014, 12:32 PM
Quote:
Originally Posted by ShadowChemosh View Post
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?]
Then do a pre-req with the following script
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)
Doesn't produce any errors when more than one is equipped, in fact I cant get it to give any errors at all.
TobyFox2002 is offline   #6 Reply With Quote
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old December 22nd, 2014, 01:16 PM
Quote:
Originally Posted by TobyFox2002 View Post
Doesn't produce any errors when more than one is equipped, in fact I cant get it to give any errors at all.
You missed your chance to say Shadow your an idiot!

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?]
It should be done if we have NOT been equipped so equal not (Not equal). Also we need to set the tag on the HERO not yourself. So it needs "hero.".

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   #7 Reply With Quote
TobyFox2002
Senior Member
 
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632

Old December 22nd, 2014, 02:22 PM
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!
TobyFox2002 is offline   #8 Reply With Quote
Sendric
Senior Member
 
Join Date: Jul 2010
Posts: 3,147

Old December 22nd, 2014, 02:33 PM
Quote:
Originally Posted by ShadowChemosh View Post
You missed your chance to say Shadow your an idiot!
Come on, Shadow. It's you're. Silly engineer.

Merry Christmas, kids! Here's hoping Santa brings an early present and lets my hockey team win tonight...or at least keeps me from getting hurt.
Sendric is online now   #9 Reply With Quote
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old December 22nd, 2014, 02:41 PM
Quote:
Originally Posted by Sendric View Post
Come on, Shadow. It's you're. Silly engineer.
Ahhhh the dreaded grammar nazi!

Quote:
Originally Posted by Sendric View Post
Merry Christmas, kids! Here's hoping Santa brings an early present and lets my hockey team win tonight...or at least keeps me from getting hurt.
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.
ShadowChemosh is offline   #10 Reply With Quote
Reply


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 Jump


All times are GMT -8. The time now is 11:44 AM.


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