How do I get a number from a table entry? So far, I have it so it loops through the table but I was hoping there was an easier method that didn’t rely on a loop every time.
I want to retreive “Weight” from the enemies with “Name”, for example I want to be able to access the weight from:
{Name = “Power 1”, Weight = 1000, Tier = “Common”}
Table setup:
local Items = {
Common = {
["Weight"] = {Weight = 1000},
{Name = "Power 1", Weight = 1000, Tier = "Common"},
},
Standard = {
["Weight"] = {Weight = 600},
{Name = "Power 2", Weight = 600, Tier = "Standard"},
},
Rare = {
["Weight"] = {Weight = 50},
{Name = "Admin Power", Weight = 50, Tier = "Rare"},
},
LivingMyth = {
["Weight"] = {Weight = 10},
{Name = "Power 3", Weight = 10, Tier = "Living Myth"},
},
}
So far I used two pairs loops that would loop through the table and then loop through the results of that loop, picking out anything under “Weight” as weight will only ever have one number.