Jump to content
  • Advertisement
Sign in to follow this  
CodaKiller

How to return a table form a luabind function?

This topic is 3494 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know how to read tables from a luabind object but how do I return a table from a function? [Edited by - CodaKiller on May 20, 2009 12:15:22 PM]

Share this post


Link to post
Share on other sites
Advertisement
I've been looking really hard to find the answer and there is almost no information on this.

This is exactly what I'm trying to do, I have a scene desc class that simply needs to return the gravity from a cml vector in the class but in the script I'm not using a class for vectors, I'm using tables since it makes the code simpler.

Here is the source for the class:


class E_SCENE_DESC
{
public:

void set_gravity(luabind::object vec)
{
gravity = cml::vector3f( luabind::object_cast<float>(vec[1]), luabind::object_cast<float>(vec[2]), luabind::object_cast<float>(vec[3]) );
}

luabind::object get_gravity() const
{
return ??; // How do I return the gravity as a table?!
}

cml::vector3f gravity;
};

Share this post


Link to post
Share on other sites
luabind::object table = luabind::newtable( luaState );

table[1] = luabind::object();

return table;


[Edited by - Neverender on May 20, 2009 7:50:57 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Neverender
*** Source Snippet Removed ***


It worked thank you, I would have never thought I could just create a table and set the values without setting the size of the table.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!