ID:146316
 
Code:
    Click()
if(src.status == "pack")
var/drop = alert("Drop this item?","Drop [src]","Yes","No")
if(drop == "Yes")
src.status = ""
var/count = 0
for(var/obj/X in usr.contents)
if(X.type == src.type)
count += 1
for(var/obj/X in usr.contents)
if(X.type == src.type)
del(X)
if(count > 1)
count -= 1
for(var/i=0;i<count;i++)
usr.contents.Add(src)

usr.client.screen -= src

var/obj/item_focus/K = new/obj/item_focus (usr.last_x,usr.last_y,usr.last_z)
src.Move(K.loc)
del(K)


Problem description:

This code is attached to all of the items within the set of obj/items. What I'm trying to do with it is make it so when someone clicks an item on screen (which is displayed as a result of being part of the users contents list), it removes the item from the screen and ads a new one of those items to a place defined by (usr.last_x,usr.last_y,usr.last_z). For some reason it will not place the item at that point. It will place the item on the same z level as the user but not another (as is required).
I'm stuck and have been stuck for hours now. Any help at all would be muchly appreciated. If any more code is needed to help, just ask for it.

Thanks in advance

- GunRunner

   Click()
if(src.status == "pack")
var/drop = alert("Drop this item?","Drop [src]","Yes","No")
if(drop == "Yes")
src.status = ""
var/count = 0
for(var/obj/X in usr.contents) //don't do two loops, one will do fine.
if(X.type == src.type)
count += 1
del(X)
if(count > 1)
count -= 1
for(var/i=0;i<count;i++)
usr.contents.Add(src)

usr.client.screen -= src

var/obj/item_focus/K = new/obj/item_focus (locate(usr.last_x,usr.last_y,usr.last_z)) //use locate.
src.Move(K.loc)
del(K)


Your way of managing items isn't very good by the way. Read Goku72's demo.