How block implicit action? TADS3

In the code below, I’ve got a box that is both a surface (so it can have a keyhole, although that is not shown) and a container that will reveal what is inside when it is unlocked. I want to make it easy on the player so that if he types >Unlock box, it will both unlock and open the box. But my code to do that isn’t getting reached. Instead it is getting executed as an implict action, so that if he types >Unlock box with frob, it gets a “not suitable” response, and if he types >Unlock box with key, it simply says, “Unlocked” and unlocks (but does not open) the box.

How can I block the implicit “unlock” action so I can use my own code?

(Also, LT3 talks about a KeyedLockable Class might be useful for this, but it doesn’t seem to be in the libary any more. Is it still around somewhere?)



th_greybox: ComplexContainer, Fixture 
    name = 'grey box'
    vocabWords = 'grey gray box'
    location = rm_glick
//    keyList = [th_greybox_key]
    subSurface: ComplexComponent, Surface {}
    subContainer: ComplexComponent, KeyedContainer { keyList = [th_greybox_key]} //I'm surprised this worked!

    dobjFor(OpenWith) asDobjFor(UnlockWith)
    dobjFor(UnlockWith) { // TODO. 9/4/15. When I use KeyedContainer, this code is not getting called. Implicit unlock is grabbing it first.
        verify () {}
        action () {
            if (gIobj != th_greybox_key) {
                "You can't unlock the spell blocker with that. ";
            else {
                "You unlock and open the box. Inside, you see a battery. ";

KeyedLockable is a typo; the class is called LockableWithKey. I suspect the problem you’re encountering may be due to defining dobjFor(UnlockWith) on the parent object (th_greybox). Have you tried moving that code into the { } code for the subContainer? It’s worth a try, anyway.

Thanks, Jim. That did the trick.

On a side note, after being out of commission for 8 weeks I’m back working on my project. I really appreciate all the help you have provided (to me and to others in the forum). Is there any way I can reciprocate?



I dunno about him, but some of us will feel pretty reciprocated (well, since I haven’t actually helped, maybe just ciprocated) by you releasing your game. :slight_smile:

[rant]This is just my way of showing encouragement. Could use some work, I guess…[/rant]

It’s kind of a “pay it forward” situation. Several people helped me a LOT when I was learning IF programming. I’m no longer active as an author (though of course I have a half-finished game on my hard drive). But I now have enough knowledge that I’m able to make a few suggestions to others … at least with respect to the less perplexing problems. As you become more knowledgeable, you’ll be able to do the same.

And FWIW, the ComplexContainer class is one of T3’s more convoluted concepts. Took me a long time to grasp it.