1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 [SOLVED] Warp/Door Bootup Variable player_x Read Error

Discussion in 'Programming' started by mario_head, Mar 15, 2019.

  1. mario_head

    mario_head Member

    Joined:
    Mar 15, 2019
    Posts:
    2
    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.
     
  2. Relic

    Relic Member

    Joined:
    Jun 27, 2017
    Posts:
    743
    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.
     
  3. mario_head

    mario_head Member

    Joined:
    Mar 15, 2019
    Posts:
    2
    That worked, thanks! I appreciate the help!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice