DS list of all of a certain object live in game

T

TurtleBitAlex

Guest
Hello. I need to make a DS list of all the "obj_object" objects currently in my room so that I can reference them all individually in my code. How would I go about doing this? This is so that they can reference each other. Also when the object dies it also needs to get off the list. Is this possible? Thanks
 

chamaeleon

Member
Hello. I need to make a DS list of all the "obj_object" objects currently in my room so that I can reference them all individually in my code. How would I go about doing this? This is so that they can reference each other. Also when the object dies it also needs to get off the list. Is this possible? Thanks
Some event adding the instances, in some object that is not obj_object
Code:
with (obj_object)
{
    ds_list_add(mylist, id);
}
Destroy event for obj_object
Code:
var idx = ds_list_find_index(<instance/object/global>.mylist, id);
if (idx != -1)
{
    ds_list_delete(<instance/object/global>.mylist, idx);
}
 

Pyxus

Member
Hello. I need to make a DS list of all the "obj_object" objects currently in my room so that I can reference them all individually in my code. How would I go about doing this? This is so that they can reference each other. Also when the object dies it also needs to get off the list. Is this possible? Thanks
You could use a for loop
Code:
for (var i = 0; i < instance_number(obj_object); i++) {
list[|i] = instance_find(obj_object, i);
}
 
Top