Question

i have a table that looks like this:

tbm = { -- facedir indexed (+1)
       { -- facedir = 0
           { -- first line
                { X = -1, Y =  2, Z =  1 },
                { X =  0, Y =  2, Z =  1 },
                { X =  1, Y =  2, Z =  1 }
            },
        { -- second line
            { X = -1, Y =  1, Z =  1 },
            { X =  0, Y =  1, Z =  1 },
            { X =  1, Y =  1, Z =  1 }
        },
        { -- third line
            { X = -1, Y =  0, Z =  1 },
            { X =  0, Y =  0, Z =  1 },
            { X =  1, Y =  0, Z =  1 }
        },
        { -- forth line
            { X = -1, Y = -1, Z =  1 },
            { X =  0, Y = -1, Z =  1 },
            { X =  1, Y = -1, Z =  1 }
        }
    }
}

ok what i want and i have googled the heck out of it is if i want to access the value contained in X and do a check if it is a certain value how would i just access it without recursing the whole dang thing? i mean the real table is more or less a little over 400KB to have to recurse it all the time will be a pain in the butt.

Was it helpful?

Solution

tbm[fi][line][ii].X

Where fi is facedir index (number 1 or greater, although there is only 1 in your example), line is index to desired line (number from 1 to 4 in your example), ii is index to one of three triplet tables within line and X is the desired key within triplet.

For ex tbm[1][2][3].X would be 1 taken from line that has Y=1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top