#Taking cards by tag

1 messages · Page 1 of 1 (latest)

rough atlas
#

My next idea is to define zones for each deck to end up, then just move each card to that zone--but that feels a little goofy? I don't know, maybe that is what's best 🙃

scenic quail
#
local tagToMatch = "Some Tag"
local deckInfo = deck.getObjects() -- remember that objects in containers are not Objects
for i = #deckInfo,1,-1 do -- iterate backwards
  local cardInfo = deckInfo[i]
  for _,tag in ipairs(cardInfo.tags) do
    if tag == tagToMatch then -- remove the card
      local removedCard = deck.takeObject({
        index = cardInfo.index
      })
      removedCard.highlightOn("Green", 5) -- do something with the removed card, for example
    end
  end
end
#

that's basically it

#

as for the thread title, you're not really "sorting" by tag but "taking" by tag, a sort would be re-ordering the cards in the existing deck

rough atlas
#

Taking cards by tag

scenic quail
#

and also removing by index, not guid

#

guids don't mean anything in a container (because they're not Objects), and you could have duplicates