Page 1 of 1

Maybe noob question

Posted: Thu May 06, 2010 12:16 pm
by xeon
What if I want to extract all items in an itemdesc.cfg which are "Weapons"?

Don't say me that I've to loop through all of them checking for a prop which only Weapons have :sick:

Re: Maybe noob question

Posted: Tue May 11, 2010 9:50 am
by Austin
Yeah you pretty much have to do that

Something like

Code: Select all

var itemdesc := ReadConfigFile(":*:itemdesc");
foreach ( cfgelem in ListConfigElemStrings(itemdesc) )
     var cfg_elem := itemdesc[cfgelem];
     if ( cfg_elem.SomeProperty )
          //Add it to a list or whatever
     endif
endforeach

Re: Maybe noob question

Posted: Tue May 11, 2010 12:13 pm
by Basara
Could .isa(POLCLASS_WEAPON) be used instead of searhing for a prop?

Re: Maybe noob question

Posted: Tue May 11, 2010 12:50 pm
by Austin
Only if you have a tangible object - he wants all the itemdesc.cfg entries.

Re: Maybe noob question

Posted: Tue May 11, 2010 1:07 pm
by Basara
Hate to break it to you, but its not real, none of it is tangable. :P

(But i see what you mean)

Re: Maybe noob question

Posted: Wed May 12, 2010 4:14 am
by xeon
Well, for now I've done exactly what I said.
I read all the itemdesc.cfg entries, and, for each of them, I check for a .property which only Weapons have.

The .isa(POLCLASS_WEAPON) isn't applicable, because I'm not using an item, but a CfgfileItemRef :/

This is a shame anyway. Suppose I've got a cfg file in which I define multiple items with no exclusively cprop, p.e.
apple yewapple {}
apple britainapple {}
pear yewpear {}

And I want all and only apples. I've to put a CProp or a property which exclusively identify them :/

Re: Maybe noob question

Posted: Wed May 12, 2010 7:35 am
by Basara
Looking over some of my own itemdesc for weapons, could you not search on one of the following entries?

Speed
Damage
SkillId
Attribute

Some would apply to other files such as NPCdesc but you're specifically checking itemdesc.cfg's

Re: Maybe noob question

Posted: Wed May 12, 2010 7:06 pm
by Austin
I guess like.. when you do

Code: Select all

var elem := FindConfigElem("key", cfgfile);
var elem := cfgfile[elem]
Maybe the elem reference object could have a property to get the prefix and suffix of the elem name...