GMS 2 Variable not defined in room end event

Discussion in 'Programming' started by Relic, Oct 7, 2019.

  1. Relic

    Relic Member

    Joined:
    Jun 27, 2017
    Posts:
    720
    I think this is a GM bug rather than my own code but will get your opinions first.

    Create event:
    Code:
    current_vo=noone;
    vo_queue=ds_queue_create()
    Room end event:
    Code:
    if current_vo {
        audio_stop_sound(current_vo)
    }
    
    ds_queue_empty(vo_queue);
    Error:
    ############################################################################################
    FATAL ERROR in
    action number 1
    of Other Event: Room End
    for object obj_controller_VO:
    Variable obj_controller_VO.current_vo(100328, -2147483648) not set before reading it.
    at gml_Object_obj_controller_VO_Other_5 (line 3) - if current_vo {
    ############################################################################################
    --------------------------------------------------------------------------------------------
    stack frame is
    gml_Object_obj_controller_VO_Other_5 (line 3)

    How can current_vo not be defined for the room end event when it is initialised in the create event?

    This ONLY happens when I run in debug mode but not every time. It happens as soon as the game compiles. I have an initialisation room which a global controller changes rooms in the first step event. I try and put a breakpoint here to catch the code before the room transition - but the error occurs before this. So why is a room event code having a fit over "uninitialised" variables before it should even happen?
     
  2. 2Dcube

    2Dcube Member

    Joined:
    Jun 23, 2016
    Posts:
    371
    I've noticed some weird behaviors too when you do things in the very first frame...
    I now make sure to wait a few steps in the "loading room" but I would be curious to know as well why this happens.
     
  3. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,556
    Have you tried setting breakpoints or debug messages in Create and Room End to see which one is running first, if at all?
     
  4. Relic

    Relic Member

    Joined:
    Jun 27, 2017
    Posts:
    720
    No further testing on my end, only confused as the error seems impossible. I’ll narrow down the issue some more and if unresolved will file it as a bug.
     

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