Edit: Also if someone can tell me how to get rid of the underscore in the output screen for the items, I would greatly appreciate it.
Merchant
icon_state="merchant"
verb
Shop()
set src in oview(0)
var/list/ItemList=list( // [Item] = [Price]
"Health_Potion"=5,
"Iron_Dagger"=10,
"Iron_Short_Sword"=15,
"Leather_Breast_Plate"=15,
"Nothing"=0
)
var/Item2Buy=input("What would you like to buy?","Merchant's Items",) as anything in ItemList
var/Price=ItemList[Item2Buy]
if(Price) //if it has no price you cant buy it!
if(usr.Gold<Price)
usr<<"You need [ItemList[Item2Buy]] gold! You only have [usr.Gold]!"
else
usr<<"You Buy a [Item2Buy] for [ItemList[Item2Buy]] Gold"
var/obj/NewItem="/obj/Items/[Item2Buy]" //note: this only sells items of the obj/Items/ path
NewItem=new NewItem //creates the actual object
usr.contents+=NewItem;usr.Items+=NewItem //add it to both their contents and Items list
usr.Gold-=Price
usr<<"Please come again!"
For this to work, get rid of the variable that defines "Price" in the code.
Be sure to assign the price variable to each obj wherever it is in the code. So for example: