var/list/inventory = list()
name = "Shop Keeper"
set src in view(2)
switch(input(usr, "What would you like to do?") in list("Buy", "Sell"))
var/obj/O = input(usr, "What would you like to buy?") in inventory
if(usr.money >= O.value)
usr.money -= O.value
usr.contents += new O
var/obj/O = input(usr, "Which object would you like to sell?") in usr.contents
O.value += 1
switch(input(usr, "Are you sure you want to sell [O.name]?") in list("Yes", "No"))
O.value /= 2
usr.contents -= O
usr.money += O.value
inventory = list(/obj/TV, /obj/rug)
When i run this, and try to buy something from the shopkeeper, i get an error message saying:
runtime error: Cannot read /obj/TV (/obj/TV).value
proc name: Action (/mob/shopkeeper/Action)
usr: Darkoro (/mob)
src: Shop Keeper (/mob/shopkeeper/Viola)
Shop Keeper (/mob/shopkeeper/Viola): Action()
I guessed that i did something wrong (No duh sherlock?). So, how would I fix it?
For the record, Viola is the name of the shop keeper from the city of Viola. Hence the inventory var being declared in shopkeeper, and being overwritten (each city has different items in stock).