Okay here is my dilema I can create a code where a verb is connected to the shopkeeper. But the only way i can do it is to have the verbs "buy item 1" "buy item 2" etc.
What i want is a dialouge box to come up and list all the items i can buy. I would also like a dialogue box come up where it shows all the items you have and you can sell them for different values.
Any help would be great! thanks!:)
ID:178009
Jun 29 2002, 8:23 pm
|
|
Jun 29 2002, 11:15 pm
|
|
I have made a demo for it.. way before you asked.but i needa upload it to the hub(Which is not working!)
|
obj This isn't tested and it's 3:30 AM, so if it doesn't work, sorry. |
In response to Nadrew
|
|
obj/Object2
icon = 'obj.dmi' icon_state = "obj2" sellamount = 30 verb get() set src in oview(1) src.Move(usr) drop() src.Move(usr.loc) obj/Object1 icon = 'obj.dmi' icon_state = "obj1" sellamount = 30 verb get() set src in oview(1) src.Move(usr) drop() src.Move(usr.loc) mob/var/gold = 100 mob/Stat() stat("Gold: [usr.gold]") statpanel("Items",usr.contents) obj var sellamount = 0 mob/shopkeeper icon = 'shopkeeper.dmi' verb Sell(var/obj/obj in usr) set src in view(1) switch(alert(usr,"Do you wanna sell [obj] for [obj.sellamount] Gold?"," ","Yes","No")) if("Yes") usr.gold += obj.sellamount del obj if("No") usr <<"Fine." Buy() set src in view(1) switch(alert(usr,"What do you wanna buy?"," ","object1","object2","nothing")) if("object1") if(usr.gold >= 50) usr <<"You buy object1" new/obj/Object1(usr) usr.gold -= 50 else usr <<"You need 50 gold" if("object2") if(usr.gold >= 50) usr <<"You buy object2" new/obj/Object2(usr) usr.gold -= 50 else usr <<"You need 50 gold" usr <<"Fine." if("nothing") ..() |
Akarat wrote:
Okay here is my dilema I can create a code where a verb is connected to the shopkeeper. But the only way i can do it is to have the verbs "buy item 1" "buy item 2" etc. Ignore the previous examples; they're well-intentioned but a very bad way to go. Using switch() vs. an associative list means you'll have a lot of redundant code, and a lot more room for errors, without any flexibility. To get you started on code to buy items, I recommend you check out my (free) BYONDscape article on associative lists, which includes complete code for a shopkeeper you can buy from. http://www.byondscape.com/scape.dmb/content/000008/ index.html Selling items is a slightly different matter, but by putting code in place for buying, you should be better able to figure it out. Lummox JR |