I've been wondering on how to manage this. I've been trying to create a list that includes all objects in it. I will use this list to later include it in an if statement
if(a in objs) Like that. Thing is, I don't have a clue on how to include all of the objects inside a list! Thanks!
Feb 7 2015, 6:16 pm
|
|
If the list includes all objects in it, then (a in objs) is definitely always true.
|
In response to Kaiochao
|
|
No. That is an undefined variable. I need to create the "objs" list, but I don't know how to include all objects in it.
|
In response to Kirshen
|
|
You're trying to check if an object exists?
|
Oh. . how to make a list contain all objects. Very easy, something I learned thanks to I believe Albro.
var/list/OBJS = list() // creates the list Indentation is off since I don't my DreamSeeker on. Hope this is what you meant. |
Why not just use OBJS.Add(t) in /obj/New? This will impact your performance by quite a bit. My way will make sure every object is added to the list (Naturally you'll have to get rid of it on Del()) but it won't have to loop at every login.
|
If you need to iterate through all /obj types that currently exist, use:
for (var/obj/o in world) This will return all /obj types, as well as derived types from /obj. |
It shouldn't be that hard. Just override obj.New() and obj.Del():
var/tmp/list/objs = list() Now when any obj is created, it will be automatically added to the objs list, and when it's destroyed it will be automatically removed from the list. Just be sure that if you override New() or Del() for any subtype of /obj, such as /obj/rock, that you call the default action ..(). |