remove_tags

Removes the given tags from the entity if they are present.

Arguments

  • tags - A table of [Tag] instances or literal definitions to be removed from the entity.

Signature

---@param tags []string|[]Tag|[]string|Tag @Table containing the tags to be removed
function Entity:remove_tags(tags)

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 = "Ad-Hoc Test Entity", 
    description = "Ad-Hoc entity for testing",
    attributes = {},
    tags = {
        { name = "humanoid", value = "minotaur" },
        { name = "house", value = "atreides" },
    }
})

local ok, err = pcall(function()
    entity:remove_tags({
        "humanoid",
    })
end)
assert(ok and err == nil)

local humanoid_tag = entity:get_tag("humanoid")
assert(humanoid_tag == nil)

local ok, err = pcall(function()
    entity:remove_tags({
        { name = "house", value = "atreides" },
    })
end)
assert(ok and err == nil)

local house_tag = entity:get_tag("house")
assert(house_tag == nil)