Contents

Layer Access

You can access layers in a map in one of several ways.

map.layer Table

A map stores each of the map's layers in the map.layer table. You can access a layer through either the layer's name or the layer's index. The name corresponds to the name in Tiled, and index to the level of the layer in Tiled. Layers are built just as they're displayed in Tiled - layer #1 is on top, layer #2 is next, and the last layer's index is the length of the layer table.

local layer

layer = map.layer[1] -- The first layer in the map

layer = map.layer["objects"] -- The layer named "objects" in Tiled

layer = map.layer[#map.layer] -- The last layer in the map


Iterators

Maps also provide a number of ways to iterate through each type of layer in the map. See the layer iterator reference for more information.