Keeping a key from working until other conditions are met

I am trying to create a situation where a door cannot be unlocked, even if the player has the key, until certain other actions have been accomplished. I thought of setting a counter to zero and incrementing it every time one of the other actions gets accomplished. Then I would have a multiple-If statement of some kind saying, in effect, "If the player has the key and the counter is less than the required value, say “There must still be something left for you to do until you leave this place.” else if the player has the key and the counter equals the required value, allow the door to be unlocked. If the player doesn’t have the key, of course, it shouldn’t even get to the if…else.

Seems that it should work, but how to write the code is beyond me at this point. Any help gratefully accepted!

You could use a counter variable, but in this case a simple decide phrase would do the trick. As in:[code]The Lab is a room.
The back door is a locked door. It is west of the Lab. It has matching key the brass key. The brass key and the ball are in the Lab.

The painting is a fixed in place thing in the Lab. It has description “This is a clue necessary to solving the puzzle.”

To decide if the lab requirements are met:
if we have not examined the painting, decide no;
if the player does not carry the ball, decide no;
decide yes.

[This next rule will only fire if the player has the brass key:]
Check unlocking the back door with the brass key:
unless the lab requirements are met,
say “You feel like there’s something more to do here first.” instead.

test me with “unlock door / key / unlock door / x painting / unlock door / get ball / unlock door with key”.[/code]Note that the decide phrase continues to check the conditions until a decision is made (i.e. it doesn’t bother to check for the ball if the painting hasn’t been examined and will only get to “yes” if both conditions have been met. Also, since the check rule contains “with the brass key”, it will only fire if the player has the key (although it will perform an implicit take if the player can reach the key but doesn’t actually have it.) See Michael Gentry’s post from this other thread for an example where only some conditions need to be met before doing something.

You might also want to add a rule for suplying a missing noun, so the player doesn’t have to specify the key. If so, see ch 17.30.

Excellent! That’s just what I needed. Thanks, Skinny Mike.

Now (of course!) I have another problem. Somehow I can easily put things ON things but not IN things.

This works just the way I would expect:

After putting Big Bird on the yellow couch for the first time, award 1 point.

But this:

After putting Oscar into the green garbage can for the first time, award 1 point.

Leads to this response:

…and I run up against the same thing over and over in different places. What is it I am not understanding about putting things IN things? :confused: (And yes, I have tried both “Putting in” and “Putting into.”)

Inform’s name for this action is “inserting it into”, not “putting it into”. (You can check the Actions section of the Index to find out the name of an action you want to handle.) So if you phrase the rule this way, it should work:

After inserting Oscar into the green garbage can for the first time, award 1 point.

AHA! HA! I KNEW it had to be a problem with the syntax but had not found that one yet. Thanks, Emerald, for helping without sneering. :mrgreen: