Currently I’m working on a currency extension and I’m trying to get selling an item to work. The code runs with no errors, but whenever I try to sell something, it does nothing. I still keep the item, the currency value for the player is unchanged and it doesn’t report the selling. This is my code thus far:
Currency is a kind of value. $1 specifies a currency. Everything has a currency.
Instead of taking inventory:
Say "You are carrying [list of things carried by the player]. You have [currency of the player]."
Selling is an action applying to two visible objects.
Understand "Sell [thing] to [person]" as selling.
The selling action has an object called the selling it to (matched as "to").
Check selling:
If the player is not carrying the thing:
Say "You can't sell something you don't have."
Carry out selling the thing (called the sellitem) to the person (called the notplayerbuyer):
Now the notplayerbuyer holds the sellitem;
Now the currency of the player is the currency of the sellitem + the currency of the player;
Say "You hand over the [sellitem] to [notplayerbuyer]. He gives you [currency of the sellitem] in return."
Okay. First, you’re not using the current version of Inform. You should upgrade unless you have a reason not to, in which case you should say so that we don’t get confused answering your question.
Second, never say “the thing” or “the person”. Those are kinds, not specific objects. Say “a thing”, “a person”, or else name a particular object or variable like “the noun”. (The current version of Inform catches this mistake in some cases.)
Third, you’re specifying an action-specific object (“the selling it to”) which is not what you want. You want to define an action with an ordinary second noun.
Fourth, it’s “two visible things” rather than “two visible objects”. (This probably used to work but it’s marked as an error in the current version.)
Fifth, specify action grammar with maximum inclusiveness: Understand “Sell [something] to [something]” as selling it to. That way you can give sensible error messages for the case where, e.g., the second noun is not a person.
Putting this together:
Selling it to is an action applying to two visible things.
Understand "Sell [something] to [something]" as selling it to.
Check selling:
If the player is not carrying the noun:
Say "You can't sell something you don't have."
Carry out selling a thing (called the sellitem) to a person (called the notplayerbuyer):
Now the notplayerbuyer holds the sellitem;
Now the currency of the player is the currency of the sellitem + the currency of the player;
Say "You hand over the [sellitem] to [notplayerbuyer]. He gives you [currency of the sellitem] in return."