1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-07 17:44:22 +03:00
inform7/resources/Documentation/Examples/Curare.txt
2023-07-24 11:56:58 +01:00

33 lines
2.1 KiB
Plaintext

Example: * Curare
Location: Descriptions as values
RecipeLocation: Varying What Is Written
Index: Cyclical randomization of named objects
Description: A phrase that chooses and names the least-recently selected item from the collection given, allowing the text to cycle semi-randomly through a group of objects.
For: Z-Machine
{*}"Curare"
A thing has a number called the last use. The last use of a thing is usually 0.
Definition: a thing is old if its last use is 12 or less.
The actual number chosen in this definition is pretty much irrelevant: the main thing is that we want to establish relative values. The lower the "last use" number of an item, the older that item should be understood to be, as we see here:
{**}To decide which thing is cyclically random (collection - a description of objects):
let choice be the oldest member of the collection;
now the last use of the choice is the turn count;
decide on choice.
This phrase will select, from the collection of objects passed to it, the one that has been mentioned least recently. This means that if we consult it repeatedly about the same collection, it will begin to cycle predictably; but if new items are added to the collection, it will mention these first before returning to the previous cycle. Now we can use this:
{**}After taking inventory:
say "You stare morosely at [the cyclically random thing carried by the player], wondering what you're ever going to find to do with it."
We could have said "You stare morosely at [the oldest thing carried by the player]" here, but doing so would not have set the "last use" property correctly, so we would not get the cycling behavior that we're looking for.
{**}The Evidence Room is a room. Some shelves are scenery supporters in the Evidence Room. A box is a kind of container which is open and not openable. On the shelves is a box. It contains a deformed bullet and a driver's license.
The player carries a steel fish hook, a Chinese passport, a tube of synthetic curare, and an envelope full of Euros.
Test me with "i / i / i / i / i / i / get all from box / i / i / i".