• 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 [SOLVED] Warp/Door Bootup Variable player_x Read Error

M

mario_head

Guest
I've been following the instructions of a video on YouTube for coding in doors that warp the player to other rooms, and after following his exact instructions I've run into an error. In the build process when loading the game, an error appears:
Code:
############################################################################################
FATAL ERROR in
action number 1
of Other Event: Room Start
for object obj_player:

Variable obj_player.player_x(100003, -2147483648) not set before reading it.
 at gml_Object_obj_player_StartRoomEvent_1 (line 1) - x = player_x;
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_player_StartRoomEvent_1 (line 1)"
The actual code:

Code:
obj_player:
    
    obj_player_Create_1
        sprite_index = spr_spess; (Unrelated)
        image_speed = .75; (Unrelated)
        obj_player.persistent = true; (Sets Persistent)
        //var player_x = x; (Failed Attempt to Define the Variables in Question)
        //var player_y = y; (Failed Attempt to Define the Variables in Question)

    obj_player_obj_door_1 (Collision Event with Door)
        player_x = other.target_x;
        player_y = other.target_y;

    obj_player_Room Start_1
        x = player_x;
        y = player_y;

obj_door_control
    obj_door_control_Game Start_1
        obj_player.player_x = obj_player.xstart;
        obj_player.player_y = obj_player.ystart;
        room_goto(other.targetRoom);

obj_door Creation Code in (Starting Room)
    target_Room = (Next Room);
    target_x = 1728;
    target_y = 224;
The video:

The top comment on the video has stated that the error was with the Player object not being persistent, however I've made it persistent and nothing has changed. I've tried defining the variables within the code and the error has not resolved. I've been dealing with this issue for about a week or so now (I took a break from it to prevent myself from getting too worked up over it).

I apologize if any part of this thread is lacking. I'm relatively new to Game Maker (I've made a game using DnD many years ago and it's half-broken due to imported resources that I no longer have access to) and this is my first forum post.
 

Relic

Member
In the create event, you have commented out player_x = x. This means player_x does not exist when it is needed in the roomstart event (happens after create event) when the player is moved to x=player_x.

Uncomment out the code (remove //) and also get ride of the “var” bit. Var is used to create temporary variables (called local variables) that won’t exist after the current event.
 
Top