I cannot get this to work! I want the player to be able to buy a thing when they walk into Gus’s Provisions (a room I’ve already set up and described). However, the objects for sale are listed in a written inventory list and are inside the container cupboard, and are not seen by the player, like so:
A written inventory is in Gus’s Provisions. The written inventory is fixed in place. The description of the written inventory is “Inventory of Gus.”
Instead of examining the written inventory:
say "[bold type]Inventory[roman type]
Weapon - Price - Damage[italic type]
Dagger - 4 copper - 1 damage
Spear - 11 copper - 3 damage
Staff - 8 copper - 2 damage
Sword - 14 copper - 4 damage
[roman type]Protection - Price - Resistance[italic type]
Helmet - 9 copper - 2 resistance
Breastplate - 15 copper - 4 resistance
Chausses - 12 copper - 3 resistance
Shield - 6 copper - 1 resistance
[roman type]Provision - Price - Health[italic type]
Herbs - 8 copper - 3 health
Potion - 14 copper - 4 health
Ration - 3 copper - 2 health
Water - 1 copper - 1 health
A counter is a container. It is scenery. It is fixed in place. The cupboard is part of the counter. The cupboard is an openable and lockable container. The cupboard is closed.
A dagger is a thing. Understand “knife” or “blade” as the dagger. The description of the dagger is “A small, silver blade is attached to an ivory handle. Exotic, for sure.” The dagger is in the cupboard. The dagger is portable. The price of a dagger is 4 copper.
That part works just fine. But the below code that is bolded does not work. I want the player to be able to buy whatever is on the inventory list even though they cannot see the actual object until they go to buy the object that is unseen in the cupboard in the counter.
Here is what I have:
The price is a kind of value. 999 copper specifies a price. A thing has a price. The price of a thing is usually 0 copper.
Definition: a thing is free if the price of it is 0 copper.
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 satchel:
say “You do not have enough copper.” instead.
The description of copper is “Copper is quite shiny - and valuable!”
Before buying something for sale when the money is free:
say “You have no copper.” instead.
Before buying something for sale when the price of the money is less than the price of the noun:
say “You do not have enough copper to purchase [the noun].” instead.
Instead of buying something:
** If a thing is for sale and is in a container:**
** say “Gus smiles, leans over and pulls out [the noun] from his counter cupboard and hands it to you.”;**
** decrease the price of the money by the price of the noun; **
** say “You give [the price of the noun] for [the noun], leaving yourself with [the price of the money].”; **
** if the money is free: **
** now the money is nowhere; **
** now the price of the noun is 0 copper; **
** now the player is carrying the noun.**
I cannot get it to work. Please direct me!