Jump to content
  • Advertisement
Sign in to follow this  
CodaKiller

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

This topic is 3381 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 )
{
	lua_newtable(L);
	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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!