Setting up a shop

The Pixie
What is the best way to set up a shop? I want the player to type "buy hat", "buy chair" or whatever.

I seem to need to have a hat in the room, otherwise the parser will complain. Is there some way to stop that? You could have "buy hat" as a command, but that seems a bit poor; you would need to list each combination of synonym. And the fact that buy is already present as a verb indicates that is not the way.

If I have a hat in the room that the "buy" verb can be associated with, then I have to stop the player just taking it. But if he buys it, then puts it down, now he is allowed to take it. It all starts to get very complicated; so much so that I think I am missing something.

Alex
You could set up a buy command, maybe just for the shop room, using the command pattern "buy #text#". That will let the player type "buy" followed by anything. You could then use a switch command, or perhaps use a dictionary somehow if you've got a lot of items.

If you wanted to go down the verb route and have some special "take" behaviour, you could make that part of a new "shop item" type for example, then you could reuse that functionality for all objects in the shop (and it could also be used to create a "shop" library perhaps so others could use it!)

The Pixie
So what is the best way to then handle the transaction? I can move a single instance of a hat to the player, but if the player buys another, then the first one gets moved to the player (and as it is already there, nothing happens).

Also, if you are creating a new object, how do you set it up? It seems to me that using the type fuctionality might be the way to go - set the hat to inherit from the hat_type, but how do you actually do that?

Alex
I think the best approach would be to have a "hat" object and then clone it.

Unfortunately it appears that I've not yet implemented a clone command (although the functionality already exists in WorldModel, as it is used for copy and paste in the Editor).

I've logged http://quest.codeplex.com/workitem/832

The Pixie
Thanks for updating Quest. i have a quick library module and demo (with walkthrough) for anyone interested.

To use:
1. Have a Boolean attribute on your shop called "shop" set to true.
2. Have an integer attrubute on the player called "money", set to the
amount of cash the player starts with. It would be good to set this
as a status attribute too.
3. Any goods for sale should be placed in the shop. Set to scenery and
not takeable (these will be changed when the item is purchased).
They also need an integer attribute "price"; this will be deducted
from the player's money.

The Pixie
A limitation of using clone for a shop (as I have done) is that you cannot give cloned objects to someone (at least, not using the standard method). I thinkj the problem is that give checks for a specific object, and is expecting the original, not the copy.

Alex
Yes, "give" and "use" will only work with the original object, as a cloned object is not necessarily the same as the object it was cloned from. I'm open to suggestions on a better design.

The Pixie
One way to handle give would be to specify a pattern rather than an object.


Another problem is if you want to use the goods in the shop. Say you have a burger bar:

buy burger
eat burger

When you eat the burger, you will get a choice of eating the burger you bought, or eating the original. Would it be possible to have a stock object in the room, and to have the original in that, then, when you eat burger, it will be outside the scope? The problem is that buy burger will fail, because the original burger would be out of scope, so what is needed is a way to specify a scope for a verb, so you can tell "buy" it has to look in player.parent.stock only, rather than the usual locations.

Alex
You'd probably want to set up "eat" as a command instead of a verb. In a similar way to "take" and "drop" it could then see where the object was, and print "you haven't bought a burger yet" or similar, just as "take" gives "you are already carrying it".

The Pixie


I have created an alternative library that allows you to sell as well as buy. The USE and GIVE problem has not been solved, but the inventory is now kept in another room, so BUY BURGER. EAT BURGER should work fine.

InsertCoin25
This library is great. I tested out the shop demo, but was wondering if there is a way to buy the items without typing anything in? Just use a hyperlink like you use for selling.

Thank You and Great Work!!!
InsertCoin25

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums