ID:165638
 
Hey, I have a list of obj's, and I have this verb that creates a new obj, and then checks to see if there's already an object of the same name in the list, and if so, it ends. The problem is, it doesn't do that. Could it possibly be that the object in the list and the object that's created have different values for their variables? If that's the case, how can I get around it? Sorry if that was confusing, here's an example:

obj/Item
var
Stats=0

mob/var/list/Items=new()

mob/verb/Make_New_Obj()
var/obj/Item=new
Item.name=input("Name","Name",null) as null|text
if(!Items.Find(Item.name))
Item.Stats=rand(1,4)
Items.Add(Item)
world<<"Added"
else
world<<"Not Added"


I just tested it, and I'll make an object, and then make another with an identical name, but doesn't add it.
The reason is that what is in the list, is an object. (an /obj) You're looking for a name, or a string. ("an obj")

These can never be equal, so you never find what you're looking for.

Try to find a tutorial or demo about associative lists. With those, you have a list storing two things. The first part of the list stores the name, and the name is associated with the object.

Ex:
MyList[1] contains "Sword"
MyList["Sword"] contains an /obj/Sword
In response to Jon88
Ok, I'll look, but I might get too lazy to actually do anthing. Would another (but highly ineffecient) way be to loop through everything in the list comparing names?