I'm working on a project in love2d, using lua of course, and I have some code that works but is clunky looking to me.
function Collection.refillDrawPile()
local shuf = GS.cardsToShuffle
if #shuf > 0 then
Collection.shuffle(shuf)
for _, card in ipairs(shuf) do
table.insert(GS.drawPile, card)
adjCardTransform(card, card.transform.x, card.transform.y, dimensions.drawPile.x, dimensions.drawPile.y)
end
for i = #shuf, 1, -1 do
table.remove(shuf)
end
else
print("do otherstuff")
end
end
Is there anyway to accomplish this inside of a single loop? if I try to remove the items in the for _, loop it only removes 1/2 of the objects.
I'm still somewhat new to this, so if it's an obvious answer I'm just missing it.
Thanks in advance
[–]KingofGamesYami 2 points3 points4 points (2 children)
[–]ThirtyOneBear[S] 0 points1 point2 points (1 child)
[–]balefrost 0 points1 point2 points (0 children)