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
Maybe noob question
Moderator: POL Developer
Re: Maybe noob question
Yeah you pretty much have to do that
Something like
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
Could .isa(POLCLASS_WEAPON) be used instead of searhing for a prop?
Re: Maybe noob question
Only if you have a tangible object - he wants all the itemdesc.cfg entries.
Re: Maybe noob question
Hate to break it to you, but its not real, none of it is tangable.
(But i see what you mean)
(But i see what you mean)
Re: Maybe noob question
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 :/
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
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
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
I guess like.. when you do
Maybe the elem reference object could have a property to get the prefix and suffix of the elem name...
Code: Select all
var elem := FindConfigElem("key", cfgfile);
var elem := cfgfile[elem]