Index: trunk/nv/common.hh
===================================================================
--- trunk/nv/common.hh	(revision 55)
+++ trunk/nv/common.hh	(revision 56)
@@ -120,32 +120,33 @@
 namespace nv
 {
+	class object;
 
-  // Typedefs for fixed size types.
-  typedef signed char         sint8;
-  typedef signed short        sint16;
-  typedef signed long         sint32;
+	// Typedefs for fixed size types.
+	typedef signed char         sint8;
+	typedef signed short        sint16;
+	typedef signed long         sint32;
 #if NV_COMPILER == NV_MSVC
-  typedef signed __int64      sint64;
+	typedef signed __int64      sint64;
 #else
-  typedef signed long long    sint64;
+	typedef signed long long    sint64;
 #endif
 
-  typedef unsigned char       uint8;
-  typedef unsigned short      uint16;
-  typedef unsigned long       uint32;
+	typedef unsigned char       uint8;
+	typedef unsigned short      uint16;
+	typedef unsigned long       uint32;
 #if NV_COMPILER == NV_MSVC
-  typedef unsigned __int64    uint64;
+	typedef unsigned __int64    uint64;
 #else
-  typedef unsigned long long  uint64;
+	typedef unsigned long long  uint64;
 #endif
 
-  typedef unsigned char       char8;
-  typedef unsigned short      char16;
-  typedef unsigned long       char32;
+	typedef unsigned char       char8;
+	typedef unsigned short      char16;
+	typedef unsigned long       char32;
 
-  typedef float  f32;
-  typedef double f64;
+	typedef float  f32;
+	typedef double f64;
 
-  typedef uint64 uid;
+	typedef uint64 uid;
 
 } // namespace nv
Index: trunk/nv/lua/lua_aux.hh
===================================================================
--- trunk/nv/lua/lua_aux.hh	(revision 56)
+++ trunk/nv/lua/lua_aux.hh	(revision 56)
@@ -0,0 +1,13 @@
+// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+#ifndef NV_LUA_AUX_HH
+#define NV_LUA_AUX_HH
+
+#include <nv/lua/lua_raw.hh>
+
+void nlua_register_aux( lua_State* L );
+
+#endif // NV_LUA_AUX_HH
Index: trunk/src/lua/lua_aux.cc
===================================================================
--- trunk/src/lua/lua_aux.cc	(revision 56)
+++ trunk/src/lua/lua_aux.cc	(revision 56)
@@ -0,0 +1,140 @@
+// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+#include "nv/lua/lua_aux.hh"
+
+static int nlua_table_copy( lua_State* L )
+{
+	luaL_checktype( L, 1, LUA_TTABLE );
+	lua_settop( L, 1 );
+	lua_newtable(L);
+	lua_pushnil(L);
+	while ( lua_next( L, 1 ) != 0 )
+	{
+		lua_pushvalue(L, -2);
+		lua_insert(L, -2);
+		lua_settable(L, -4);
+	}
+	return 1;
+}
+
+static int nlua_table_icopy( lua_State* L )
+{
+	luaL_checktype( L, 1, LUA_TTABLE );
+	lua_settop( L, 1 );
+	lua_newtable(L);
+	int i = 0;
+	for(;;) 
+	{
+		i++;
+		lua_rawgeti(L, 1, i);
+		if ( lua_isnil( L, -1 ) ) 
+		{
+			lua_pop( L, 1 );
+			break;
+		}
+		lua_rawseti(L, 2, i);
+	};
+	return 1;
+}
+
+static int nlua_table_merge( lua_State* L )
+{
+	luaL_checktype( L, 1, LUA_TTABLE );
+	luaL_checktype( L, 2, LUA_TTABLE );
+	lua_settop( L, 2 );
+	lua_pushnil(L);
+	while ( lua_next( L, 2 ) != 0 )
+	{
+		lua_pushvalue(L, -2);
+		lua_insert(L, -2);
+		lua_settable(L, 1);
+	}
+	return 0;
+}
+
+static int nlua_table_imerge( lua_State* L )
+{
+	luaL_checktype( L, 1, LUA_TTABLE );
+	luaL_checktype( L, 2, LUA_TTABLE );
+	lua_settop( L, 2 );
+	int i = 0;
+	for(;;) 
+	{
+		i++;
+		lua_rawgeti(L, 2, i);
+		if ( lua_isnil( L, -1 ) ) 
+		{
+			lua_pop( L, 1 );
+			break;
+		}
+		lua_rawseti(L, 1, i);
+	};
+	return 0;
+}
+
+static int nlua_table_reversed( lua_State* L )
+{
+	luaL_checktype( L, 1, LUA_TTABLE );
+	lua_settop( L, 1 );
+	int len = lua_rawlen(L,1);
+	int i   = len;
+	lua_createtable(L,len,0);
+	while ( i != 0 )
+	{
+		lua_rawgeti(L, 1, i);
+		lua_rawseti(L, 2, len-i+1);
+		i--;
+	}
+	return 1;
+}
+
+static int nlua_table_toset( lua_State* L )
+{
+	luaL_checktype( L, 1, LUA_TTABLE );
+	lua_settop( L, 1 );
+	lua_newtable(L);
+	int i = 0;
+	for(;;) 
+	{
+		i++;
+		lua_rawgeti(L, 1, i);
+		if ( lua_isnil( L, -1 ) ) 
+		{
+			lua_pop( L, 1 );
+			break;
+		}
+		lua_pushboolean( L, true );
+		lua_rawset(L, 2);
+	};
+	return 1;
+}
+
+static const struct luaL_Reg nlua_table_aux_f [] = {
+	{ "copy",      nlua_table_copy },
+	{ "icopy",     nlua_table_icopy },
+	{ "merge",     nlua_table_merge },
+	{ "imerge",    nlua_table_imerge },
+	{ "reversed",  nlua_table_reversed },
+	{ "toset",     nlua_table_toset },
+	{ NULL, NULL }
+};
+
+static const struct luaL_Reg nlua_math_aux_f [] = {
+	{ NULL, NULL }
+};
+
+void nlua_register_aux( lua_State* L )
+{
+	lua_getglobal( L, "table" );
+	luaL_setfuncs( L, nlua_table_aux_f, 0 );
+	lua_pop( L, 1 );
+
+	lua_getglobal( L, "math" );
+	luaL_setfuncs( L, nlua_math_aux_f, 0 );
+	lua_pop( L, 1 );
+}
+
