How can I delete all tags via scripts. I’ve tried this
for i,tag in ipairs(sprite.tags) do
sprite:deleteTag(tag)
end
but it only deletes the first tag. I assume that is due to tags being deleted while looping. Is there a easy way to do this? Feels like I’m missing the obvious.
What I do is loop in reverse, from the end of the array to the start.
-- or app.sprite in v 1.3
local activeSprite <const> = app.activeSprite
if not activeSprite then return end
app.transaction(function()
local tags <const> = activeSprite.tags
local lenTags <const> = #tags
local i = lenTags + 1
while i > 1 do
i = i - 1
local tag <const> = tags[i]
activeSprite:deleteTag(tag)
end
end)
Ah… of course! Thanks.
for i = #sprite.tags,1,-1 do
sprite:deleteTag(sprite.tags[i])
end