Skip to content

Lua multitagging

James R. requested to merge lua-tag-iterator into next
  • Tag groups are exposed by calling sectors.tagged(), lines.tagged() or mapthings.tagged(). Each function accepts a single parameter, which is the tag. For instance to fetch the sector tag group for tag 1... sectors.tagged(1)

    Tag groups may be indexed (1-indexed) or called. You can also take the length of them, which tells the number of elements in the tag group. When a tag group is called it acts as an iterator. E.g. for sector in sectors.tagged(1)

  • Tag lists are exposed from the taglist field of sectors, lines and mapthings. A tag list may be indexed (1-indexed), and the length be taken to tell the number of tags in the tag list. Since tag lists represent a map data structure, they will become invalid at the start of a new level. Therefore you should check the valid field if you store the tag list.

    Tag lists also inherit methods from the global taglist table:

    • iterate(list) - returns an iterator over the tags in the tag list
    • find(list, tag) or has(list, tag) - returns a boolean of whether the tag exists in the list
    • shares(list, another_list) - returns a boolean of whether two lists share at least one tag

    add(list, tag) and remove(list, tag) are also available for sector tag lists.

    You may compare tag lists with an equality operator (==/~=) to tell if two tag lists are composed of identical tags.

  • Another global tags is added to tell which tags are set in the level. This counts across sectors, lines and mapthings. Use tags.iterate to iterate over these tags. You may also take the length of tags, which will tell you how many unique tags are in use.


In addition to the Lua FEATURES, I've also fixed a bug where changing a sector's tag would shrink its original tag group incorrectly, leading to garbage elements at the end of the tag group.

Edited by James R.

Merge request reports

Loading