Jump to content


Photo

Going to rooms based on variables


  • Please log in to reply
3 replies to this topic

#1 togman100

togman100

    GMC Member

  • New Member
  • 161 posts

Posted 11 March 2012 - 11:27 PM

Hello. I have the following code.
if global.class_1=0
exit
else
{message_background(mess_back)
message_button(ico_button)
done=show_question("Are you done?")
if done =0 exit
if done=1
{goto_room=("powers_"+string(global.class_1))
room_goto(string(goto_room))
}}
When I run it I get the following error message.

FATAL ERROR in
action number 1
of Mouse Event for Left Pressed
for object done_class:

Unexisting room number: 0

So my question is: is there something special I have to do to go to a room based on a variable or is that just not possible?

Edited by togman100, 11 March 2012 - 11:53 PM.

  • 0

#2 Jakyl11

Jakyl11

    GMC Member

  • GMC Member
  • 3154 posts
  • Version:GM:Studio

Posted 11 March 2012 - 11:45 PM

why not use a switch statement?
like

switch(global.class_1)
{
//if global.class_1=1 do this
   case 1:
	room_goto(roomname1);
  	break;
//now if global.class_1 =2 do this
   case 2:
	room_goto(roomname2)
	break;
//etc...
}

Edited by Jakyl11, 11 March 2012 - 11:47 PM.

  • 0

#3 togman100

togman100

    GMC Member

  • New Member
  • 161 posts

Posted 11 March 2012 - 11:53 PM

why not use a switch statement?
like

switch(global.class_1)
{
//if global.class_1=1 do this
   case 1:
	room_goto(roomname1);
  	break;
//now if global.class_1 =2 do this
   case 2:
	room_goto(roomname2)
	break;
//etc...
}

Very nice, thank you.
  • 0

#4 Jakyl11

Jakyl11

    GMC Member

  • GMC Member
  • 3154 posts
  • Version:GM:Studio

Posted 12 March 2012 - 02:09 AM


why not use a switch statement?
like

switch(global.class_1)
{
//if global.class_1=1 do this
   case 1:
	room_goto(roomname1);
  	break;
//now if global.class_1 =2 do this
   case 2:
	room_goto(roomname2)
	break;
//etc...
}

Very nice, thank you.

np Posted Image
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users