Inexhaustible supply: how is this different from the example

This is basically a straight copy of Example 363…except it won’t compile. It refuses to accept the line “let the current item be a random seed in the hidden place,” which looks to me like a perfectly ordinary declaration of a temporary named variable. Ideas?

[code]The storage room is a room.

The food stash is in the storage room. “There’s a pile of food here.”

A seed is a thing. It is edible. The description of a seed is “A seed out of your food stash.”

After eating a seed:
say “You eat the seed. That’s pretty good!”;
move the noun to the hidden place.

The hidden place is a room.
In the hidden place are 20 seeds.

Instead of taking the food stash:
let the current item be a random seed in the hidden place;
if the current item is nothing:
say “No thanks. You’re stuffed.”;
move the current item to the player;
say “You take a seed.”

Rule for implicitly taking the food stash:
let the chosen seed be a random seed in the hidden place;
if the chosen seed is nothing:
say “No thanks. You’ve eaten way too many!”;
move the chosen seed to the player;
say “(helping yourself to a seed)”;
now the noun is the chosen seed.[/code]

I think “a seed is a thing” should be “a seed is a kind of thing”. You have now just declared a single item called “a seed”.

Huh. So then when I make 20 seeds, I suppose it’s making an actual thing called “20 seeds.”

Yep. :slight_smile: By the way, you can check this by checking the index, or by typing “tree” in the game-window.

Made twenty individual seeds for me.

If the source doesn’t compile, the index doesn’t get updated. But when I commented out the rules for taking seeds, I got it to compile with a single object called “20 seeds.”

That’s what it does (and rightly so!) if you’ve defined a seed as a kind of thing. If you haven’t, then you get one object called “20 seeds.” (Because there’s no such thing as an “individual seed,” if seed isn’t a kind of thing.)

Right, defining it as a kind makes 20 seeds. Maybe I misunderstood the question…