View Single Post
Old 10-13-2016, 07:32 AM   #1
Human being with feelings
DarkStar's Avatar
Join Date: May 2006
Location: Surrey, UK
Posts: 18,343
Default Q: lua: Accessing partially-populated tables?

Next question.

Let's say that I have a table in lua with these entries:
xx[11], xx[12], xx.[13],
xx[21], xx[22], xx[23], xx[24],
xx[51], xx[52], 
xx[81], xx[82], xx[83], xx[84], xx[85]
You could think of the first digit in the index as the track number and the second as the clip number (assuming <10 clips per track).

What is the best way to access each of the clips for a particular track?

Perhaps start with the track number *10 +1 (e.g 51), then use 'ipairs' which will stop at the first nil value? (With a check that I do not stray into the entries for the next track.)

Or is there a better way?
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote