• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

GML [SOLVED] Using room_goto with a variable? (malformed assignment) AKA don't use room_name as a var

Dr_Nomz

Member
I was trying to have an object that I could collide with to go to a different room, where each one could be given a variable in the room's creation to change what room that object takes you to.

However, I got a malformed assignment error instead.
Code:
//Create:
room_name=lvl_Small_Town;

//Collision with player:
///Moves player to another area.
room_goto(room_name);
Why isn't it working? Is there a better way to do this? Or do I need to say it differently?
 
Hmmm, seems you hit on some internal jiggery with the specific variable room_name. It looks like GMS has that internally as some indicator of something, but any attempts to find out what it is (i.e. show_debug_message(string(room_name)) ) causes the same problem. Just rename room_name to almost anything else.
 

Dr_Nomz

Member
Seriously? That's crazy, it doesn't even mention a function or anything. Okay then, if you say so.

wtf that's so dumb. xD Well thanks for the help!
 
Ever accidentally left a variable in your project that doesn't do anything? Like maybe you had it storing something and you used that variable later on in some function, but you decided you didn't need that function, deleted it but forgot to delete the original variable? Something like that has probably happened. OR maybe they have plans for it in the future and have it put aside, but they haven't implemented the functionality yet.
 

Dr_Nomz

Member
Nope, no instances of a variable called room_name anywhere in my entire project, I used CTRL+SHIFT+F and it's for sure not there. Just a weird thing with the program.

Also it's GMS1.4 so I'm not so sure how likely that last thing you mentioned is.
 

Slyddar

Member
Damn, just wasted a good 30 mins on this trying to work out why global.room_name as a string would output 736 instead of the string I had assigned to it. Tried room_name and got the same thing. Spent way too long looking at other reasons instead of this obscure solution.

Very poor form that there is no mention of it in the engine when entering that variable. Surely something should appear advising it's a pre defined variable and should not be used.
 
Top