Skip to main content
Every entity in a RollingQuest level — blocks, sides, items, enemies, balls, and decorations — can be given a tag in the level editor. Tags let your scripts look up specific entities by name at runtime, without hard-coded IDs or fragile index-based lookups. The Elements.tagged table is the single entry point for all tag-based entity access.

Setting Tags in the Level Editor

Open the properties panel for any entity in the editor and fill in its Tag field. Tags are free-form strings — choose names that describe the entity’s role in your level design (for example "exit-door", "spawn-trigger", or "collectible-key").
Multiple entities can share the same tag. When you look up a tag that more than one entity uses, Elements.tagged gives you a table of all matching entities instead of a single value.

The Elements.tagged Table

Elements.tagged is a read-only table indexed by tag strings. Each value is either:
  • A single entity — when only one entity in the level has that tag.
  • A table of entities — when multiple entities share that tag.
Because the game can return different value shapes, always check what you have before using it.

Getting a Single Entity by Tag

When you know exactly one entity carries a tag, index Elements.tagged directly:
The value you get back is a generic element. To call type-specific methods (like block:enable() or enemy:kill()), cast it first using one of the as*() methods available on every entity.

Cast Methods

Calling the wrong cast method throws a runtime error. Use entity.type to inspect the EntityType of an unknown element before casting if you are unsure.

Working with Multiple Entities Sharing a Tag

When several entities share a tag, Elements.tagged["my-tag"] returns a table. Iterate it with a numeric for loop:
A safe pattern is to always wrap the result in a table check, so your code handles both the single-entity and multi-entity cases gracefully.

Entity Types

The following entity types can all be found via Elements.tagged:

Practical Examples

Get a block and toggle it

Read a ball’s position on level start

Iterate all enemies with a shared tag

Collect all items tagged “bonus-coin”


Checking Whether a Tag Exists

Elements.tagged returns nil for tags that no entity in the level uses. Always guard lookups when the tag might not be present: