invalid key to 'next'

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

invalid key to 'next'

Agi Shi
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:

        try
        {
            luabind::call_function<void>(_lua, "createGUI", boost::ref((gui::widget&)*_sheet));
        }
        catch(const luabind::error &e)
        {
            engine::log(engine::string(e.what()) + " :: " + _lua.error());
        }

This results in:

lua runtime error :: invalid key to 'next'

This is under Lua 5.1.4 and Luabind 0.8.  The same code worked 100% correctly under Lua 5.0.x.  I cannot find what is wrong, any ideas?  Major thanks to anyone with ideas!

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: invalid key to 'next'

James Porter-2
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: invalid key to 'next'

Agi Shi
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 <[hidden email]> 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
> [hidden email]
> 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 
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user