Exiting a barrel only when the conditions are right.

I’ve been stuck on this for ages and it’s killing me.

Basically, I want the player to find out they’re inside a barrel only after lighting a match, and then have them not be able to do anything until they climb out of the barrel.

This is what I have but no matter what I change, I keep hitting different errors, at the moment this will never let me leave, it doesn’t allow for exit commands.

Storeroom is a dark room
Light source is a kind of thing.
open barrel is an enterable scenery container in Storeroom. Player is inside open barrel.

instead of doing something when player is inside open barrel and light source is lit:
	say "You are crouched inside something. Something whos walls are pushing hard against you and are preventing you from moving.[paragraph break]".

First of all, let’s sort out the light source. Your condition “light source is lit” isn’t meaningful as it stands, since a light source is a kind of thing, not a thing.

I wouldn’t bother declaring a light source a kind of thing unless you’re going to have several in your game which behave in similar ways. I would make the match a device and associate striking the match with switching it on. (There are lots of other ways of doing it.)

The match is a device.  The player carries the match.

Understand "strike [the match]" or "light [the match]" as switching on.  
Carry out switching on the match: now the match is lit.
Report switching on the match: say "You strike the match, and it bursts into flame."; rule succeeds.

Understand "put out [the match]" or "extinguish [the match]" as switching off. 
Carry out switching off the match: now the match is not lit.
Report switching off the match: say "You put out the match."; rule succeeds.

Now we want to stop the player from doing anything in the barrel before striking the match. Well, not quite anything. We probably want them to be able to look (although they won’t see anything, since it’s dark). And they should be allowed to take inventory, since otherwise they might not know they’re carrying a match. And maybe TAKE MATCH should be permitted, even though it’s redundant since they already have it. And maybe we’ll think of more exceptions later.

We will use the “Instead of doing something other than …” construction for our rule. Since our list of exceptions is moderately complicated, we’ll define a “type of action” (barrel activity) to cover them.

Looking is barrel activity. Taking inventory is barrel activity. Switching on the match is barrel activity. Switching off the match is barrel activity. Taking something held is barrel activity.

Instead of doing something other than barrel activity when the player is inside the open barrel and in darkness:
	say "You are crouched inside something. Something whose walls are pushing hard against you and are preventing you from moving."

Maybe some blocked actions should give a different refusal message.

Instead of dropping the match when the player is inside the open barrel and in darkness:
        say "That doesn't sound like a good plan."

When the player first strikes the match, there should be some sort of message.

After switching on the match when the player is inside the open barrel for the first time:
	say "The flickering light shows that you are in a plain wooden barrel, in what looks like some sort of lumber room."

And now you still want to block most activities while the player is in the barrel. You shouldn’t say now that the barrel prevents them from moving (since they can in fact get out).

Instead of doing something other than crouching activity or exiting when the player is inside the open barrel:
	say "You are crouched inside the barrel, which prevents you from doing much."

For simplicity, you might well decide to block the player from extinguishing the match once they’ve lit it.

Instead of switching off the match in the storeroom:
       say "And plunge myself back into darkness? No thanks!"