ID:262977
 
This is code for a leather pouch. Adding the first item works. Then, every time I try to add 1, I get a runtime error - type mismatch.
obj
item
storage
bag1
verb

add()
if(contents.len >= 3)
alert("This pouch is already full!", "Cannot comply")
return
var/obj/A = input("Choose an item to put into the bag", "Filling Bag") as obj in usr.contents
if(istype(A, /obj/item/Def) || istype(A, /obj/item/Mdef) || istype(A, /obj/item/Mweapon) || istype(A, /obj/item/Orb_bonus_def) || istype(A, /obj/item/Orb_bonus_wpn) || istype(A, /obj/item/bweapon))
alert("You cannot place equipped or equippable items in a bag!", "Cannot comply")
return
else
contained += A
usr.contents -= A
usr << "[A] added to the [name]."

Any ideas?


--Vito


That problably means, that contained isn't a list.
In response to CIB
var/list/contained

That's what's bothering me. It thinks a list is not a list, in my opinion.

--Vito
In response to Vito Stolidus
var/mob/m


Is m then a mob? No, m is null.

var/list/contained


Is contained then a list? No, contained is null.

var/list/contained=list()


Better.

Or you could just use the contents list.
In response to Jp
Oh...

--Vito