GML How do you reference the next room in the Room Manager's room order?

The term pretty much explains itself.

1612584092652.png

In this example, how would you reference rLevel3 in an alternate way than naming the room later on in programming?
Consistantly naming and naming and naming rooms will waste valuable time in my perspective.
 

EvanSki

Raccoon Jam Host
The room list think of as an enum
so in the pic above room_1 would be whatever room would be where rlevel3 is
 

Gamebot

Member
The documentation does say that room_next should go to the next room within the managers list. You can try to just move them and see if it works...However, I would suggest a more plausible solution...there are MANY ways to handle this here is just a few.

1. RENAME ALL ROOMS TO BE MORE DESCRIPTIVE

YES
GML:
rm_load

rm_menu

rm_level_forest

rm_level_bonkers

NO
GML:
rm_level

rm_level_1

rm_level_2

rm_level_1_1

2. CREATE TWO GLOBAL VARS.

Index number to get to next room.
One for a rooms list you can move into the correct order within a controller object. Make sure these are strings and exact name as your rooms.

ROOM END
Code:
room_goto( global.roomlist[ global.index ] );
global.index += 1;

3. USE ONLY A GLOBAL INDEX

You could just keep a global index number only and a switch statement...which you might have to copy and paste

Code:
switch ( global.index ) {

    case 0: 
    room_goto( rm_load );  global.index += 1;
    break;

    case 1: 
    room_goto( rm_menu ); global.index += 1; 
    break;

    case 2: 
    room_goto( rm_bonkers  ); global.index += 1; 
    break;

}
 
Top