• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Mac OSX Room Order with the new Update

I'm confused about the how the rooms are ordered and the room variable.
Does the "room" variable correspond to the room order? That's the way I expect it to work.
But when I drag a room to the top of the room order and run the game the "room" variables says it's 6. I used this code to check the room variable: draw_text(40,60, room)

What I'm trying to do is randomize the rooms, but the "room" variable isn't working the way I thought.

I'm using GM 2 v2.3.0.529
 

chamaeleon

Member
The room variable will hold the room asset number, but I don't think any other guarantees are made. The functions room_goto_next() and room_goto_previous() will go to the next and previous room, as indicated by your room order editor. At no point does the manual indicate that this is done by adding or subtracting one from the current room asset id. Relying on any particular value being assigned to any given room is not a good idea, nor how one asset id may correspond to the next. My recommendation would be to store all your rooms in a data structure of your choice that allows you to do what you need.
GML:
my_rooms = ds_list_create();
ds_list_add(my_rooms, roomA, roomB, ..., roomM);
ds_list_add(my_rooms, roomN, roomO, ..., roomZ);
ds_list_shuffle(my_rooms);
Now you have a ds_list that contains rooms in a random order and you can use an index into it to pick one, you can remove entries to avoid visiting them again, etc.
 
Top