• Advertisement
Sign in to follow this  

Passing a struct as a table to LUA function

This topic is 3323 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

Hallo, Does anyone know how to pass a struct from c/c++ to a lua script as an argument for a function? I know how to pass a single number, but I am unsure about how to pass a table (I asume that is what I need to pass)? I have been googleing and reading for a while now and could really need a pointer in the right direction. Regards,

Share this post


Link to post
Share on other sites
Advertisement
You have to create a table on the lua stack and then fill it with the data as required.

iirc the function is "lua_newtable()" or something like that, check the reference at lua.org for more details.

Share this post


Link to post
Share on other sites
Keep in mind that, since C++ lacks reflection, you'll have to explicitely specify every single member that should go into the table.
A nice template function and/or macro might help with it, though [smile]

Share this post


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

  • Advertisement