ds_list_size() returning wrong value

V

VediaTony

Guest
Heya!

As the title suggests, I'm getting a very strange bug when working with ds_list.
In my gameplay controller object that is persistent, I create a global ds_list in the CREATE event with the following code:
Code:
global.LEVEL_LIST = ds_list_create();
I also destroy the list within this object but this time it's in the Game End event, this is the code I use to destroy it:
Code:
ds_list_destroy(global.LEVEL_LIST)
global.LEVEL_LIST = -1;
Then I have a room that has 51 SAME objects inside it meaning they run the same code and everything, I proceed to insert these objects into global.LEVEL_LIST by using this code:
Code:
ds_list_add(global.LEVEL_LIST,id)
After all, objects get inserted into the ds_list another object comes called obj_level_manager that is not persistent. This object should loop through the list and make every object inside this list visible, this is also where the issue comes.
I don't use loops to go through the list instead I use alarm[0] (look at the code)

So firstly I get the global.LEVEL_LIST size by using this code (CREATE event):
Code:
list_size = ds_list_size(global.LEVEL_LIST)-1;
alarm[0] = 3;
list_size should be 50 but instead, it's 45.

Then we move to the alarm[0] code which is:
Code:
var tmp = ds_list_find_value(global.LEVEL_LIST,list_size)
tmp.visible = true;
list_size--;
if(list_size >= 0) alarm[0] = 3;
This basically loops through the ds_list sets every object in the list visible. The last line just checks if the current object isn't the last one continue looping.
 

Bayesian

Member
I proceed to insert these objects into global.LEVEL_LIST by using this code:
Where do you do this? In one of the 51 object's create event? If its in with statement in another object it might be running before the 51 objects are finished being created. The only other thing is obj_level_manager is being create before the 51 obects are finished being created. Try using show_debug_message to output the creation order. Also confirm that there there really are 51 objects in the room and nothing is destroying them.
 
V

VediaTony

Guest
Where do you do this? In one of the 51 object's create event? If its in with statement in another object it might be running before the 51 objects are finished being created. The only other thing is obj_level_manager is being create before the 51 obects are finished being created. Try using show_debug_message to output the creation order. Also confirm that there there really are 51 objects in the room and nothing is destroying them.
Whoops forgot to add that. I don't generate these object with code I've placed them into a room via room editor. I've counted them so I'm 100% sure that there are 51 objects
 

samspade

Member
Whoops forgot to add that. I don't generate these object with code I've placed them into a room via room editor. I've counted them so I'm 100% sure that there are 51 objects
Make sure to try the other things Bayesian suggested (and say what the results are). Also, you could put a breakpoint on that line and run the debugger. A single run through might get you the information that you need. It would allow you to count how many times it is triggered, observe which items get counted, and observe creation order.
 
Top