ID:165047
 
The last time i asked for help on stacking objects in the inventory i thought i had solved the problem, but no. So instead, i dreamed up this code in school today. (it was during a science exam, i think. oh well. :D )
obj
var/quant=1
axe
verb
Pick_up()
set src in oview(0)
for(var/obj/axe/a in usr.contents)
a.quant+=1
a.suffix="axe ([a.quant])"
del(src)
return ..()
usr<<"You pick up an <b>axe</b>."
usr.contents+=src
src.name="Wield"
src.suffix="axe ([quant])"
sword
verb
Pick_up()
set src in oview(0)
for(var/obj/sword/a in usr.contents)
a.quant+=1
a.suffix="sword ([a.quant])"
del(src)
return ..()
usr<<"You pick up a <b>sword</b>."
usr.contents+=src
src.name="Wield"
src.suffix="sword ([quant])"

Yes, yes, rubbishy and filled with mistakes, but instead of correcting all my OTHER mistakes, just answer this question. When i have a stacked object in my inventory and am looking at the inventory statpanel, i constantly get this runtime error:
runtime error: Cannot read null.contents
proc
usr:
src:
call stack:
(/obj)
Adam753 (/mob)
Oh, well i solved that, but the end of one problem is the start of another: how would I make it so that the usr STARTS with a stacked object in his inventory? i tried this:
mob/Login()
var/obj/gold/g=new(loc)
g.quant=50
usr.contents+=g

but it's just not there. what am i doing wrong this time?
In response to Adam753
you're not setting the suffix.
In response to Adam753
You should really have a proc(s) to automatically do stuff such as setting quantity for you rather than having to manually do all that all the time. It will also make sure you don't sometime forget stuff, such as this time. :P