GML Grabbing Variable Values From Object IDs In DS Lists

I'm trying to set up a system where once a teleporter object (obj_teleporter) collides with the player, it looks through a DS list "global.tele_list" which stores the ids of any teleport stops (obj_teleportstop) in the current room, then when it finds one with a matching tele_id value (ex: both the teleporter and teleport stop have a their tele_id set to 1), it'll store that object in a variable (target) and change the players x and y to match the target's;
I have an object (manager) that has the code;
Code:
Room Start: 
global.tele_list = ds_list_create();
The teleport stops have this code in their create events;
Code:
Create:
tele_id = 0; 
ds_list_add(global.tele_list, id);
And the teleporters have this set of code;
Code:
Create:
tele_id = 0;
target = 0;
Code:
Step:
if (place_meeting(x,y,obj_player))
{
    target = ds_list_find_value(global.tele_list, tele_id);
    obj_player.x = target.x;
    obj_player.y = target.y;
}
(IDs are set in creation code).

Though when I try to run the game, I get this error message;

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_teleportstop:

global variable name 'tele_list' index (100006) not set before reading it.
at gml_Object_obj_teleportstop_Create_0 (line 2) - ds_list_add(global.tele_list, id);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_teleportstop_Create_0 (line 2)


I'd like to know how I would actually achieve this if my code is horribly wrong, as I've only recently started using Gamemaker.
 

curato

Member
I have a loading room if you will that is my first room when the game start. I load any manager objects there and make sure everything is loaded then have it shift to my title page. That avoids errors that can occur with the engine not loading objects in the manner you intend. Also you should check that before you try to use it with instance_exists.
 

Amon

Member
I second the part regarding checking if the instance exists first with instance_exists. You could be trying to store the id of something that hasn't been instantiated yet.
 
Top