get_tags
Lookup for the given tag names in the entity tags map and returns them if they present, if they not present they will be skip. If none of the given tags are found in the entity, an empty table will be returned.
Arguments
- names - The names of the tags to lookup and retrieve as an array table
Signature
---@param names []string @Array of names of the tags to lookup
---@return []Tag
function Entity:get_tag(name)
Example of Usage
-- bind the exposed entity UserData to a local variable
local entityAPI = alacrity.Entity
-- create a new random unique user ID
local id = alacrity.uuid.new_v4()
-- create a new Entity instance
local e = entityAPI.new({
id = id,
name = "My new Ad-Hoc entity",
description = "This is an Ad-Hoc example test entity",
attributes = {},
tags = {
{ name = "humanoid", value = "minotaur" },
{ name = "house", value = "atreides" },
}
})
local tags = entity:get_tags({"humanoid", "house"})
assert(tags ~= nil)
assert(tags[1].name == "humanoid")
assert(tags[1].value.Value == "minotaur")
assert(tags[2].name == "house")
assert(tags[2].value.Value == "atreides")
assert(entity:get_tags("undefined") == nil)