# How can I check if a container is "Complete"?

Hi again.

I have an envelope that needs to contain three things to be “complete” so that it can then be posted and solve a puzzle.

``````Check giving the envelope to Gordon when the player encloses the envelope:
if the envelope is incomplete, say "you can't or whatever.";
otherwise:
say "Licking the ancient sealing gum you close up the envelope and hand it to Gordon.";
increase the score by 1.
``````

The code I have is below. I think the issue is the “contains”, or “encloses” or the order. I’ve gone around and around so many times the word “envelope” itself looks like total nonsense. Anyway, maybe I’ve got it totally wrong too.

``````the envelope can be complete or incomplete. the envelope is incomplete.

every turn:
when the envelope encloses the order form and the quarter and the dollar bill;
now the envelope is complete.
``````
1 Like

Couple things here – first, the main thing you want to do here is create a definition telling Inform what “complete” means for the envelope:

``````To decide if the envelope is complete:
if the envelope encloses the order form and the envelope encloses the quarter and the envelope encloses the dollar bill, decide on true;
decide on false.
``````

Couple subtleties here – first, since this is a definition, you don’t need the prefatory “the envelope can be complete or incomplete” statements, so you can just check “if the envelope is complete” without anything else (if you want to be able to use “incomplete” you can just define a new condition as the mirror of the first).

Second, you can just say “[object] is inside the envelope” – I stuck with “enclosed” in case there’s some subtleties about sub-containers or supporters within the envelope. But “inside” might be more intuitive.

Third, note that you’re doing this as a check rule, which means that even when the envelope is complete, you’re not actually handing it over to Gordon and it stays in the player’s inventory (and you can keep giving it over to get an infinite score!), because the standard rules’ block giving rule is preventing the hand-over from actually happening (and spitting out its standard response, which you probably don’t want). To be more aligned with how Inform does things, you might want to break the consequences when the action succeeds out into an After rule instead – and get rid of that pesky block giving rule in this particular circumstance.

Finally, just flagging that every turn rules aren’t a great way to do this sort of thing in general – while you can get it to work using similar syntax to what I did, note that you’d need an inverse every turn rule to make the envelope incomplete if anything leaves the envelope later. So things can get pretty crufty (and for sufficiently complex games or low-spec machines, slow-running).

Putting it all together, I get something like this:

``````Test chamber is a room.  Gordon is a man in the test chamber.  The envelope is a container in the test chamber. the order form is in the test chamber.  The quarter is in the test chamber.  The dollar bill is in the test chamber.  Use scoring.

To decide whether the envelope is complete:
if the envelope encloses the order form and the envelope encloses the quarter and the envelope encloses the dollar bill, decide on true;
decide on false.

To decide whether the envelope is incomplete:
If the envelope is complete, decide on false;
Decide on true

The block giving rule does nothing when the noun is the envelope and the second noun is gordon.

Check giving the envelope to gordon:
If the envelope is incomplete:
Say "You can't or whatever.";
Stop the action.

After giving the envelope to Gordon:
say "Licking the ancient sealing gum you close up the envelope and hand it to Gordon.";
increase the score by 1.
``````

EDIT: relevant bit of the docs is here; you might also want to read the subsequent, more general section which goes beyond booleans.

1 Like

That’s great. I appreciate the work you put into this for me.

2 Likes

You might also want to add a carrying capacity so that the player can’t put more than 3 things in the envelope.

Unless @DeusIrae’s code does that already but I don’t think it does. (Or unless you’ve added it already and I’m stating the obvious…)