What's wrong with this code - TADS3.1

The following block of code gives me two warning when I compile my game.

+++myKhakiPockets: BagOfHolding, Component, RestrictedContainer
'pockets' 'pocket'
"One of the things you like about these khakis is that they have nice, deep
pockets. "
theName = 'your pockets'
aName = 'your pockets'
disambigName = 'your khaki pockets'

/* we're restricted to pocketable items */
canPutIn(obj) { return obj.okayForPocket; } 
cannotPutInMsg(obj) { return '{The dobj/he} wouldn\'t fit very well in your
 pocket. '; }

/* We have a high affinity for best-for-pocket items. */
affinityFor(obj) { return obj.bestForPocket ? 200 : 0; }
contentsLister: thingContentsLister {
 showListPrefixWide(itemCount, pov, parent)
  {"In your pocket you have ";}
 showListPrefixTall(itemCount, pov, parent)
  {"In your pocket you have ";}

The two warnings I receive are that ‘okayForPocket’ and ‘bestForPocket’ are undefined. Can anyone help me with this problem :question: I can find no reference to these objects in the TADS manuals.

If you didn’t define those properties, then they don’t exist. Did you define them somewhere?

You need to modify Thing so as to provide those two properties on ALL objects. Set them to nil by default and to true for things that you want the player to be able to put in the pocket.

Dunno where you got that code…

This code is from the ‘me.t’ module of ‘Return To Ditch Day’. I included that module in my code and modified it to fit my game. I did not define the two objects that are giving the warnings. Without those two sections of code my game compiles and runs with no problems; Although the total game source is still rather bare.

I, now, somehow get the feeling that objects we wish to place in our pockets must somehow be marked with one of those two declarations. Boy, am I confused :exclamation:

I could not find any reference to them in RTDD or the manuals and I did a lot of searching.

Here I am confused too. RTDD doesn’t define them on the Thing class (or anywhere else) as nil. And that is IMHO ok, because obj is passed as a parameter and it’s not known by the time of compilation which object will be passed to these methods. So from a statical analysis during compilation such a warning couldn’t be produced IMHO. My assumption is, that the warning is not about the code shown above. Could you post exact warning message and check which lines are exactly referred by the warning?

Here’s a complete list of files (with line numbers) of where these two identifiers occur:

(Using the “grep” command - behold the power of Unix :stuck_out_tongue:)

grep -nr "okayForPocket\|bestForPocket" rtdd rtdd/intro.t:2119: okayForPocket = true rtdd/intro.t:2442: okayForPocket = true rtdd/bridge.t:339: okayForPocket = true rtdd/me.t:307: canPutIn(obj) { return obj.okayForPocket; } rtdd/me.t:312: affinityFor(obj) { return obj.bestForPocket ? 200 : 0; } rtdd/bookstore.t:342: okayForPocket = true rtdd/campus.t:230: okayForPocket = true rtdd/campus.t:231: bestForPocket = true rtdd/campus.t:268: okayForPocket = true rtdd/campus.t:269: bestForPocket = true rtdd/campus.t:334: okayForPocket = true rtdd/campus.t:335: bestForPocket = true rtdd/campus.t:343: okayForPocket = true

So they’re not actually defined in a class, but just set per object as needed.

That last post did the job! I used Boxer99 to search the RTDD sources and found the information. I think that RTDD contains a wealth of of examples on how to get things done in TADS.

Changing the subject. A long time back, I was trained in Unix and serviced both the software and the machines that employed it. This brings up a question. What do you think of KUBUNTU? I got a 750GB drive for Christmas and I’m considering giving it another try.

You can install Ubuntu/Kubuntu inside Windows and boot it right there. Great for trying it out without having to bother with resizing hard disk partitions. And you can uninstall simply by deleting its directory.

To get that version of (K)Ubuntu, you choose the “Wubi - Install from Windows” download option.