ID:267903
 
so i want the usr to be able to buy different things from the shopkeeper depending on what has been bought and sold to it. this is what i have

Shop_Keeper
icon = 'people.dmi'
icon_state = "shop"
var/list/inventory = list(/obj/items/Healing_Herb, /obj/items/Magic_Potion)
verb
Buy()
set src in view(1)
var/obj/items/o = input("What would you like to buy?") in inventory
if(o:cost <= usr.gold)
o:loc = usr
usr.gold -= o:cost
else
usr << "ShopKeeper: That costs too much. It costs [o:cost]"
Sell()
set src in view(1)
var/obj/items/o = input("What would you like to sell?") in usr
o:loc = inventory
usr.gold += o:cost / 2


but im getting:
runtime error: Cannot read /obj/items/Healing_Herb (/obj/items/Healing_Herb).cost
proc name: Buy (/mob/Shop_Keeper/verb/Buy)
usr: Dark Weasel (/mob)
src: Shop Keeper (/mob/Shop_Keeper)
call stack:
Shop Keeper (/mob/Shop_Keeper): Buy()

when i try to buy something
It's because /obj/items/Healing_Herb and /obj/items/Magic_Potion aren't actual objs, they are just obj types.
New()
>>>>. = ..()
>>>>for(var/t in inventory) inventory[inventory.Find(t)] = new t ()
>>>>return .


What that does is scroll through the inventory list when a new Shop_Keeper is made, then replaces the things it finds (paths) with a new object of the type.
In response to DarkView
oh thx
ill try it...
...
ok it worked