Aargghh, I always get that syntax wrong, which is why I shouldn’t do it without running it through Inform. I’ve checked it out now and the proper syntax is to use the passive voice:
Carry out Combining Objects:
let the result be a random thing that is become by the second noun;
say "You use [the noun] on [the second noun] and get a [result]."
(If the relation is reciprocal you can actually use “thing that the second noun becomes” and it’ll be OK.)
Once this is fixed the “When play begins” statement should work:
[code]A slice of bread is a kind of thing. The plural of slice of bread is slices of bread. There are five slices of bread in the cafeteria.
When play begins: now every slice of bread becomes the cheese sandwich.[/code]
Now, about the “random” thing: This is not something that can be helped the way we have it, so we need to go to something more complicated.
Think of it this way: Suppose the bread and cheese combine to make the cheese sandwich, and the bread and sausage combine to make the sausage sandwich, and the cheese and macaroni combine to make the mac’n’cheese. Now the player combines the bread and cheese. What should they get?
Well, if the result is determined by something that relates to the first noun or second noun, there’s absolutely no way to tell except by picking at random! Suppose the cheese is the second noun. The cheese becomes the cheese sandwich, and the cheese becomes the mac’n’cheese. If we’re just looking at what the cheese is related to, Inform has no way of distinguishing the two.
What we need to do is to do something a little more complicated, to look at what the noun and the second noun both relate to. So we could write something like this:
Carry out Combining Objects:
if something (called the result) that is become by the noun is become by the second noun:
say "You use [the noun] on [the second noun] and get a [result].";
otherwise:
say "Those don't combine."
Note that our “if” test is now testing whether there’s something that both the noun and second noun become, and picking that. (If we’re not careful defining the relations, there could be more than one such thing, and then Inform will just pick the first one we defined. But there’s no way around that other than to make sure we don’t try to let two separate objects combine with more than one result. If the egg and bread make the egg sandwich, and the bread and egg make the french toast, then neither Inform or the player will know what to do with “Use egg on bread.”)
And if we’re going to do this we really need the relation to be nonreciprocal, or we’ll wind up making the ingredients instead of the result. So:
[code]Cafeteria is a room. Hyperspace Chest is a room.
Object Transmutable relates various things to various things. The verb to become means the Object Transmutable relation.
Definition: a thing is Object Transmutable if it becomes more than one thing.
Combining Objects is an action applying to two things. Understand “use [something] on [something]” as Combining Objects.
There is a Cheese in the Cafeteria. It becomes the cheese sandwich. [This line and the next one are what is producing the attached number.]
A slice of bread is a kind of thing. The plural of slice of bread is slices of bread. There are five slices of bread in the cafeteria.
When play begins: now every slice of bread becomes the cheese sandwich.
Carry out Combining Objects:
if something (called the result) that is become by the noun is become by the second noun:
say “You use [the noun] on [the second noun] and get a [result].”;
otherwise:
say “Those don’t combine.”
Test me with "use bread on cheese".[/code]
(By the way, a nice little bonus you may not have noticed–we don’t actually have to define the Cheese Sandwich as an object, and in fact we didn’t. When we write “It become the Cheese Sandwich” Inform knows that it needs to create a thing called the Cheese Sandwich and put it into the appropriate relation with the cheese. So it automatically creates the cheese sandwich off-stage.)