get_tag
Lookup for the given tag name in the entity tags map and returns it if its
present, if its not present nil will be returned instead.
Arguments
- name - The name of the tag to lookup and retrieve
Signature
---@param name string @Name of the tag to lookup
---@return Tag|nil
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" },
}
})
local tag = entity:get_tag("humanoid")
assert(tag ~= nil)
assert(tag.name == "humanoid")
assert(tag.value.Value == "minotaur")
assert(entity:get_tag("undefined") == nil)