pockets(tads 3)

For some reason, when I try to place something of Class Pocket in something of class PocketContainer, class PocketContainer screws up.

class Pocket: Hidden, Container 'pocket*pockets' 'pocket' desc() { if(hole.isIn(obj) || holeSide.isIn(obj)) { "There's a hole in me pocket! "; if (hole.isIn(obj)) hole.discover(); if (holeSide.isIn(obj)) holeSide.discover();} else "Your pocket. Or at least, now it is. ";} specialDesc() { if(!isIn(me)) "You dropped your pocket. "; else "Your pocket is where is belongs. ";} isEquivalent = true bulk = -2 weight = -1 bulkCapacity = 4 weightCapacity = 3 ; class PocketContainer: Wearable, Container maxPockets = 2 iobjFor(PutIn) { verify() { inherited; if(!gDobj.ofKind(Pocket)) illogical( '(dobj) isn\'t a pocket. '); if(contents.length >= maxPockets) illogical( 'It hasn\'t any room! '); }} ;

I’m at work at the moment, so I don’t have access to the TADS 3 Workbench, but I don’t suppose you could go into a little more detail about what you’re trying to do and why?

Also, I’m wondering why the Pocket has negative weight and bulk, because that seems like something that might potentially lead to problems when you place it in another container.

Right, the problem isn’t specific to the Pocket class. There’s a nil object reference when you try to place any object in the PocketContainer. TADS doesn’t seem to be able to access gDobj at that level. One simple solution is running the check in check() instead of verify() and replacing the illogical() with failCheck().

I’m not sure exactly why you can’t use gDobj in verify. It might be a design choice - since verify is supposed to be about those actions which are easily excluded. In other words it might be that if the action is sensible (eg. putting things in objects of this kind) then it should pass the verify stage regardless of whether the context is sensible.

Alternatively, there might just be a way to access the direct object that I don’t know about. I’ve already been tripped up by the fact you have to use DirectObject when you remap a verb.

I wanted to make a pocket, which would increase the amount you could hold, so it has negative bulk, and pockets have to go in clothes, but not all clothes have pockets, so I had to make a new class. When you place it in a container, wouldn’t it generally add the bulk to the bulk of what’s in the container… wait… it has to be stretchy container… ok I will change PocketContainer to Wearable, StretchContainer.

The whole idea is you dropped your pockets everywhere, and you are on a quest to find them. It was my idea of a retutorial, as I was mostly using Inform 7, but Inform 7 wasn’t doing what I wanted and I found it’s ‘database’ to be harder to search, but that’s just me. I had used TADS before, but that was long ago enough for me to forget the words (most of the syntax I still get). There are also two holes, each one begins in a pocket. You can transport yourself through the holes, and I have that figured out, but now I’m trying to figure out how to see and hear through them (reading about SenseConnectors), and hopefully it will come to a point where NPC’s will put the hole in their pocket, so there is a whole room in their pocket, and drag you to secret locations. The PocketContainers are used as ‘equipment’ in this ‘RPGish’ thing. I hope it works out.

I still need to look over the displaying of correct grammar, ‘There’s a hole in me the pocket!’("There’s a hole in me <<hole.location.theName>>! ") That’s just silly. I’ll find it.

Anyhow… Thanks Pacian! My pockets fit in my pants!!! WOO!

When verify is run, the direct and indirect objects haven’t necessarily been decided yet, because verify is part of the decision process. In some situations, you could fudge this by using “gAction.dobjList_[1].obj_” to get the first possible direct object. But the PutIn action’s indirect object verification runs before its direct object verification, so there isn’t even a list of possible direct objects at this stage. The easiest thing to do, as Pacian said, is use the check stage instead.

That won’t work, because you’ll be increasing the amount that the coat can hold, but you can only put pockets in the coat anyway.