lua-users home
lua-l archive

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


On Sun, May 24, 2009 at 1:40 PM, Adrian Sietsma
<adrian_groups@sietsma.com> wrote:
> 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
>>                --log(type(val2))
>>                val2.position = vec2(pos.x, pos.y)
>>                pos.x = pos.x + val2.size.x
>>            end
>>        end
>>        return table
>>    end
>>
>> 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.
>

Are you sure? Read again, it isn't val2 being iterated over.

After a first read through I can't see how that code could cause the
error. Is this the exact place pointed to by the error message?

Matthew.