SOLVED room_goto not going to that room

Hello there,
this is a very simple issue but I can't find out what's wrong.
I did this:
//in my project there are 85 rooms
n = get_integer("Tell me the room you want to see","")
if n > 0 and n < 86 {
    ROOM = "Room" + string(n)
} else show_message("Room does not exist :D")
No matter what I give as integer, Game Maker always bring me to the next room (like room_goto_next() does).

Please notice: even if I simply use room_goto(Room54); still I can't reach Room54 but I'll reach ne next room.

Rooms in my projects are all called (for now) "Room#", while # is a number.


Forum Staff
Strings are not room IDs. You can't use them interchangeably.

Use asset_get_index to convert an asset name to an asset ID. Note that this is slow, and you shouldn't rely on reflection to solve problems that can be solved in cleaner or more efficient ways, such as assigning the rooms to an array and using that to index them.

Mr Magnus

Viking King
So, you need to understands the difference between asset indices and strings.

Rooms aren't identified by strings. They are identified by numbers. Room42 could internally be represented by game maker as the number 12.
if you pass in "room53" you're asking game maker to go to the room with the index "room53". There is no room with that index. However "room_goto(12)" could send you to a valid room.

You want something like asset_get_index() which takes in a string and spits out the number that represents that asset. *that* is the value you want to plug in to room_goto().

There are better ways to do what you want to do, but that's a different discussion.
Thanks to both.
This still don't solve my problem, as I mentioned:

Please notice: even if I simply use room_goto(Room54); still I can't reach Room54 but I'll reach ne next room.
This should work, the manual says.
Anyway I also tried a simple room_goto(54) but still the result is always it brings me to the next room (if I'm in room1, it will bring me to room2, etc...).

So what's the problem, ignoring the fact I was trying to fet the value from a string?


Generally, rooms have IDs from 0 to n, with same order, as you have in room manager (or in asset editor when on "custom" sorting view). So, room2 doesn't need to have id=2.

Also, keep in mind that room_goto(Room54) isn't the same as room_goto("Room54"). As mentioned above, it's same as room_goto(asset_get_index("Room54")).

To get real id of room, use: show_debug_message(room_constant_name_from_asset_editor) . Maybe everything works as it should. You should never use real id in code, as room ids might change after dragging resources around asset tree.
Last edited:


To ensure that game doesn't throw an error:
var _room_id = asset_get_index("Room" + string(n)));

if  (_room_id > -1) {