ID:154787
 
Hey There.
I'd like to know how to make group items together when i pick them up and view in the inventory..Which is based on grids.
This is the code i use to view them in the grid..but the items apear in different cells,i'd like them to be groupped if i have for example 2 Swords. is there var i have to call to identify if they are the same? "Type"?

/
mob/proc/UpdateInv()
var/I = 0
for(var/obj/items/O in src.contents)
winset(src, "inventory.inventory", "current-cell=1,[++I]")
src << output(O, "inventory.inventory")
winset(src,"inventory.inventory", "cells=[I]")
You could make a list, and check if the item is already in the inventory and of the same type, and call a ++:

var/dList[0]

for( var/atom/x in contents )
if( dList[x.type] )
dList[x.type][1] ++
else
dList[x.type] = list( 1, x )

for( var/x in dList )
stat( "[dList[x][1]]" ,dList[x][2] )