GMS 2 Inherited variable not getting initialised [SOLVED: IDE bug]

Discussion in 'Programming' started by FacesOfMu, Jul 10, 2019 at 6:48 AM.

  1. FacesOfMu

    FacesOfMu Member

    Joined:
    Jun 23, 2018
    Posts:
    55
    I've got an object that has this inheritance:

    par_all
    obj_item
    obj_container

    In the Create event of obj_item, there's
    Code:
    // obj_item Create Event
    event_inherited();
    debug_start = 10;
    
    In the Create event of obj_container, there's
    Code:
    // obj_container Create Event
    event_inherited();
    
    In the Clean Up event of obj_container, there's
    Code:
    // obj_container Clean Up Event
    var debug = debug_start;
    
    At the end of my room, I get the following message:
    Code:
    ERROR!!! :: ############################################################################################
    FATAL ERROR in
    action number 1
    of <Unknown Event>
    for object obj_container:
    
    
    Variable obj_container.debug_start(100051, -2147483648) not set before reading it.
     at gml_Object_obj_container_CleanUp_0 (line 1) - var debug        = debug_start; 
    ############################################################################################
    --------------------------------------------------------------------------------------------
    stack frame is
    gml_Object_obj_container_CleanUp_0 (line 1)
    
    How can this happen?
     
  2. FacesOfMu

    FacesOfMu Member

    Joined:
    Jun 23, 2018
    Posts:
    55
  3. Azenris

    Azenris Member

    Joined:
    Oct 30, 2016
    Posts:
    61
    did you check that the create is called, are you using instance_change or anything
    Is container actually related to the item, did you forget the child-parent setup?
     
  4. meseta

    meseta Member

    Joined:
    Feb 26, 2018
    Posts:
    29
    as discussed on Discord, this is caused by a known GM bug where creating instances right after room_goto() results in the instances being created, but their create code not running. We discovered this bug some time ago, but I think we didn't file the bug ticket, I'll do so now.
     
    Azenris and FacesOfMu like this.
  5. FacesOfMu

    FacesOfMu Member

    Joined:
    Jun 23, 2018
    Posts:
    55
    Thanks Meseta!
     

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