lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Agi Shi wrote:
I see.  However, the only iteration I'm doing in Lua is this:

    local function buttons(table)
        local pos = vec2(0, 0)
        for key, val in pairs(table) do
            for key2, val2 in pairs(val) do
                val2.position = vec2(pos.x, pos.y)
                pos.x = pos.x + val2.size.x
        return table

I'm not modifying the table itself, only the values of the table.  And
I've now realized that naming the table 'table' is a bad idea, so I've
changed it (but the same issue occurs).

Is there a possibility that val2.position does not exist when you assign to it ? That would be an insert, which will break pairs(). I notice that eg debugWin has no initial position.