Reputation: 653
How can I loop this array of tables?
TASK_CONFIG = {
[1] = {NAME = "1-a", COUNT = 10, REWARD = 1000},
[2] = {NAME = "4-b", COUNT = 10, REWARD = 6000},
[3] = {NAME = "3-a", COUNT = 15, REWARD = 2400},
}
I need something like:
for each ITEM in TASK_CONFIG
for each FIELD in ITEM
-- do something
next
next
The idea is looping every field, for example:
Looping every row and getting the values "name", "count", "reward"
Upvotes: 0
Views: 69
Reputation: 653
for a, b in pairs(TASK_CONFIG) do
for c, d in pairs(b) do
-- print info / do something
end
end
Upvotes: 2