Lua multitagging
-
Tag groups are exposed by calling
sectors.tagged()
,lines.tagged()
ormapthings.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 thevalid
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)
orhas(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)
andremove(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. Usetags.iterate
to iterate over these tags. You may also take the length oftags
, 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.