ID:147200
 
Is this possible? And if so, how?
        shopkeepers
var/list/wares
var/list/waresshow
verb/Buy()

Pubkeeper
icon_state = "pub"
wares = list(/obj/possesions/Beer)
waresshow = list("Beer - 10G")

verb/Buy() hasn't been finished.
How to make the user choose Beer - 10G in list waresshow and then the program gives them /obj/possesions/Beer from list wares?
To do what you want would be like the following.
mob/shopkeepers/verb/Buy()
var/selection=input("Buy what?")in waresshow
var/item_type=wares[waresshow.Find(selection)]
var/obj/O=new item_type(usr)
usr<<"Got a [O.name]."

However, there is a better way to do this with associative lists.
mob/shopkeepers
var/wares=list("Beer - 10G"=/obj/possessions/Beer)
verb/Buy()
var/selection=input("Buy what?")in wares
selection=wares[selection]
var/obj/O=new selection(usr)
usr<<"Got a [O.name]."

Look up list associations in the help file.
In response to Loduwijk
Thanks.
In response to Loduwijk
Loduwijk wrote:
However, there is a better way to do this with associative lists.
mob/shopkeepers
var/wares=list("Beer - 10G"=/obj/possessions/Beer)
verb/Buy()
var/selection=input("Buy what?")in wares
selection=wares[selection]
var/obj/O=new selection(usr)
usr<<"Got a [O.name]."

Far better still is to allow the player to cancel their selection. (Although it's also a good idea to charge some money for the item, too.)
mob/shopkeepers
var/wares=list("Beer - 10G"=/obj/possessions/Beer)
verb/Buy()
var/selection=input("Buy what?") as null|anything in wares
if(!selection) return
selection=wares[selection]
var/obj/O=new selection(usr)
usr<<"Got a [O.name]."

Lummox JR