Automated Drawers by Emily Short

This topic is for discussions related to Automated Drawers by Emily Short

It isn’t clear how one references a drawer in Inform 7 at compile time. Here’s a simple example of the sort of thing that I am trying to do:

Include Automated Drawers by Emily Short.
Start is a room. The desk is in start. Two horizontal drawers are part of the desk. The pencil is in the desk’s left drawer. The paper is in the desk’s right drawer.

This does compile, but it does not work:

oops
An Interactive Fiction by Eric Conrad
Release 1 / Serial number 190915 / Inform 7 build 6M62 (I6/v6.33 lib 6/12N) SD

Start
You can see a desk here.

open left
You open the left drawer of the desk.

x left
The left drawer is empty.

(Where is the pencil?)

I’m not sure how this comes about, but here’s one way to get it working:


The Study is a room.

The desk is in the study. Two horizontal drawers are part of the desk.

The chinese lacquer box is in the study. Two horizontal drawers are part of the box.

The pencil is nowhere. The paper is nowhere.

The incriminating letter is nowhere.

When play begins:
	move the incriminating letter to a random leftmost drawer enclosed by the box;
	let left-desk-drawer be a random leftmost drawer enclosed by the desk;
	move the pencil to left-desk-drawer;
	move the paper to left-desk-drawer.
1 Like

What happens is that at compile-time line, when Inform doesn’t think there’s something called the left drawer, it takes “The pencil is in the desk’s left drawer” to declare a new off-stage container called “the desk’s left drawer,” and it puts the pencil there. You can see this by checking the Map in the Index (under the World tab).

Which is not very useful from the point of view of what you want to do. I’m not sure you can in fact refer to an individual drawer generated by this at compile time. At compile time, AFAICT, the code just creates two completely generic drawer objects as part of the desk. The work of setting one to leftmost and one to rightmost, etc., is done in the “initialize drawers rule,” which takes place When Play Begins.

So I think you might have to move the objects into the drawers during the When Play Begins stage:

Include Automated Drawers by Emily Short.
Start is a room. The desk is in start. Two horizontal drawers are part of the desk. 

There is a pencil. There is some paper.

When play begins:
	now the pencil is in a random leftmost drawer incorporated by the desk;
	now the paper is in a random rightmost drawer incorporated by the desk.

Which is sadly inelegant, but for most purposes should get the job done.

(One thing that I think you might be thinking of here is that, if you have an assembly created by lines like “A pouch is a kind of container. A kangaroo is a kind of animal. Every kangaroo incorporates a pouch. Start is a room. Bessie is a kangaroo in Start,” then at compile time the pouch will be created with the name “Bessie’s pouch,” so you can write “A joey is in Bessie’s pouch” and the joey will wind up in the right place. But this isn’t how Automated Drawers does it. Also I checked and with parts it only seems to work for parts of people, which I hadn’t realized before, which is why I had to use kangaroos as a kind of person that incorporates a container, and yes I know it’s only the jills.)

3 Likes

Here’s a bare-bones alternative which allows you to refer to the parts at compile time. It’s adapted from example 56 (“Being Prepared”), under “4.15. Assemblies and body parts”, and taking into account info from “4.16. Names made in assembly”.

A two-drawered-desk is a kind of thing.

A drawer is a kind of container. It is openable. It is usually closed.

A drawer (called its left drawer) is part of every two-drawered-desk.
A drawer (called its right drawer) is part of every two-drawered-desk.

The Study is a room.

The desk is a two-drawered-desk. The desk is in the study.
The pencil is in the desk's left drawer. The paper is in the desk's right drawer.

The chinese lacquer box is a two-drawered-desk. The box is in the study.
The incriminating letter is in the box's right drawer.

As I said, it’s rather bare-bones as it stands. But maybe useful nonetheless.

3 Likes

Three very good replies to my plea for help. The first two use the Automated Drawers extension, and the third does not.

The two that do use the extension use the same approach, with phrasing that differs in the choice of participle. Both dynamically place objects in the drawers at the beginning of a scene (“when play begins”), so the placement is during run time, but the wording has to pass through the compiler.

(Suggestion for the extension: In the extension’s only example, the desk is empty. Make the example more useful by hiding something in one of the drawers.)

For the record, the variations in wording are, thanks to Matt and StJohn:

When play begins:
    move the pencil to a random leftmost drawer enclosed by the desk;  [StJohnLimbo]
    move the paper to a random rightmost drawer incorporated by the desk. [Matt Weiner]

The third solution, also by StJohnLimbo,implements the desk directly, without the extension. The advantage is simplicity and clarity of language - the desk can be filled statically, that is, as part of the startup state rather than as part of setting up a scene. The disadvantage is that in a larger project, it precludes using the extension for fancier objects with drawers.

Thanks for the prompt replies.