Custom property in itemdesc.cfg?

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
xeon
Forum Regular
Posts: 338
Joined: Fri Oct 31, 2008 3:18 am

Custom property in itemdesc.cfg?

Post by xeon »

I was thinking that I could add a custom property to an object definition in its itemdesc.cfg entry, and retrieve it in my script through a simple "object.getprop("propertyname")", but it doesn't work.
I am remembering wrong?
Tomi
POL Developer
Posts: 478
Joined: Tue Feb 21, 2006 5:08 pm

Re: Custom property in itemdesc.cfg?

Post by Tomi »

in that case you need to define it as Cprop Name value in the itemdesc
xeon
Forum Regular
Posts: 338
Joined: Fri Oct 31, 2008 3:18 am

Re: Custom property in itemdesc.cfg?

Post by xeon »

Ok, but in that way I have a CProp defined for every object in the world, instead of having the property defined only once. So I'm wasting space in items.txt and memory on the server :|
RusseL
Forum Regular
Posts: 375
Joined: Fri Feb 20, 2009 8:30 pm

Re: Custom property in itemdesc.cfg?

Post by RusseL »

then.... there is no other way as:

Code: Select all

var itemdesccfg := readconfigfile(":*:itemdesc");
customprop := itemdesccfg[youritem.objtype]."customprop";
xeon
Forum Regular
Posts: 338
Joined: Fri Oct 31, 2008 3:18 am

Re: Custom property in itemdesc.cfg?

Post by xeon »

I see.
Thank you RusseL.
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Re: Custom property in itemdesc.cfg?

Post by Yukiko »

Xeon,
What you are describing is a "custom member" rather than a "custom property". I'm not being picky here. It's important to keep the definitions straight to avoid confusion. :)
xeon
Forum Regular
Posts: 338
Joined: Fri Oct 31, 2008 3:18 am

Re: Custom property in itemdesc.cfg?

Post by xeon »

Yes, that's correct Yuki.
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Custom property in itemdesc.cfg?

Post by Turley »

custom members inside the itemdesc can of cause be done by reading the config. we have a complete module for this purpose :)
xeon
Forum Regular
Posts: 338
Joined: Fri Oct 31, 2008 3:18 am

Re: Custom property in itemdesc.cfg?

Post by xeon »

Yes, but you have to do like RusseL said, reading the cfgfile, the entry and the property. And this is slower than using a ".member" syntax or the GetObjProperty() call
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Re: Custom property in itemdesc.cfg?

Post by CWO »

Really it depends on how much you're using this member and this item. Sure it's slower than GetObjProperty() (but really, this isn't noticeable unless you want to do it a thousand times per second) but if you set a custom CProp, just remember, a CProp takes more memory since it has to be stored in memory on every item instead of appearing just once in a config file. You could also make your own custom config file that stores these members under the objtypes or define an array of objtypes and do a comparison instead of looking up a custom member or prop on an item.
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Custom property in itemdesc.cfg?

Post by Turley »

the em functions for cfg files maybe look like it will be an io operation, but its only a lookup inside a memory structure. thus quite fast.
RusseL
Forum Regular
Posts: 375
Joined: Fri Feb 20, 2009 8:30 pm

Re: Custom property in itemdesc.cfg?

Post by RusseL »

Configs are everytime in memory since you once read them, that is fast:)
Post Reply