#Switching rooms is freezing the game

1 messages · Page 1 of 1 (latest)

visual ore
#

I thought I fucked up smth with my room transition object somehow but it's the code room_goto(room) that's freezing the game

Idk why or how this is happening, everything was working fine before

jovial tusk
#

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

visual ore
jovial tusk
#

So I think you should use a different variable

visual ore
#

specifically the code is room_goto(NextArea)

jovial tusk
#

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

visual ore
#

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

jovial tusk
#

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

visual ore
#

step through?

jovial tusk
#

Under the toolbar will be the many debugger functions

#

You’d want “step into a code block or script”

visual ore
#

alr
what do I do from there?

jovial tusk
#

Where are we currently in the debugger?

#

(Screenshot the current paused view pls)

visual ore
jovial tusk
#

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

visual ore
#

just like
any while or for loops in general? cuz I dont have any that have to do with rooms.

jovial tusk
#

Erm no

#

Did you pause when your game froze

#

Or just paused randomly?

visual ore
#

no I paused when the game froze

jovial tusk
#

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

visual ore
#

so I just spam step into until it gets to a line that keeps looping?

jovial tusk
#

Until it gets to one that looks like a loop

#

Or especially a room_goto call

visual ore
jovial tusk
#

I assume activePlr is the player here

#

In which case, makes sense

visual ore
jovial tusk
#

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)

visual ore
#

im confused

jovial tusk
#

What are you confused about?

visual ore
#

The player never "transitions", the obj that makes the screen fade to black does.

jovial tusk
#

#

Right, but does that if statement succeed?

#

That’s the important part

visual ore
#

yeah

jovial tusk
#

So then

visual ore
#

it gets to room_goto, but it freezes after that

jovial tusk
#

???

#

I thought we were already in the frozen part

#

That’s the whole point we’re checking…

visual ore
#

yeah
I touched the obj, it got to room_goto, the game froze and then I paused

jovial tusk
#

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

visual ore
#

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

jovial tusk
#

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

visual ore
jovial tusk
#

Yeah, but I won’t be able to look at it until 4 hours later

visual ore
#

that's fine

#

should I send it in dms?

jovial tusk
#

Yeah 👌

visual ore
#

aite

jovial tusk
#

@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

jovial tusk
#

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

visual ore
#

oh yeah I didn't explain much about the game itself

visual ore
#

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:

  • home being set to a different room, causing the check in oDeath to 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

visual ore
#

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!

jovial tusk
#

Glad we got there in the end 🙌