Page 1 of 1

Custom property in itemdesc.cfg?

Posted: Tue Sep 03, 2013 12:47 pm
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?

Re: Custom property in itemdesc.cfg?

Posted: Tue Sep 03, 2013 12:51 pm
by Tomi
in that case you need to define it as Cprop Name value in the itemdesc

Re: Custom property in itemdesc.cfg?

Posted: Tue Sep 03, 2013 11:37 pm
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 :|

Re: Custom property in itemdesc.cfg?

Posted: Wed Sep 04, 2013 12:52 am
by RusseL
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?

Posted: Wed Sep 04, 2013 3:47 am
by xeon
I see.
Thank you RusseL.

Re: Custom property in itemdesc.cfg?

Posted: Wed Sep 04, 2013 4:00 am
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. :)

Re: Custom property in itemdesc.cfg?

Posted: Wed Sep 04, 2013 4:10 am
by xeon
Yes, that's correct Yuki.

Re: Custom property in itemdesc.cfg?

Posted: Wed Sep 04, 2013 10:51 am
by Turley
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?

Posted: Wed Sep 04, 2013 12:23 pm
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

Re: Custom property in itemdesc.cfg?

Posted: Wed Sep 04, 2013 7:15 pm
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.

Re: Custom property in itemdesc.cfg?

Posted: Wed Sep 04, 2013 8:47 pm
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.

Re: Custom property in itemdesc.cfg?

Posted: Thu Sep 05, 2013 4:57 am
by RusseL
Configs are everytime in memory since you once read them, that is fast:)