Hi, i was wondering how can i make a shopkeeper sell more than one thing, i have it so that a bartender only sells beer, but i'd like him to be able to sell ale, beer and vodka. IF YOU KNOW HOW TO DO THIS PLEASE ANSWERE. So far the code i have for 1 item being selled is...
mob
Bartender
icon = 'bartender.dmi'
density = 1
verb
Talk_To_Bartender()
set src in oview(1)
switch(input("Hey mate, wana buy a nice cold beer?, only 50 gold.","Bartender",text)in list("Sure","Na, I don't drink."))
if("Sure")
if(usr.gold<=49)
alert("You can't afford another beer mate!")
if(usr.gold>=50)
usr.gold-=50
usr.contents += new/obj/beer
alert("You buy a beer.")
if("Na, I don't drink")
alert("Alright, come again some other time...")
obj/beer
icon = 'beer.dmi'
ID:261593
![]() Aug 12 2002, 10:01 am
|
|
heres how i do it, probably not what your goal is, though...
verb sword() set category = "Shop" (does stuff like checking money + giving item) shield() set category = "Shop" (does similar stuff) magic_wand() set category = "Shop" (again, money check, gives item) so every item in the shop is listed under "Shop" in the verb panel! |
Cybermattr wrote:
heres how i do it, probably not what your goal is, though... Here's another interesting way to do it: mob In this case, any /mob/shopkeeper will have a var/list/selling that's an associative list of all the items they sell. The advantage of this approach is that the items don't have to be verbs. They can be the objects themselves, and all they have to do is respond to Click() and know that you're clicking them from a statpanel. obj Lummox JR |
The code is a little screwy, but your input() approach is perfectly extensible for this kind of thing.
However, a much better approach appears in my BYONDscape article on associative lists; you'll find it in the archives, as free content.
Lummox JR