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. 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.
Anyone out there willing to help out a noob in need?
Thanks in advance.