Issues regarding currency implementation, definition

I’ve been having trouble implementing gold coins as a form of currency in my IF for some time now. I must admit, i am a total noobie, but I have this as a project for my English class, and I am genuinely interested in working in this style. :slight_smile: Anyways, I’m particularly stuck in the syntax aspect of defining currency and the state of the item (free/worth something). I am not trying To implement a complex bartering system where the prices change, but a simple trade system utilizing currency and a wallet.
Here is the source code in question, with large parts in brackets to serve as templates:

Money is a kind of object. Money has a number called worth. The worth of money is usually 25.
The player carries a wallet. The wallet contains money. The printed name of the money is "[worth of the money] gold coins". Understand "gold coins" as the money.
Definition: the money is free if its worth is 0 gold coins.
Definition: a thing is for sale if it is not free.
Instead of taking something for sale, say "You'll have to pay for that."
Before buying something for sale when the money is not in the wallet, say "You're broke." instead.
Before buying something for sale when the money is free, say "You're broke." instead.
Before buying something for sale when the worth of the money is less than the worth of the noun, say "You don't have enough money for that."
Instead of buying an object:
	decrease the worth of the money by the worth of the noun;
	say "You fork over [the worth of noun] for [the noun], leaving yourself with [the worth of the money].";
	now the worth is 0;
	now the player is carrying the noun. 

[An object has a number called value. Price is a kind of value. 10 gold specifies a price. An object has a price. The price of an object is usually 0 gold. After examining something for sale, say "It can be yours for [the price of the noun]"
Definition: an object is free if the price is 0 gold.
Definition: a thing is for sale if it is not free.
Instead of taking something for sale, say "You'll have to pay for that."
Before buying something for sale when the money is not in the wallet, say "You're broke." instead.
Before buying something for sale when the money is free, say "You're broke." instead.
Before buying something for sale when the price of the money is less than the price of the noun, say "You don't have enough money for that."
Instead of buying something:
	decrease the price of the money by the price of the noun;
	say "You fork over [the price of the noun] for [the noun], leaving yourself with [the price of the money].";
	if the money is free, remove the money from play;
	now the price of the noun is 0 gold;
	now the player is carrying the noun. 
The player carries a wallet. The wallet contains money. The printed name of the money is "[price of the money] in gold". Understand "gold" as the money. 
Instead of taking the money:
	say "Best to leave it alone until you need to buy something." 
Instead of buying something free:
	say "[The noun] is yours already." 
Instead of buying the money:
	say "The money belongs to you; you buy things with it." ]

The issue is particularly with the definitions: Inform 7 is coming up with the following error:
“Problem. You gave as a definition ‘the money is free if its worth is 0 gold coins’ : but that condition makes no sense to me, although the preamble to the definition was properly written. There must be something wrong after ‘if’.”

I’ve tried every way to word the statemet and I can’t seem find out what that something is. :confused:
Anyone out there willing to help out a noob in need?
Thanks in advance.

You’ve defined worth as a number, but “0 gold coins” is not a number.

Definition: the money is free if its worth is 0.

Additionally, you probably want “Some money is a thing” instead of a kind of object. Otherwise Inform assumes there are or can be more than one money object so saying “the money” is likely to cause problems. If there are more than one money objects in the game you’d say “Money is a kind of thing” and then you’d have to specify which money you mean everywhere you use it (rather cumbersomely, “a random money in the wallet”).

Ah, I understand now! I thought you had to explicitly state the specific value you were referring to, but I guess it is defined in the first lines as having worth, which allows worth to specify the value automatically. Thanks so much!

Now, if it isn’t too much trouble, how would I go about coding speech and something like a buy menu? I feel like that should be simple enough but I haven’t seen any guides about making NPC’s that can sell you things. I have three shops that I need to set up, and they only need to be a simple give-money-and-take-object type of shop with no need for bartering or haggling.

This is what I have so far, number 1 of 3 shops:

[Smithy] The Grunmin's Smithy is a room. The description of Grunmin's Smithy is "You enter a dark and smoggy room, with the front wall missing for ventilation. You can see a large bellows, piping air into the heart of a huge forge. An equally giant anvil is present directly in front of the forge. You wonder if these items are truly this large, or if your perception is altered by Grunmin's unusual height." Grunmin is inside Grunmin's smithy. Grunmin is a person. The description of Grunmin is "A local dwarf who practices the smithing arts. His face is covered in soot from the forge, and sweat drenches his brow. He may be stout, but he is not short of spirit!" The bellows are scenery. The forge is scenery. The great anvil is scenery.
Thanks again for your help! :slight_smile:

Look at the juggling equipment catalog example in the Manuals. That would be a good starting point.

Will do. :slight_smile: Thanks for the help, guys! Really helped me move forward.