[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: invalid key to 'next'
- From: Matthew Wild <mwild1@...>
- Date: Sun, 24 May 2009 16:37:25 +0100
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.