Multi-Vendor (TinyMUX Version)

A vendor that sells multiple objects.

Author: Raevnos
Category: Vendors
Compatibility: PennMUSH, TinyBit.


Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for Multi-Vendor (TinyMUX Version)

@create MultiVendor
@lock MultiVendor=me
@set MultiVendor = LINK_OK
@set MultiVendor = VISUAL
@set MultiVendor = COMMANDS

@@ To make the vendor do stuff when an item is bought, put the approriate code in <ITEM>_BUY. %0 is the dbref of the buyer.

@APAY MultiVendor=@notify me;@tr me/%va_buy=%#, %va;@va me;@cost me;@pay me;@opay me

@DESCRIBE MultiVendor=This is a vendor that sells multiple objects. To buy something, [ansi(h,ORDER <ITEM>)], where <ITEM> is one of [v(items)], and then give the vendor the requested amount of money ([ansi(h,GIVE MULTIVENDOR=<N>)]).%r%rSince this is an example object, it doesn't actually create objects, but it's easy to make your own copy do so. See [ansi(g,MultiVendor/Notes)] for information. It's visual, so you can copy the code to other mushes. Feel free to modify it as needed. Enjoy. -- Raevnos


&LICENSE MultiVendor=All code on this object (MultiVendor) is released under the Lesser Gnu Public License. A copy of that license is avaliable at [tagwrap(a, href="",]

&NOTES MultiVendor=$multivendor/notes:@Pemit %#=To add objects to this machine, create them, add their names to &ITEMS. The order command uses semaphores so that only one person can order at a time. It clears itself after 60 seconds, or the first time it's given enough money, and moves onto the next order in the queue, or waits for one to show up.%r%rThe attribute ITEMS contains a list of items the vendor sells (One word names only, though you can modify that fairly easily), and for each item, the attribute <ITEM>_COST is how much it costs, in MUSH Money, and the attribute <ITEM>_BUY contains code that's @triggered when it's bought, with the dbref of the buyer in \%0.%r%r\%1 contains the name of the current item being bought.

&ORDER_CMD MultiVendor=$order *:@wait me={@switch t(member(v(items),ucstr(%0)))=1,{@pemit %#=[name(me)] says, "Thank you for ordering a [capstr(lcstr(%0))]. That'll be [v(%0_cost)], if you please.";@va me=[capstr(lcstr(%0))];@cpattr me/%0_cost=me/cost;@payment me=[name(me)] gives you a %va;@opay me=is given a %va by [name(me)].;@wait me/60={@notify me;@cost me;@pay me;@opay me}},{@pemit %#=[name(me)] says, "Sorry, I don't sell [capstr(lcstr(%0))]'s.";@notify me}

@@ Example Items

&POPCORN_BUY MultiVendor=@Create [name(%0)]'s Bag of Popcorn; Drop [name(%0)]'s bag of Popcorn

&POPCORN_COST MultiVendor=20

&SODA_BUY MultiVendor=@pemit %0=If this wasn't a demo object, you would have gotten a real can of soda.

&SODA_COST MultiVendor=10

@STARTUP MultiVendor=@drain me;@notify me;@va me;@cost me;@pay me;@opay me