Is there a way to make the value of the item show up in the shopkeeper's list without having to hard code in the 'Name --- Value' for each individual item? Here is the code.
-----
verb
Buy()
set src in oview(0)
var/list/wares[] = new //sets up a new list
for (O in src)
wares += "[O]"
wares += "Cancel"
var/obj/shopchoice = input("What will you buy?") in wares //ask the player what he wants to buy, from the items on the list
if (shopchoice == "Cancel")
usr << "Come again."
return 0
else
usr << "Item costs [shopchoice.value] Gold."
------
The code works as is, I just would prefer not to have to hard code everything
ID:178863
Mar 25 2002, 3:45 am
|
|
In response to Lummox JR
|
|
Very useful column. Thank you. It was a very useful learning experience.
|
You're not far off in your code from what you need. I have some pretty good shopkeeper code in a BYONDscape article that should suit you just right:
Dream Tutor: Learn To Love Associative Lists
That particular column is non-subsscription content.
Lummox JR