Maybe noob question

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
xeon
Forum Regular
Posts: 338
Joined: Fri Oct 31, 2008 3:18 am
Location: Italy

Maybe noob question

Post 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:
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Re: Maybe noob question

Post 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
Basara
Novice Poster
Posts: 47
Joined: Fri Oct 13, 2006 6:37 am
Location: UK

Re: Maybe noob question

Post by Basara »

Could .isa(POLCLASS_WEAPON) be used instead of searhing for a prop?
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Re: Maybe noob question

Post by Austin »

Only if you have a tangible object - he wants all the itemdesc.cfg entries.
Basara
Novice Poster
Posts: 47
Joined: Fri Oct 13, 2006 6:37 am
Location: UK

Re: Maybe noob question

Post by Basara »

Hate to break it to you, but its not real, none of it is tangable. :P

(But i see what you mean)
xeon
Forum Regular
Posts: 338
Joined: Fri Oct 31, 2008 3:18 am
Location: Italy

Re: Maybe noob question

Post 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 :/
Basara
Novice Poster
Posts: 47
Joined: Fri Oct 13, 2006 6:37 am
Location: UK

Re: Maybe noob question

Post 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
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Re: Maybe noob question

Post 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...
Post Reply