room_get_info

This function gets information on a room from storage and returns it as a struct. You can choose to exclude information through the given optional arguments.

NOTE The function cannot be used to get the current state of an active room (the current room or an already visited persistent room). In this case it returns the original state of the room.

The room must have been previously created using The Asset Browser or added in-game using room_add.

The format of the returned struct is as follows:

room_info_struct = 
{
    instances: 
    [
        {/* Instance Info Struct */},
        {/* Instance Info Struct */},
    ],
    layers:
    [
        {
            elements:
            [
                {/* Layer Element Info Struct */},
                {
                    /* Example */
                    type: layerelementtype_tilemap,
                    tiles: [/* Tile Map Data */]
                }
            ]
        },
    ],
    views:
    [
        {/* View Info Struct */},
    ]
}

The tables below list all the possible structs that can be contained in the returned struct:

Room InfoRoom Info

This is the main struct returned by the function. All variables listed below are present at the root of this returned struct:

Room Info Struct
Variable NameData TypeDescription
widthRealThe width of the room
heightRealThe height of the room
creationCodeScript FunctionThe index of the script function that contains this room's creation code
physicsWorldBooleanWhether the room has a physics world
physicsGravityXRealThe physics world's gravity component along the x axis
physicsGravityYRealThe physics world's gravity component along the y axis
physicsPixToMetersRealThe physics world's pixel-to-metre scale
persistentBooleanWhether the room is persistent
enableViewsBooleanWhether views are enabled for the room
clearDisplayBufferBooleanWhether to clear the display buffer before drawing the room
clearViewportBackgroundBooleanWhether to clear viewports' backgrounds before drawing to them
colourColourThe clear colour used when clearDisplayBuffer is set to true
instancesArray of Room Instance Info StructAn array listing all instances placed in the room with basic information on them
layersArray of Room Layer Info StructAn array listing all room layers, in order of increasing depth
viewsArray of Room View Info StructAn array listing all views, ordered by view index

Instance InfoInstance Info

This type of struct represents one instance in the room.

These structs are found in the instances array, which is part of the main struct returned by the function.

Instance Info Struct
Variable NameData TypeDescription
idObject InstanceThe instance ID
object_indexStringThe name of the object this is an instance of (use asset_get_index to get the actual object)
xRealThe x coordinate of the instance's position
yRealThe y coordinate of the instance's position
xscaleRealThe x scale of the instance
yscaleRealThe y scale of the instance
angleRealThe rotation angle of the instance
image_indexRealThe image index used by the instance
image_speedRealThe image speed of the instance
colourColourThe blend colour used to draw the instance
creation_codeScript FunctionThe index of the script function that contains the instance's creation code
pre_creation_codeScript FunctionThe index of the script function that contains the instance's pre-creation code

Layer InfoLayer Info

This type of struct represents one layer in the room.

These structs are found in the layers array, which is part of the main struct returned by the function.

Layer Info Struct
Variable NameData TypeDescription
idRealThe layer ID
nameStringThe name of the layer
visibleBooleanWhether the layer is visible
depthRealThe depth of the layer
xoffsetRealThe x offset of the layer
yoffsetRealThe y offset of the layer
hspeedRealThe horizontal speed of the layer
vspeedRealThe vertical speed of the layer
effectEnabledBooleanWhether the layer filter/effect is currently enabled
effectToBeEnabledBooleanWhether the layer filter/effect should be enabled/disabled in the next frame (the next value of effectEnabled)
effectFX StructA struct containing the effect's parameters (-1 if no layer effect is set)
shaderIDShader AssetThe shader to be applied to the layer (layer_shader)
elementsArray of Room Layer Element Info StructAn array listing all elements on the layer. Each element type struct contains information specific to it.

View InfoView Info

This type of struct represents one view in the room.

These structs are found in the views array, which is part of the main struct returned by the function.

View Info Struct
Variable NameData TypeDescription
visibleBooleanWhether the view is visible
cameraIDCamera IDThe camera assigned to this view
xviewRealThe x coordinate of the view camera's position
yviewRealThe y coordinate of the view camera's position
wviewRealThe width of the view's camera
hviewRealThe height of the view's camera
hspeedRealThe horizontal movement speed of the view
vspeedRealThe vertical movement speed of the view
xportRealThe x position on screen where the view is drawn
yportRealThe y position on screen where the view is drawn
wportRealThe width of the viewport
hportRealThe height of the viewport
objectObject AssetThe object of which the first instance in the room should be followed by the camera
hborderRealThe horizontal border around the instance of the object to follow
vborderRealThe vertical border around the instance of the object to follow

Layer Element InfoLayer Element Info

This type of struct represents one element in a layer.

These structs are found in the elements array, which is part of a layer struct.

Layer Element Info Struct
Variable NameData TypeDescription
All Element Types
idRealThe unique ID of the element
typeLayer Element Type ConstantThe type of element
Background Element Type
sprite_indexSprite AssetThe sprite used by the background
image_indexRealThe sprite's subimage
xscaleRealThe scale along the x axis
yscaleRealThe scale along the y axis
htiledBooleanWhether to tile the background image horizontally
vtiledBooleanWhether to tile the background image vertically
stretchBooleanWhether to stretch the background so it fills the entire room
visibleBooleanWhether the background should be visible
blendColourColourThe blend colour to draw the background with
blendAlphaRealThe alpha value between 0 and 1 to use
image_speedRealThe image speed of the background
speed_typeSprite Speed ConstantThe units in which image_speed is expressed, either spritespeed_framespersecond or spritespeed_framespergameframe
nameStringThe name of the background
Instance Element Type
inst_idObject InstanceThe ID of the instance
Sprite Element Type
sprite_indexSprite AssetThe sprite index of this sprite element
image_indexRealThe subimage of the sprite
xRealThe x coordinate of the sprite's position
yRealThe y coordinate of the sprite's position
image_xscaleRealThe scale of the image along the x axis
image_yscaleRealThe scale of the image along the y axis
image_angleRealThe image angle
image_alphaRealThe alpha value between 0 and 1
image_blendColourThe blend colour
image_speedRealThe animation speed of the image, expressed in speed_type units
speed_typeSprite Speed ConstantThe units in which image_speed is expressed, either spritespeed_framespersecond or spritespeed_framespergameframe
nameStringThe name of the sprite element as given in The Room Editor (default is graphic_*)
Tile Map Element Type
xRealThe x position (or offset) of the tile map in the room
yRealThe y position (or offset) of the tile map in the room
tileset_indexTile Set AssetThe tile set that this tile map uses
data_maskRealThe bitmask value for the tile map
tilesArray of RealThis variable is only present when the tilemap_data parameter is set to true. It is a one-dimensional array that contains all the tile map data, listed row by row.
widthRealThe width in cells of the tile map
heightRealThe height in cells of the tile map
nameStringThe tile map's name
Particle System Element Type
psParticle System AssetThe particle system
xRealThe x coordinate of the particle system's position
yRealThe y coordinate of the particle system's position
angleRealThe angle by which the particle system is rotated
xscaleRealThe scale along the x axis of the particle system
yscaleRealThe scale along the y axis of the particle system
blendColourThe blend colour to use to draw the particle system
alphaRealThe alpha value between 0 and 1 to use
nameStringThe name of the particle system element as defined in The Room Editor (default is particle_*)
Tile Element Type
visibleBooleanWhether the tile is visible
sprite_indexSprite AssetThe sprite this tile is on
xRealThe x coordinate of the tile position
yRealThe y coordinate of the tile position
widthRealThe width of the tile
heightRealThe height of the tile
image_xscaleRealThe scale factor along the x axis of the tile
image_yscaleRealThe scale factor along the y axis of the tile
image_angleRealThe angle of the tile
image_blendColourThe blend colour to use to draw the tile
image_alphaRealThe alpha to use
xoRealThe x offset
yoRealThe y offset
Sequence Element Type
xRealThe x coordinate of the sequence position
yRealThe y coordinate of the sequence position
image_xscaleRealThe scale along the x axis of the entire sequence
image_yscaleRealThe scale along the y axis of the entire sequence
image_angleRealThe angle by which the sequence is rotated
image_alphaRealThe alpha value between 0 and 1 to use
image_blendColourThe blend colour to use to draw the sequence
image_speedRealThe animation speed of the sequence, expressed in speed_type units
speedTypeSprite Speed ConstantThe units in which image_speed is expressed, either spritespeed_framespersecond or spritespeed_framespergameframe
seq_idSequence AssetThe sequence asset
nameStringThe name of the sequence element as defined in The Room Editor (default is graphic_*)
head_positionRealThe playhead position of the sequence

 

Syntax:

room_get_info(room, [views], [instances], [layers], [layer_elements], [tilemap_data]);

ArgumentTypeDescription
roomRoom AssetThe room to get the info from
viewsBooleanOPTIONAL Whether to include view information in the struct (defaults to true)
instancesBooleanOPTIONAL Whether to include instance information in the struct (defaults to true)
layersBooleanOPTIONAL Whether to include layer information in the struct (defaults to true)
layer_elementsBooleanOPTIONAL Whether to include layer element information in the struct (defaults to true, requires layers to be set to true)
tilemap_dataBooleanOPTIONAL Whether to include tile map data in the struct (defaults to true, requires layers and layer_elements to be set to true)

 

Returns:

Room Info Struct

 

Example:

var _info = room_get_info(Room1);
var _info_json = json_stringify(_info, true);
show_debug_message(_info_json);

The above code gets the information of the room Room1, converts the returned struct to a JSON string using json_stringify, then outputs it in a debug message. All view, instance, layer, layer element and tile map information is included in the output.