§17.4. Standard tokens of grammar
We have already seen "[something]" and "[someone]", which are standard examples of "tokens of grammar" - patterns matched by suitable named things. There are several other standard tokens, provided not so much from necessity but to allow the game parser to be more graceful and responsive. "[someone]" matches the same possibilities as "[a person]" would, but the parser handles it a little better in cases of failure. These special tokens are best explained by looking at some of the examples in the standard grammar, which can be browsed in the Index of any game.
Understand "wear [something preferably held]" as wearing.
Here we expect that the named item will be one that is held by the player, and the parser will use this to resolve ambiguities between names of things carried and not carried. (If the action is one which positively requires that its noun be something carried, such as "eating", then a command matching this token against something not carried will generate an automatic attempt to take it.)
Understand "take [things]" as taking.
Understand "drop [things preferably held]" as dropping.
"[things]" is like "[something]" but allows a list of items, or a vague plural like "all", to be typed. The result will be a sequence of actions, one for each item thus described. "[things preferably held]" is the analogous token for "[something preferably held]".
Understand "take [things inside] from [something]" as removing.
"[things inside]" matches only what is inside the second-named thing, and ensures that (for instance) the command "take all from box" does not also try to take the box.
Understand "put [other things] in/inside/into [something]" as inserting it into.
Similarly, "[other things]" will allow anything except the second-named thing. (Like "[things inside]" it is really only needed for handling containers.)
![]() | Start of Chapter 17: Understanding |
![]() | Back to §17.3. Overriding existing commands |
![]() | Onward to §17.5. The text token |
|
Suppose that we have a game in which groups of objects can have meaning apart from their individual significance -- perhaps there are spells that can only be cast by collecting just the right items in the same place. In this case, one of the things the player might like to be able to do is look at several items together and get a special response, different from looking at the items individually. To make this happen, we need to do several things:
Now for step 2, overriding Inform's usual output of names of objects:
We'll save our "to describe" phrase until Section 2, when we can give the game specific instructions about how to report different lists of objects. Now, the player might also want to be able to refer to a group of item by some kind of group name, so let's add the option of creating a Table of Collective Names which will interpret these:
And as a bit of polish, because we'd like SEARCH TABLE to have the same effect as EXAMINE ALL ON TABLE:
Now we define a few actual lists of items:
We sort the lists so that regardless of how we change the rest of the code (and the order in which objects are coded), the resulting list will always be in sorted order and ready to compare with the list of items the player wants to look at. And thanks to the "Reading a command" code we wrote earlier, we can also teach the game to understand the player's references to "the left hand of autumn" as a specific collection of items.
|
|
Suppose that we have a game in which groups of objects can have meaning apart from their individual significance -- perhaps there are spells that can only be cast by collecting just the right items in the same place. In this case, one of the things the player might like to be able to do is look at several items together and get a special response, different from looking at the items individually. To make this happen, we need to do several things:
Now for step 2, overriding Inform's usual output of names of objects:
We'll save our "to describe" phrase until Section 2, when we can give the game specific instructions about how to report different lists of objects. Now, the player might also want to be able to refer to a group of item by some kind of group name, so let's add the option of creating a Table of Collective Names which will interpret these:
And as a bit of polish, because we'd like SEARCH TABLE to have the same effect as EXAMINE ALL ON TABLE:
Now we define a few actual lists of items:
We sort the lists so that regardless of how we change the rest of the code (and the order in which objects are coded), the resulting list will always be in sorted order and ready to compare with the list of items the player wants to look at. And thanks to the "Reading a command" code we wrote earlier, we can also teach the game to understand the player's references to "the left hand of autumn" as a specific collection of items.
Suppose that we have a game in which groups of objects can have meaning apart from their individual significance -- perhaps there are spells that can only be cast by collecting just the right items in the same place. In this case, one of the things the player might like to be able to do is look at several items together and get a special response, different from looking at the items individually. To make this happen, we need to do several things:
Now for step 2, overriding Inform's usual output of names of objects:
We'll save our "to describe" phrase until Section 2, when we can give the game specific instructions about how to report different lists of objects. Now, the player might also want to be able to refer to a group of item by some kind of group name, so let's add the option of creating a Table of Collective Names which will interpret these:
And as a bit of polish, because we'd like SEARCH TABLE to have the same effect as EXAMINE ALL ON TABLE:
Now we define a few actual lists of items:
We sort the lists so that regardless of how we change the rest of the code (and the order in which objects are coded), the resulting list will always be in sorted order and ready to compare with the list of items the player wants to look at. And thanks to the "Reading a command" code we wrote earlier, we can also teach the game to understand the player's references to "the left hand of autumn" as a specific collection of items.
|