I’m always trying to learn better practices and get better at programming, but this is something I’m not quite sure on how it should be done
I want to be able to equip/unequip pets efficiently
I know a couple of ways to do it
Method #1
you have loop through this to get equipped pets (which isn’t fun)
data = {["Pet32"] = {equipped = false}, ["Pet74"] = {equipped = true}}
Method #2
this allows you to have a table of all equipped pets, so you don’t have to loop and check if it’s equipped, but I’m not sure how reliable this would be with saving data because they wouldn’t be the same tables after setting/getting data
data = {["Pet2"] = {damage= 12}, ["Pet74"] = {damage= 55}}
equippedPets = {}
table.insert(equippedPets , data["Pet2"])
Method #3
my final idea is similar to the one above, but I don’t use the table value I just use the key which is what I think is the best method out of these 3
data = {["Pet32"] = {damage= 12}, ["Pet74"] = {damage= 55}}
equippedPets = {"Pet32"}
anyone got a better method, or an improvement to one I listed?
Edit