Getting Vocabwords from Dynamically Created Object [Solved]

Hi again; I’m having another issue with words. In my sandbox game, I make some objects at run-time and use initializeVocabWith() to set the new object’s vocab words, but then I have to retrieve those vocab words and simply calling the object’s vocabWords property gives me nothing. I was originally under the impression that initializeVocabWith() added words to the vocabWords property, but since vocabWords is apparrently remaining blank, is this actually not the case? How then do I get my obj’s vocab words?

No, it’s rather other way around. Contents of vocabWords property is parsed by initializeVocabWith function (in preinit phase I think or through the Thing constructor on dynamically created objects) and each word is then added to the vocabulary by calling cmdDict.addWord(self, cur, wordPart) where cmdDict is a dictionary intrinsic class of the parser (tads.org/t3doc/doc/sysman/dict.htm).

VocabWords property is a convenient way to provide object’s vocabulary for the parser. Format is chosen to be easily entered by game author. But what is easy for an author is not easy for computer - parser can’t work with this string of multiple words directly, so therefore each word is categorized by speech part (noun, adjective,…) and entered into lookup tables deep inside the parser code in an interpreter. Once the vocabWords are fed into the parser, vocabWords property is no longer used in any way.

There are methods to modify vocabulary (addWord, removeWord - see link above), but for your specific question it may not to be overly effective, you probably can’t explicitly get words for a specific object, only either iterate through all game words or search for a specific word and get a list of matching objects for that word. So if you want to read vocabWords in the format in which they are usually entered, then save them in vocabWords property by yourself.

@tomasb: Okay, thanks. I actually don’t need any particular format; right now, I’m more interested in transferring the vocabulary of a parent object to a child, e.g. a “pine tree” becoming “pine wood” and then a “pine wood chair”. Since ‘pine’ (etc.) is currently fed into my first object’s constructor as a string argument, I’ll see if I can nail it to a property myself, as you mentioned. Thanks again!