Complete newbie question about OpenableContainer

I have an openable, restricted container that is initially closed. If I say “put x in container”, it assumes I want to open it first, which it does.

I just can’t hunt down the syntax to make the user explicity open the container, and I don’t even know if it’s possible. I could make it into a locked container, but I’d rather not.

Anyway, sorry for the very basic question, but I’m just getting started.

Heat

What you’re asking about are called implicit actions or implicit commands, and in this case it’s controlled by a precondition on the PutIn action.

Some links to docs:

tads.org/t3doc/searchGo.php?d=do … action.htm
tads.org/t3doc/doc/techman/t3res.htm#precond

In the second link there’s this example,

Hopefully that’ll get you started.

Thanks for the quick reply. I’ll take a look at it, but I’m guessing that will answer my questions.

I feel kind of foolish for asking, but I really appreciate the help.

Don’t mention it, and while it’s definitely possible it may not be straightforward :slight_smile:. I’m looking at it right now myself in fact, and the easy solution didn’t work :slight_smile:.

edit (ninja’d by Nikos – good name for a game? – below): well, it was easy after all, a simple mistake on my part. I was using dobjFor instead of iobjFor.

The transcript:

And code:


#charset "us-ascii"

#include <adv3.h>
#include <en_us.h>

versionInfo: GameID
    IFID = 'foo'
;

gameMain: GameMainDef
    /* the initial player character is 'me' */
    initialPlayerChar = me
;

startRoom: Room 'Start Room'
    "This is the starting room. "
;

+ me: Actor
;

++ box: OpenableContainer 'box' 'box'
    iobjFor(PutIn) { preCond = (inherited() - objOpen) }
;

++ cat: Actor 'cat' 'cat'
;

What George said. The exact code you want in your container object:

iobjFor(PutIn) { preCond = inherited() - objHeld }

(You want “iobjFor” rather than “dobjFor” because the container is the indirect object in PUT THING IN CONTAINER.)

Allow me to derail this thread a bit to say I forgot how bloody awesome the Tads 3 docs and reference help are. Probably overwhelming at first though.

Thanks guys… You’ve been a big help. Like I said, I’m a newbie to this, and I write software for a living – it’s a matter of getting a handle on the framework and I’d rather ask the experts than spend a week trying to blindly guess.

This probably won’t be my last idiotic question, but I really do appreciate your patience and taking the time to research it for me.

Since you write software for a living, I’m pretty sure you’ll be able to figure out what you need to know. A good place to look, if you’re comfortable reading code, is the Library Reference Manual. it’s hyperlinked to the source code for the entire library, so you can see what any method is doing. Of course, it’s still a bit of a tangle. Workbench (assuming you’re on Windows) has breakpoints and Watch Expressions. Also a stack trace. All very useful.

The thing that threw me at first (and I’m not a professional programmer!) is the number of macros and templates. These cause ordinary procedural code to LOOK like declarative code. something like iobjFor(PutIn) is a macro. The macros are incredibly convenient – they just look a bit weird.

And please feel free to post questions, idiotic or otherwise!