Re: invalid key to 'next'

Agi Shi <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
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).

On Sat, May 23, 2009 at 9:46 PM, James Porter <[email protected]> wrote:
> Agi Shi wrote:
>> This is my lua code: http://lua.pastebin.com/f7b33bcca
>>
>> It's in a function called createGUI().  I've omitted the function itself
>> and a few unneeded lines.  I call this function from C++ as such
>
> Well, that's probably where the error is occurring. "invalid key to
> 'next'" usually occurs if you are iterating over your table and you
> modify it during iteration.
>
> - Jim
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.