Restricting things that can be put into a container (not carrying capacity)

Hi everyone. Apologies in advance because I’m sure this is simple, and I’m almost as sure that I have done it before many times.

I’m trying to prevent people putting random stuff into a container. Specifically I have a bottle recycler and I only want the player to be able to put bottles in it. If this were a custom action, no problem but as it is a core action I’m a little unsure about the safest way to accomplish this.

I have (I don’t know why it’s not letting me choose code as formatting)

Check putting something into something: if the noun is not the bottles and the second noun is the shoot: say "you can't do that." instead.

The issue here is that the name of this action is “inserting it into” (you can check this by typing ACTIONS in the IDE, which will display how Inform is translating player input an action). So you can just do:

Check inserting something into the recycler:
	If the noun is not a bottle, say "That doesn't fit!" instead.


Thanks @DeusIrae.

If you’re new to this, you might not know—I didn’t—that you can look at the “index” tab in the IDE for lots of crucial information. The “actions” section of the index has a grouping called “commands” that will let you look up actions like “put” and see how Inform has defined them—“inserting it into” in this case.

Lots of other good stuff there, too.

The command list keeps track of new actions and rules about those actions, too—it’s built when you compile the project. It also links to your code so it’s a great way to keep track of or troubleshoot changes to actions.


Thanks @kamineko. It’s a timely reminder of the utility of the documentation of this programme.

1 Like

In a scenario where the player drops something but you want it to go into a container like, say a guitar case and some coins, would the “try” statement be?

instead of dropping the euros when the player is in the station and the buskers are not playedout:
	try inserting the euros into the guitarcase instead.
1 Like

Yup, that’s right, except you’ve got a redundant “instead” at the end.

1 Like

Redundant but harmless. I tend to use “instead” or “end the action” in both check and instead rules, just so that I don’t have to think about the difference.