Inform 7 Home Page / Documentation


§10.3. Dispensers and Supplies of Small Objects

A slightly tricky situation arises in IF when we want to offer the player a simulation of a near-infinite supply of something: a napkin dispenser from which he can keep taking more napkins, or an infinite selection of pebbles on a beach, or something of that nature.

One approach is simply to limit the number of items the player is allowed to pick up at a time, while maintaining the fiction that there are more of these items in existence than the player is allowed to interact with. Extra Supplies demonstrates this.

The task becomes harder if we do want to let the player have as many napkins as he wants. In some languages, it is possible to generate new objects on the fly after the story has begun (called "dynamic object creation"), and something like this is possible if we are compiling for Glulx. (See the Inform extensions site for examples.) Usually, though, it is less complicated and almost as effective simply to have a very large supply of existing objects, which are moved in and out of play as the player needs them. Pizza Prince demonstrates how to do this with slices of pizza.

* See Ropes for an example involving divisible pieces of string, which relies on similar techniques


arrow-up.png Start of Chapter 10: Physics: Substances, Ropes, Energy and Weight
arrow-left.png Back to §10.2. Liquids
arrow-right.png Onward to §10.4. Glass and Other Damage-Prone Substances

*ExamplePizza Prince
Providing a pizza buffet from which the player can take as many pieces as he wants.

**ExampleExtra Supplies
A supply of red pens from which the player can take another pen only if he doesn't already have one somewhere in the game world.