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?
Custom property in itemdesc.cfg?
Re: Custom property in itemdesc.cfg?
in that case you need to define it as Cprop Name value in the itemdesc
Re: Custom property in itemdesc.cfg?
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 
Re: Custom property in itemdesc.cfg?
then.... there is no other way as:
Code: Select all
var itemdesccfg := readconfigfile(":*:itemdesc");
customprop := itemdesccfg[youritem.objtype]."customprop";Re: Custom property in itemdesc.cfg?
I see.
Thank you RusseL.
Thank you RusseL.
Re: Custom property in itemdesc.cfg?
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.
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.
Re: Custom property in itemdesc.cfg?
Yes, that's correct Yuki.
Re: Custom property in itemdesc.cfg?
custom members inside the itemdesc can of cause be done by reading the config. we have a complete module for this purpose 
Re: Custom property in itemdesc.cfg?
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
Re: Custom property in itemdesc.cfg?
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.
Re: Custom property in itemdesc.cfg?
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.
Re: Custom property in itemdesc.cfg?
Configs are everytime in memory since you once read them, that is fast:)