GameMaker How to grab an object from a ds_list to use?

J

John Ashmore

Guest
I am trying to find an object in a ds_list, then read values assigned in variables within that object. Depending on the boolean variable "moving" I want to delete all the matching objects in the ds_list. Can I use something like:

var tempobj = ds_list_find_value(obj_eggspawner.eggslisttube1,0);
if (!tempobj.moving)
{
ds_list_delete(obj_eggspawner.eggslisttube1,0)
}

This code is written within object obj_player.
The ds_list is 'eggslisttube1' which is within the obg_eggspawner.

I am getting an error which is:

Variable obj_player.'unknown variable' (100016, -2147483648) not set before reading it.
at gml_Object_obj_player_KeyPress_87 (line 42) - if (!tempobj.moving)
 
The unknown variable is coming after the obj_player, so whatever variable is coming after that has not been defined.

Could you post that line of code?
 
The unknown variable is coming after the obj_player, so whatever variable is coming after that has not been defined.

Could you post that line of code?
edit: Nevermind, tempobj is getting set to undefined because the list is empty. You aren't checking if the list isn't empty. Do that before you do anything else.
 
Last edited:
Top