Separating a single thing from a collection of the things

I have a group of gold coins, and a single gold piece (I use piece so as to disambiguate it from the collection). However, when I try to EXAMINE or DROP a gold piece, the parser converts it to the collection. How do I stop that? (P.S. I use NbrGold variable to adjust the number of coins in the collection.)

NbrGold is a number that varies. NbrGold is initially 35.
Printed name of gold coins is "[nbrGold] gold coins".
Small belt pouch contains [nbrGold] gold coins.

A gold piece is a thing.  Description of gold piece is "Typical coin of the realm, equal to 10 silvers. The King is on one side and the Imperial seal is on the other.".
Understand "one gold" or "gp" or "gold coin" as gold piece.

Instead of examining gold coins:
	if nbrGold is not zero:
		say "You have [nbrGold] gold coins. You pull one of the coins from the pouch. [description of gold piece][line break]"; 
		
Instead of dropping a gold piece:
	say "You hear a clink as the coin hits the ground.";
	decrement nbrGold.

One final note: If I EXAMINE GP, which I think should work because of the Understand rule, it says that gp doesn’t exist?

As written, the gold piece is out of play. You need to put it in a room or container/supporter or inventory for it to be referenceable.

Do you want something like this?

Lab is a room.  "This is a lab."

A gold piece is a kind of thing.
Description of gold piece is "Typical coin of the realm, equal to 10 silvers. The King is on one side and the Imperial seal is on the other.".
Understand "one gold" or "gp" or "gold coin" as gold piece.

The player carries 10 gold pieces.
		
After dropping a gold piece:
	say "You hear a clink as the coin hits the ground.";

Yes, but I need to look in my pouch to see 10 gold pieces. Inform doesn’t seem to distinguish between the plural 10 gold pieces --it takes it as a single thing–from the single gold piece. Would printed-plurals work here for the gold collection?

Yes, I know, but I can’t put a single gold coin in the pouch with the gold coin collection or I’ll get: Your pouch contains 35 gold pieces and a gold piece.
Also, if I DROP 3 gold pieces, it won’t know what to do; and neither do I since it doesn’t know about a collection of gold coins.

I have a gold cache (the collection of identical gold pieces). I have this working fairly well but if the player wants to perform an action on a single gold piece, say X GOLD PIECE,
I pull a gold piece from nowhere, place it on the player, and

say "[description of gold piece]".

Before I can respond to the player’s command, the parser gives the “can’t see any such thing” error because the gold piece is out of play.

I changed the parser error message so that if that occurs, and the command is “x gold piece”, it will give the proper description. However, that means I need to put a plethera of phrases in the parser checker since Understand phrases, like Understand "gold" or "gp" or "gold coin" as gold piece. aren’t recognized at this point. The same problem multiplies for most of the player’s commands that might try to perform an action of a single gold piece.

All this will go away if I can pull the gold piece from nowhere before the parser throws the error. Any suggestions? Is there a way that I can keep the gold piece description in play without it being recognized, like a global text variable?

The essence of my solution is that you don’t have a gold coin collection. So you don’t get a message like you describe. (Or if you do get that while running my code, provide a transcript so I can see it for myself :slight_smile: )

2 Likes

Side note: substitutions with brackets like your [nbrGold] only work inside of quoted text. Outside of quoted text, brackets will comment the text between them out, so the compiler will read that third sentence as just “Small belt pouch contains gold coins,” rather than as a variable number of gold coins.

2 Likes

This code works to avoid the problem you mentioned.

A small belt pouch is a container worn by the player. The small belt pouch is openable and closed.
Description of the small belt pouch is "A small leather bag that hangs from a loop on your pants.".
Understand "pouch" or "belt pouch" as small belt pouch. 
Small belt pouch contains gold cache and silver cache.

NbrGold is a number that varies. NbrGold is initially 35.
NbrSilver is a number that varies. NbrSilver is initially 19.

Gold cache is a thing. Printed name of gold cache is "[nbrGold] gold coins". 
Understand "gold" or "gold coins" as gold cache.
Silver cache is a thing. Printed name of silver cache is "[nbrSilver] silver coins".
Understand "silver" or "silver coins" as silver cache.

When I run it, I get

>**open pouch**
You open the small belt pouch, revealing 35 gold coins and 19 silver coins.