Implicit takes are a convenience to players; in general, we would like to avoid asking players to type any more obvious commands than strictly necessary, while allowing the computer to guess as much as it safely can.
Occasionally, though, we have designed a timed puzzle in which the player has a limited number of moves in which to accomplish his objectives. In that case, the implicit take complicates matters, because it means that a player who types
>EAT GATEAU
(first taking the gateau...)
gets away with a spare move compared to the precise but naïf dupe who types
>TAKE GATEAU
>EAT GATEAU
...and really, that doesn't seem quite fair. The way to fix this problem is to fill in the extra minute on the clock during the implicit take; and that is indeed what we do in the following example.
"The Big Sainsbury's"
Sainsbury's is a room.
The crispy duck and the Guinness steak pie are edible things in Sainsbury's.
Rule for implicitly taking something:
follow the advance time rule;
continue the activity.
When play begins:
now the right hand status line is "[time of day]".
Test me with "take crispy duck / eat crispy duck / eat steak pie".
Suppose we want the player to have a pizza buffet from which he can take a number of slices. But we don't want to actually put the slices there in front of him, because "you can see 17 slices of pizza here" is not the descriptive effect we want, and because we want to pretend, at least, that the pizza supply is nearly infinite. In fact, we're going to replenish the supply by allowing eaten slices to return to the buffet table (safer in IF than in real life).
To do this, we create one object to stand in for the pizza supply, but whenever the player tries to take it, we give him a different "pizza slice" object instead. Thus:
"Pizza Prince"
The Pizza Prince is a room.
The buffet table is a supporter in Pizza Prince.
The pizza selection is a thing on the buffet table. Understand "slice" as the pizza selection. The description is "They are all cheese-only, and all luke-warm."
Rule for writing a paragraph about the buffet table:
say "On [the buffet table] is [a pizza selection]. [description of the pizza selection][line break]".
Now we introduce our actual pizza slices, which are retained in a container out of play until they're needed:
A pizza slice is a kind of thing. 10 pizza slices are in Pizza Limbo. A pizza slice is always edible. [After a fashion, anyway.]
In this example we've set that supply to be artificially small, to make it easier to test what happens when the player reaches the limit; but we could provide many more slices to start with in Pizza Limbo, and the aim in practice would be to pick a number high enough (such as 50 or 100) that the average player will get bored of TAKE PIZZA long before he reaches the limit.
The main thing to be aware of is that objects consume memory in the game file, so creating a large number of pizza slices might bulk the game out. This is more of a concern if we're compiling for the Z-machine than if we're compiling for Glulx.
Whenever the player tries to take the selection, we want him to wind up holding an individual slice instead; but of course we need to check and make sure that he hasn't exhausted the pizza slice supply.
Instead of taking the pizza selection:
let chosen slice be a random pizza slice in Pizza Limbo;
if chosen slice is nothing: [That is, there were no slices remaining]
say "[manager refusal]";
otherwise:
move the chosen slice to the player;
say "Taken (gingerly)."
To say manager refusal:
say "[one of]'Hey!' barks a hitherto-unseen manager from behind you. 'It's an 'all you can eat' buffet, not an 'all you can stuff down your pants' buffet.'[or]You are conscious of a disapproving huff from the manager, so you refrain.[stopping]"
That's fine for the case where the player is taking a new slice of pizza explicitly, but we need to handle it a little differently if the taking action is generated in response to EAT PIZZA. In that case, we need to take the slice and also change the identity of the noun, because after the implicit take action happens, the game will test whether the player is holding the noun before attempting to eat it. So we need to refocus its attention:
Rule for implicitly taking the pizza selection:
let chosen slice be a random pizza slice in Pizza Limbo;
if chosen slice is nothing: [That is, there were no slices remaining]
say "[manager refusal]";
otherwise:
move the chosen slice to the player;
say "(helping yourself from the selection)";
now the noun is the chosen slice.
And finally, a bit of touch-up:
Rule for clarifying the parser's choice of the pizza selection while taking:
say "(from the magnificent selection before you)[line break]"
For tidiness, we should probably also return the consumed pizza slices to Pizza Limbo so that they can be re-used later:
After eating a pizza slice:
move the noun to Pizza Limbo;
continue the action.
Test me with "i / get pizza / g / i / get pizza / drop pizza / look / get pizza / g / look / eat pizza / g / g / g / g / get pizza / g / g / g / g / g / g / g / g / g / g / g / g / i / eat pizza / take pizza / g".
As mentioned in this section, the "implicitly taking" activity does not allow us to skip an implicit take entirely. In order to do this, we need to borrow from the chapter on Rulebooks and tell Inform that one of the rules normally built in to the Standard Rules does nothing in certain circumstances:
"Lollipop Guild"
The carrying requirements rule does nothing when showing something to the guardian.
The can't show what you haven't got rule does nothing when showing something to the guardian.
The block showing rule does nothing.
Candyland is a room. "A fizzing, popping wonderland of sugary delights. A path tiled with butterscotch sweets leads to the horizon."
The butterscotch path is scenery in Candyland.
The player carries a basket. In the basket are a licorice gumdrop and a can of tuna. The gumdrop is edible. The description of the gumdrop is "Covered all over with grains of sugar." The can of tuna is edible. The description of the can of tuna is "A rare import in this place."
The giant lollipop is a fixed in place edible thing in Candyland. "Growing right next to the path, on a trunk of white paper, is a giant lollipop colored green and red and white." The description of the lollipop is "If you were very blind, like Aunt Myrtle, you might mistake it for a young sapling just planted: the lollipop is just that leafy shade of green, with swirls of white and red that might be branches or flowers."
The guardian is a man in Candyland. "Right beside you is a guardian in a mint-colored uniform." The description of the guardian is "A killjoy wielding a gigantic toothbrush." The guardian carries a gigantic toothbrush. The description of the toothbrush is "Bristles as long as your hand. Firm bristles, too, not those soft ones. The guardian doesn't care about your tender gums."
A thing can be sweet. The butterscotch path, the lollipop, and the gumdrop are sweet.
Carry out showing a sweet thing to the guardian:
say "The guardian shrieks! You don't understand its language, but from its ululations you understand the idea of decay. There may have been a bit in there about a root canal." instead.
Carry out showing something to the guardian:
say "The guardian nods approvingly at the unsweetened [noun]." instead.
Report eating a sweet thing in the presence of the guardian:
say "The guardian looks mournful, but unholsters his tube of paste and begins applying it to the toothbrush, as though to say that he really did not want to have to do this...";
end the story saying "Everything goes minty" instead.
Report eating something:
say "You consume [the noun] with gusto." instead.
Test me with "x guardian / x toothbrush / show gumdrop to guardian / show path to guardian / show tuna to guardian / look / eat gumdrop".
Note that because we only deactivate the carrying requirements rule for showing purposes, the player still takes the gumdrop before eating it.