• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM DS_List returning empty value

P

PhenomenalDev

Guest
I am trying to make a collection of objects be created in order and given a text value however future objects after the first object spawned are empty.

Create:
list = ds_list_create();
ds_list_add(list, "Carrot");
ds_list_add(list, "Onion");
ds_list_add(list, "Tomato");
ds_list_add(list, "Cabbage");

alarm[0] = irandom_range(room_speed,room_speed*2);

Alarm[0]:
x=instance_create(x,y+(irandom_range(0,room_height)),objMovingWord)
x.text=list[|0]
ds_list_delete(list,0)
alarm[0] = irandom_range(room_speed,room_speed*2);
 
H

Homunculus

Guest
Adding to what TsukaYuriko said, you are also saving the new instance to an instance variable named x, but x is a built-in variable. Use a local variable instead, maybe with another name for clarity.
Also, you never stop removing items from the list if the list is empty, which is definitely a problem.
 
P

PhenomenalDev

Guest
Adding to what TsukaYuriko said, you are also saving the new instance to an instance variable named x, but x is a built-in variable. Use a local variable instead, maybe with another name for clarity.
Also, you never stop removing items from the list if the list is empty, which is definitely a problem.
Assigning to x was my issue. That fixed it thanks.
 
Top