Elements of the table are not specified.
You will need to create a table that maps numerical indices to a specific subtable in sums
. You can even use the sums
table to store both your sub-stats and your order for them.
For instance:
-- create table with sum ids in a specific order sums = { "LD1", "LD2", "LD3", "LD4", "I1", "I2", "I3" } -- create subtables in sums for each id for i,id in ipairs(sums) do sums[id] = {} end -- stick some data in the sum tables for fld = 1, 22 do table.insert( sums["LD1"] , 0 ); table.insert( sums["LD2"] , 0 ); table.insert( sums["LD3"] , 0 ); table.insert( sums["LD4"] , 0 ); table.insert( sums["I1"] , 0 ); table.insert( sums["I2"] , 0 ); table.insert( sums["I3"] , 0 ); end -- show sum tables in order for i,id in ipairs(sums) do print(id, sums[id]) end
source share