Passing C++ Objects To Lua

Hey everybody !
I recently took a look at Lua and C++ and I thought how can I pass structs from C++ to Lua . Do you simply put everything in the struct in a table and pass it ?
For example :
1
2
3
4
5
struct Human
{
int height, weight, age ;
std::string name ;
} ;


Would you put it all together in a table and send it to Lua or is there a better way ?
If it's only one way and the structs are simple then serializing to a lua table should be a relatively painless approach. If you want two way communication, or have complicated structs, then you need to look into full userdata and the index metamethod.

There are numerous libraries to do this though, I've only tried LuaBridge which seemed good, but my requirements were a bit too much for it, and I ended up developing my own system.

See if you can get a copy of the Programming in Lua book, which has a couple of chapters on C/C++ Integration.
Thanks a lot ! I really appreciate your help ! ^_^ I'll grab a copy of it as soon as I'll be able to .
Topic archived. No new replies allowed.