• 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!

Something's not right with this

F

FactorX12

Guest
Ok, so I am trying to make a platformer and I need to be able to switch between specified rooms that are set up like this:
r1_1
the first number being current level, the second number being which room of the current level player is in.
I tried doing this:
room_goto(r1_1); which worked fine.
so, I made a formatter that takes the current level and the desired room to go to within that level and joins it to that format, like this:
level = 1;
room = 1;
room_goto("r" + string(level) + "_" + string(room));
and it didn't switch. keep in mind, the room number is being increased/decreased right before the room switches, so it will go to the next room. I also tried outputting the returned string that it gives me like this:
show_message("r" + string(level) + "_" + string(room));
and it output:
r1_1. So, my question is, Am I doing something wrong or is it gamemaker? that formatter I made puts out the same thing that I typed in and it switched, but for some reason, if I use the formatter, it doesn't switch. I am very frustrated right now, so any help would be nice. tell me if something doesn't make sense and I will clear it up.
 

Slyddar

Member
Room is an in built GM variable, so you can't use it to store anything yourself. Also you can use asset_get_index() to get the correct room format.
Code:
level = 1;
_room = 1;
var rm = asset_get_index("r" + string(level) + "_" + string(_room));
room_goto(rm);
 
N

noobhere

Guest
Room is an in built GM variable, so you can't use it to store anything yourself. Also you can use asset_get_index() to get the correct room format.
Code:
level = 1;
_room = 1;
var rm = asset_get_index("r" + string(level) + "_" + string(_room));
room_goto(rm);
Well, that's better
 
F

FactorX12

Guest
Room is an in built GM variable, so you can't use it to store anything yourself. Also you can use asset_get_index() to get the correct room format.
Code:
level = 1;
_room = 1;
var rm = asset_get_index("r" + string(level) + "_" + string(_room));
room_goto(rm);
Ah, yes! this solved it! Thanks bro!
 
Top