#Switching rooms is freezing the game
1 messages · Page 1 of 1 (latest)
Which event is room_goto(room) running in?
Fwiw, if it’s room start or room end event, it’ll be effectively entering an infinite loop since it has to switch rooms after those events end
it's in the step event of my transition object
you touch it, the screen fades to black and then it just sends you to the room assigned to it
Right, and room is a built in variable meaning the current room
So I think you should use a different variable
this is what I mean by the room assigned to it
specifically the code is room_goto(NextArea)
You were saying room_goto(room)
Not room_goto(NextArea)
You can see why that would be confusing
They are not the same in this context
I meant room_goto(room) as the statement. the code for swapping rooms, not the actual code I had written down. sorry bout that
in any case, it used to work but now it's freezing my game even though I didn't do anything to it
For the future, let’s not refer to the statement as room ^^
Moving on
It’s gonna be hard to say why, but it’s obvious that an infinite loop is occurring
You’ll have to use the debugger
And when the game freezes
Pause the game with the debugger
And step through
step through?
Under the toolbar will be the many debugger functions
You’d want “step into a code block or script”
alr
what do I do from there?
Okay we need to find wherever the loop is exactly
This looks like that it’s a room loop I presume?
Try to find any room goto calls or while/for loops
just like
any while or for loops in general? cuz I dont have any that have to do with rooms.
no I paused when the game froze
Okay just making sure
What I mean by for/while loops is well, basically they’re one of the many things that can cause an infinite loop
Same for do/until
Same for room_goto being called infinitely within the same frame
You just need to either find whatever loop initiator that caused it
So you need to step through it
so I just spam step into until it gets to a line that keeps looping?
ye
You might need something to determine if you’ve recently transitioned or not
Like a global variable
global.transitioned
Could set it to true whenever you’re transitioning, and then set it to false only when you walk away from wherever you’ve transitioned to (so i.e. a trigger)
im confused
What are you confused about?
The player never "transitions", the obj that makes the screen fade to black does.
yeah
So then
it gets to room_goto, but it freezes after that
???
I thought we were already in the frozen part
That’s the whole point we’re checking…
yeah
I touched the obj, it got to room_goto, the game froze and then I paused
Right, and now we need to find a loop OR room_goto
Doesn’t matter what the code is doing WHILE it’s frozen
But we need to validate that we’re not just making a recursive call
Or an endless loop
All the while we are in a frozen state
Not before
This is how we isolate infinite loops
So you need to actively step through while it’s frozen
Until you land on a loop, or a room_goto call
Again, doesn’t matter what you are doing. Or what’s being transitioned
my thing is Ik the object works, and I dont have any while loops that run infinitely. its the statement itself that is causing issues
like if I just use the spacebar to swap rooms in the player's code( if keyboard_check_pressed(vk_spacebar) { room_goto(rTest_A01) } ), it freezes there too
Look, I’m just merely telling you what to look out for
You can tell me you know it works, but your game is frozen
Room_goto does not freeze by itself under any circumstances
Unless you are somehow in an infinite loop (or recursively calling it)
And unless you’re willing to prove that wrong, or send me your project so i can look what’s going on (after i get off work)
Or show more code that is relevant to the transition system
It’s gonna be hard for me to tell you what’s wrong
I can send you the project, it'd probably be easier that way
Yeah, but I won’t be able to look at it until 4 hours later
Yeah 👌
aite
@visual ore I ended up looking at the project, but the game hasn't frozen for me once, despite my numerous best attempts
In fact, everything is still animating on screen
Just the player is gone whenever I die
And that's it
If anything, that's the only bug I can see
If that's what you were meaning, again, need to be a bit clearer on that.
A player dying and warping to a room (or room restart) isn't interpreted well when you say it's freezing
oh yeah I didn't explain much about the game itself
The game has multiple characters n you swap between them with IJKL. when you die, the game just waits for you to swap to the next character. If everyone dies and theres noone left to swap to, THEN the game resets.
the character closest to a room transition is the one mapped to K, so if you swap to him and then walk to the far left, you'll see the bug
@jovial tusk
I've had more of a gander at it (on limited time atm), and from what I can tell in the code, the transition instance step event stops running entirely. The Room change does occur, but I'm still digging at the root cause
Okay
I finally found something
@visual ore turns out that you were stuck in an infinite room_restart() call.
And that was caused by:
homebeing set to a differentroom, causing the check inoDeathto fail completely- All of the player instances are "persistent"
The last point is more specific, because they do not refire their create events whenever they change rooms.
They are never recreated
If I remove the additional check in oDeath, it stops the infinite loop
These are the kind of things that I was mainly talking about, and it's a LOT harder to debug. I can admit that
I had to spend a couple minutes messing with the debugger until I noticed that cleanup events were constantly firing, for instances that shouldn't be destroyed
ah
I kinda get it but also not really
anyway, that's mildly annoying
I had that check there so oDeath wouldn't count players in other rooms as alive, since having the game wait for you to swap to an inacessible character would softlock the game. but if that specific check is what's causing the room transition to break, then I need a different way to do that.
that didn't take too long to figure out though, everything works fine now
Thanks a ton for the help!
Glad we got there in the end 🙌