Jump to content


Photo

Getting current room number


  • Please log in to reply
11 replies to this topic

#1 jcop

jcop

    GMC Member

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

Posted 12 July 2012 - 04:01 PM

How do I read what the current room number is so I can pass that to a function like room_set_background_color()?
  • 0

#2 Jack Indie Box

Jack Indie Box

    GMC Member

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

Posted 12 July 2012 - 04:28 PM

this is stored in the variable "room"

so just write room and itll do the rest :)
  • 1

#3 Merlocker

Merlocker

    No Imagination

  • GMC Member
  • 450 posts
  • Version:GM8

Posted 12 July 2012 - 05:12 PM

if you name your room R_one then use
room_set_background_color(R_one)

  • 0

#4 jcop

jcop

    GMC Member

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

Posted 12 July 2012 - 05:16 PM

Yeah... I wanted to set it from the player object without having to keep track of the room number myself. Was just looking from a global variable that knows the current room number. I ended up finding background_color thanks to the forums and used that and it works perfectly without needing to know the room number.
  • 0

#5 Merlocker

Merlocker

    No Imagination

  • GMC Member
  • 450 posts
  • Version:GM8

Posted 12 July 2012 - 06:10 PM

In game maker you don't need the number, just use the room name, I had this trouble before.
  • 0

#6 jcop

jcop

    GMC Member

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

Posted 12 July 2012 - 06:12 PM

What if you don't know the room name in the object you want to use to reference the current room?
  • 0

#7 Merlocker

Merlocker

    No Imagination

  • GMC Member
  • 450 posts
  • Version:GM8

Posted 12 July 2012 - 06:18 PM

I'm not sure with studio, but in the room editor under settings there should be a box that has the room's name. You can always just change it to w.e you want.
  • 0

#8 jcop

jcop

    GMC Member

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

Posted 12 July 2012 - 06:24 PM

I need to get it in code for an event of an object.
  • 0

#9 Merlocker

Merlocker

    No Imagination

  • GMC Member
  • 450 posts
  • Version:GM8

Posted 12 July 2012 - 06:25 PM

room_set_background_color(Room_Name)
  • 0

#10 Kouri

Kouri

    GMC Member

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

Posted 12 July 2012 - 09:42 PM

You got your answer in the first reply.

this is stored in the variable "room"

so just write room and itll do the rest :)


//Set current room's background color to White and draw bg color
room_set_background_color( room, c_white, true );

Edited by Kouri, 12 July 2012 - 09:44 PM.

  • 1

#11 Jack Indie Box

Jack Indie Box

    GMC Member

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

Posted 13 July 2012 - 08:19 AM

room is a special global variable(just like health or score....) so as you didnt seem to understand. when ever you type room on its own, game maker retrieves the current room's id and uses it in your code. no tricks needed
  • 0

#12 Erik Leppen

Erik Leppen

    GMC Member

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

Posted 13 July 2012 - 08:51 AM

Can you change properties of the active room?

From the manual:

The following functions are used for creating rooms and changing room properties (please note that these functions should be used with rooms that are not the current room otherwise errors and unpredicatable behaviours can occur):

You are better of changing the background color before you go to that room.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users