Jump to content
  • Advertisement
Sign in to follow this  

I'm making a lua push table function and I require assistance.

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

Well I need to push a table on to the lua stack but I'm unsure how to do this, the function I'm trying to make takes the address of an array, the number of bytes per element in the array and the size of the array. It then creates a table from the c++ array but I can't get it to work right, any ideas would be most appreciated. Here is what I have so far:
void lua_pushtable( lua_State *L, void* data, int stride, int size )
	for( int i = 0; i < size; i = i + stride )
		double value = NULL;
		memcpy( &value, &((byte*)data), stride );
		lua_pushnumber( L, i );
		lua_pushnumber( L, value );
		lua_settable( L, -3 );
	lua_pop( L, 1 );

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!