Selling things??

Hi everyone,

I have been having fun making an IF with Inform 7. I do have a buying system in place for things but I thought about also having a selling system.

I can’t see to get around this issue:

I want an item to have a price and a worth for the purpose of selling… or just have an item price which is half the amount if selling it.

This is my current selling code:

Worth is a kind of value. 100 gold specifies a worth. A thing has a worth. The worth of a thing is usually 00000 gold.

Selling is an action applying to one thing. Understand "sell [things] to [someone]" as giving it to. 

After selling something:
        increase the price of the money by the worth of the noun;
        say "The shopkeeper forks over [the worth of the noun] for [the noun], leaving yourself with [the price of the money].";

Any ideas? :confused:

It looks as though you’ve specified two different kinds of value for ‘price’ and ‘worth’. So you have this:

Worth is a kind of value. 100 gold specifies a worth. A thing has a worth.

and presumably somewhere also something like this:

Price is a kind of value. 100 gold specifies a price. A thing has a price.

But that won’t work, because different kinds of number values don’t play well together - as far as Inform is concerned, you might be trying to subtract kilometres from stock market value. So you need to specify them as the same kind of value, but with different names:

Gold-value is a kind of value. 100 gold specifies a gold-value. A thing has a gold-value called price. The price of a thing is usually 0 gold. A thing has a gold-value called worth. The worth of a thing is usually 0 gold.
(And there’s no need to use a special value here; you could just use ‘a number called price’, etc., unless the gold-value kind is doing something important.)

Ah I see, as a programmer I thought surely an int could be added to another int but I guess it works differently.

Now my IF will run but this part won’t work:

Instead of selling something: increase the price of the money by the worth of the noun; say "The shopkeeper forks over [the worth of the noun] for [the noun], leaving yourself with [the price of the money].";

Instead it will just say this:

I need to do something else to make it execute my selling code but I don’t know what. :blush:

EDIT: - I think this line may be the problem:

Selling is an action applying to one thing. Understand "sell [things] to [someone]" as giving it to.

Indeed it is. It means your command is getting mapped to the giving it to action, and there aren’t any commands that evoke the selling action.

You want something like this:

Selling is an action applying to one thing. Understand "sell [something]" as selling.

Then “sell rusty” will activate the selling action. This won’t allow for “sell rusty dagger to raven”; there are a couple different ways to handle that. (One way is to just leave it as it is, so when the player types “Sell rusty dagger to raven” the game responds “I only understood you as far as wanting to sell the rusty dagger.”)

EDIT: And you probably want to write a line that removes the sold item from your inventory, and puts it in the shopkeeper’s inventory if that’s implemented.

Ah yes, I had this line there before but it wasn’t working for me. I thought I needed to assign it as giving to get rid of the item.

For putting in his inventory do I use give like this?

Doesn’t quite seem to work but I think I have the right idea.

EDIT: Move seemed to work for me! :smiley:

Or “now the shopkeeper carries the noun” – that’s the most general way of making relations happen.

You can, but you have to define a phrase to cast between the two types. After all, what if one type was pounds and the other kg?

Excellent!

Thanks for all the help everyone, the response here has been amazing! :slight_smile:

In a different system (ADRIFT) I wrote a game where I had three currencies and an exchange rate between them. In Menagerie!, the game took place at a circus. There was a boardwalk, and naturally the games required tokens to play them. As I recall the player started with a certain amount of money, but you could then win tokens and then exchange the tokens for more money (at one point you had to buy your circus ticket, so this was a requirement). If you failed to buy your ticket and basically spent your tokens on playing more games, the player could also exchange points from your game score for either more money or tokens, I can’t remember which.

I think I had a ticket booth for the token to money exchange, but the score to token/money cheat was done as a command.

Oh yeah, that game also had three difficulty levels and the exchange rate differed depending on which difficulty level you played at.