ID:921970
 
Keywords: inventory, shop
Problem description:

I have a shop system in place wherein there is a list of items and you pick from one of them. If you pick, say, a dagger, how do I go about adding a dagger to the player's inventory from there?
You make the obj then use Move() to place it in the player's contents.
http://www.byond.com/docs/ref/info.html#/atom/movable/proc/ Move
The object is already in the code. I just need to remember what you do to like, spawn the item into your inventory.
new()
/obj/Items/Potions/Small_Health_Potion = variablex
variablex.Move(usr)?
I feel like it is somewhere along those lines but it has been a while...
Did you click the link I provided? It explains just what you're asking for if I'm not mistaken.
Emm wouldnt usr.contents += object chosen work?
It really depends on how you have set up your shops.

For instance: In the following setup:

mob
shopkeeper
var
list/shop = newlist(/obj/item/sword)


You could spawn a copy of the item by doing the following:

var/obj/o = shop[1]
var/obj/oc = new o.type()

mob.contents += oc //replace mob with a reference to whichever mob you want to add the item to.


Or you could move the item by doing the following:

var/obj/o = shop[1]
o.Move(mob) //again,
shop.Remove(o)


Again, my knowledge of DM is a bit rusty, so there might be a minor error here or there. It's been about 2 years since I've worked with DM, so I'm using a more general syntax (I've been working with Java, Actionscript, and C# the last several years.)
In response to Ter13
You pretty much got it. Though the two variables for one object is un-needed.