• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

GMS 2 Variable not defined in room end event

Relic

Member
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?
 

2Dcube

Member
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.
 

FrostyCat

Member
Have you tried setting breakpoints or debug messages in Create and Room End to see which one is running first, if at all?
 

Relic

Member
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.
 
Top