Sign in to follow this  

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

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)[i], 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this