ID:1930580
 
(See the best response by Ter13.)
Code:
mob
Stat()
..()
//statpanel("Inventory")
stat(contents)
for(var/obj/O in src)
src<<output(O,"Items")


The items only appear in the stats tab under the Health and stuff. I would like it to appear in the grid styled window I made. In the code I put src.loc = usr. Is there something I messed up? What exactly did I do wrong?


List grids shouldn't be updated in Stat(), they should be updated whenever that list changes.

stat(contents) will show your contents list in the current statpanel. Since you don't want that, remove that line.

src<<output(O,"Items") will output all items to the same cell in the grid, which probably isn't what you want.

The usual way of outputting a list to a grid goes like this:
client/proc/ListToGrid(List[], GridID)
for(var/index in 1 to List.len)
src << output(List[index], "[GridID]:[index]")
winset(src, GridID, "cells=[List.len]")


And you'd call this whenever your contents changes:
mob/proc/ContentsChanged()
client.ListToGrid(contents, "Items")
where do i put item move
In response to Dayvon64
After you get/drop an item, call player.ContentsChanged() (replace 'player' with the variable referring to the mob that got/dropped the item). For example, after you have src.loc = usr.loc, you'd call usr.ContentsChanged().
For Drop and Get I have this error ealWorld.dm:156:error: Item.Move: undefined type: Item.Move Should I replace Item.Move with something else?
In response to Dayvon64
Change Item to the variable that refers to the item involved in the Get/Drop (probably src).
So if it's a helmet it would be Helmet.Move?
In response to Dayvon64
You mentioned in your first post that you have src.loc = usr somewhere. Can you show the code related to that?
obj
Items
DblClick()
if(src.loc != usr && usr in bounds(src, 30))
view() << sound('Confirm.ogg', volume=100)
switch(alert(usr,"Do you want to pick up the [src]?","Grab","Yes","No"))
if("Yes")
src.loc = usr

This is the Src.loc=usr

Health_Potion
icon = 'Items.dmi'
icon_state = "Health Potion"
Use()
..()
if (usr.Health == usr.MHealth)
usr << "You already have full Health!"
else
usr << "You drink the Health Potion."
usr.Health = min(usr.Health + 50, usr.MHealth) // select the minimum, this way Health never passes MHealth
usr.contents -= src
src.loc = null // garbage collect instead of forced deletion

This is the Item
Best response
obj
Items
DblClick()
if(src.loc != usr && usr in bounds(src, 30))
view() << sound('Confirm.ogg', volume=100)
switch(alert(usr,"Do you want to pick up the [src]?","Grab","Yes","No"))
if("Yes")
Move(usr)


Health_Potion
icon = 'Items.dmi'
icon_state = "Health Potion"
Use()
..()
if (usr.Health == usr.MHealth)
usr << "You already have full Health!"
else
usr << "You drink the Health Potion."
usr.Health = min(usr.Health + 50, usr.MHealth) // select the minimum, this way Health never passes MHealth
MoveNull()



Here's my MoveNull() function:

atom
movable
proc
MoveNull(force=1)
if(loc)
if(isturf(loc))
var/list/oloc = obounds(src)
var/atom/blockage
if(!force)
for(var/area/a in oloc)
if(!a.Exit(src,null))
blockage = a
break
for(var/turf/t in oloc)
if(!t.Exit(src,null))
blockage = t
break
if(!blockage)
for(var/atom/movable/o in oloc)
if(!o.Uncross(src))
blockage = o
break
if(blockage)
Bump(blockage)
return 0
loc = null
#ifdef PIXEL_MOVEMENT
step_x = 0
step_y = 0
#endif
for(var/area/a in oloc)
a.Exited(src,null)
for(var/turf/t in oloc)
t.Exited(src,null)
for(var/atom/movable/o in oloc)
o.Uncrossed(src)
else
var/atom/oloc = loc
if(!force)
if(!oloc.Exit(src,null))
Bump(oloc)
return 0
oloc.Exited(src,null)
loc = null
#ifdef PIXEL_MOVEMENT
step_x = 0
step_y = 0
#endif
return 1


Then you can update the inventory based on mob.Entered()/Exited().
I have gotten Variables.dm:94:error: t.Exit: undefined var should I just do mob/var/t.Exit? Or is it a special kind of var.
Fixed the minor typo.
It is still not showing in the Grid

mob
Stat()
..()
stat(contents)
for(var/obj/O in src)
src<<output(O,"Items")

Is there something wrong with my stat?
Is there something wrong with my stat?

You didn't read anything Kaio told you.

http://www.byond.com/forum/?post=1930580#comment16609581

Why should we continue to help you if you aren't going to bother to read?
No I thought you were doing something completely different so I switched it.
No I thought you were doing something completely different so I switched it.

That makes sense, perhaps I should have been clearer that I was showing you a way to do what Kaio is talking about.

By Moving the items, you can now detect when an object has left the player's inventory on mob/Entered()/Exited(), and update the inventory like Kaio told you from there.
Thank you, but I suppose the only problem is that I made the Grid incorrectly.