First taking something in a container

Bear with me here, since I seem to have lost all of my Inform 7 somehow. Is there a better way to do this?

Before doing something other than taking or removing when the noun is not nothing and the noun is in the knapsack and the player carries the knapsack and the knapsack is open:
	say "(first taking [the noun])";
	silently try taking the noun;
	if the player carries the noun:
		continue the action;
	stop the action;

It just feels… yucky, especially that rule condition.

You’re basically remaking implicit taking? I’m not sure what the implicit taking activity is doing under-the-hood (based on the Standard Rules, it seems to be I6 code and I don’t know where to find that) but I think it’s more-or-less what you wrote.

(e) Causing implicit takes which wouldn’t otherwise happen. Suppose we have a photographing action, and there are very small flowers which can’t conveniently be snapped without being first picked. We then want an implicit take to occur, even though we wouldn’t want this for other sorts of photography. So:

Check an actor photographing a flower:
    if the actor is not carrying the noun:
        carry out the implicitly taking activity with the noun;
        if the actor is not carrying the noun, stop the action.

Note that if the activity doesn’t succeed in taking the item, it’s expected to print some text explaining this, which is why we don’t need to say anything further.

Yes and no. You were right to point me to the implicit taking activity. But I’m more worried by my feeling that something as simple as always taking when using something in a carried container shouldn’t have such an icky condition. But maybe it just has to.

Since the items can’t be removed from the knapsack unless they’re visible, maybe you could skip the open part? Some things are down to taste, but I’d either put the criteria in a to decide definition or else try something like this. “Doing something other than removing or taking” could stay where it is, but it’s easier for me to read this way.

before doing something with something held by the knapsack when the knapsack is held by the player:
	unless removing or taking:
		say "flergh"

Maybe? Just an idea

Is there a reason you want all actions to involve taking the object, rather than just ones that require a held noun?

2 Likes

If you really want it, though:

Last before doing anything except taking or removing:
    remove the noun from the knapsack;
    remove the second noun from the knapsack.

To remove (the item - nothing) from the knapsack: do nothing.
To remove (the item - a thing) from the knapsack:
    if the item is enclosed by the knapsack:
        carry out the implicit taking activity with the item.

I believe this should do it. (Not tested.)

Ugh. I really needed to just to specify a held noun. Thanks.

Ideally, that should already happen by default. Are there enough cases where it doesn’t that you need something like this for every action in the game?