You can iterate through objects in an object layer in one of multiple ways.
for object in map.layer[x].<iterator name>() do
-- Do something to object
end
layer.nameIs(n)
: Iterates through all objects whose name is n
. The name corresponds to what was entered into the Tiled "name" field for the object.layer.nameMatches(n)
: Iterates through all objects whose name matches n
, using Lua patterns. The name corresponds to what was entered into the Tiled "name" field for the object.layer.typeIs(n)
: Iterates through all objects whose type is n
. Tye type corresponds to what was entered into the Tiled "type" field for the object.layer.typeMatches(n)
: Iterates through all objects whose type matches n
, using Lua patterns. The type corresponds to what was entered into the Tiled "type" field for the object.layer.objTypeIs(n)
: Iterates through all objects whose object type is n
. The object type of an object corresponds to the way the object was created in Tiled, and is readable through an object's _objType
property. Possible object types are: ellipse
, polygon
, polyline
, image
, point
, square
, and rectangle
. To force Dusk to classify all rectangle objects as rectangle
, set the objTypeRectPointSquare
preference to false
.layer.objects()
: Iterates through all objects in the layer.