ID:139539
 
Code:
proc/UpdateInventory()
var/itemCount = 0

winset(src, "default.winInventory", "current-cell=1,1")
src << output("Inventory:", "default.winInventory")

for (var/obj/item/I in src.inventory)
++itemCount
winset(src, "default.winInventory", "current-cell=[itemCount+1],1")
src << output(I, "default.winInventory")


Problem description:
Alright, so I've seen there's alot of issues with implementing interactive inventory in a grid, but I am still unsure of the cause.

Currently, The item is output to the inventory grid properly; however, I want access to it's popup menu and Click() proc.

I was reading that there is a common mistake of making an object variable with a limited scope, which inevitably gets destroyed at the end of the proc. I think that might be what I'm doing here, I'm just not really sure if I is a reference or a shallow copy of the actual item in src.inventory.
Nevermind. I found that by using the object's Move proc and moving it to the player mob, the functionality of the object is preserved. Why this is, I am not sure. but it works.

Here is the code for anyone else who might run into this problem.

verb/mob/Get(var/obj/item/O)
if (istype(O,/obj/item))
if (istype(O,/obj/item/gold))
src.wealth += O.value
if (istype(O,/obj/item) && !istype(O,/obj/item/gold))
usr << "You pick up a [O.name]."
O.Move(src)

proc/mob/player/UpdateInventory()
var/itemCount = 0

winset(src, "default.winInventory", "current-cell=1,1")
src << output("Inventory:", "default.winInventory")

for (var/obj/item/I in src)
++itemCount
winset(src, "default.winInventory", "current-cell=[itemCount+1],1")
src << output(I, "default.winInventory")
In response to Kaezon
The difference I can see is src.inventory has been changed to src (or src.contents), so its pulling a different list other than what you were looking for in the previous post.
In response to Kaezon
proc/mob/player/UpdateInventory()


shouldn't that be

mob/player/proc/UpdateInventory()