Skip to main content
The Elements namespace provides a single entry point for looking up any entity in the current level by its editor-assigned tag. When you assign a tag to a block, side, item, enemy, ball, or decoration in the level editor, that entity becomes accessible at runtime through Elements.tagged. Tags let you avoid hard-coded coordinate lookups and write scripts that stay correct even when you rearrange the level geometry.

Variables

Elements.tagged

A TaggedElementsTable — a special Lua table where each key is a tag string and the value is either a single entity object or an array of entity objects, depending on how many entities share that tag.
  • Type: TaggedElementsTable (behaves as table<string, any>)
  • Read-only: Yes

TaggedElementsTable

A TaggedElementsTable maps tag strings to the entities that carry them. The lookup result depends on how many entities share the same tag:
  • Exactly one entity — the value is that entity object directly.
  • Multiple entities — the value is a Lua array (table) of entity objects.
  • No entity — the value is nil.
You never construct a TaggedElementsTable yourself; you always access it via Elements.tagged.
Tag names are case-sensitive. A tag of "door" and a tag of "Door" are two different keys.

Usage Examples

Looking up a single entity

Looking up multiple entities with the same tag

Reacting to an event and toggling tagged elements

Sending a signal to tagged entities

You can combine Elements.tagged with the Signals namespace to communicate without a direct method call:
When you need to broadcast to all entities sharing a tag, prefer Signals.emitToTag(signalId, tag) — it handles the single vs. multiple entity distinction automatically.