Index: trunk/src/lua/lua_raw.cc
===================================================================
--- trunk/src/lua/lua_raw.cc	(revision 161)
+++ trunk/src/lua/lua_raw.cc	(revision 162)
@@ -188,2 +188,62 @@
 	lua_pop( L, 1 );
 }
+
+void nlua_toflags( lua_State *L, int index, nv::uint8* data, nv::uint32 count )
+{
+	index = lua_absindex( L, index );
+	nv::uint32 flag;
+	if ( lua_istable( L, index ) )
+	{
+		lua_pushnil( L );
+		while ( lua_next( L, index ) != 0 )
+		{
+			if ( lua_type( L, -1 ) == LUA_TBOOLEAN )
+				flag = static_cast< nv::uint32 >( lua_tointeger( L ,-2 ) );
+			else
+				flag = static_cast< nv::uint32 >( lua_tointeger( L ,-1 ) );
+			lua_pop( L, 1 );
+			if ( flag < count )
+			{
+				data[ flag / 8 ] |= ( 1 << static_cast< nv::uint8 >( flag % 8 ) );
+			}
+		}
+	}
+}
+
+void nlua_toflags_set( lua_State *L, int index, nv::uint8* data, nv::uint32 count )
+{
+	index = lua_absindex( L, index );
+	nv::uint32 flag;
+	if ( lua_istable( L, index ) )
+	{
+		lua_pushnil( L );
+		while ( lua_next( L, index ) != 0 )
+		{
+			flag = static_cast< nv::uint32 >( lua_tointeger( L ,-2 ) );
+			lua_pop( L, 1 );
+			if ( flag < count )
+			{
+				data[ flag / 8 ] |= ( 1 << static_cast< nv::uint8 >( flag % 8 ) );
+			}
+		}
+	}
+}
+
+void nlua_toflags_array( lua_State *L, int index, nv::uint8* data, nv::uint32 count )
+{
+	index = lua_absindex( L, index );
+	nv::uint32 flag;
+	if ( lua_istable( L, index ) )
+	{
+		lua_pushnil( L );
+		while ( lua_next( L, index ) != 0 )
+		{
+			flag = static_cast< nv::uint32 >( lua_tointeger( L ,-1 ) );
+			lua_pop( L, 1 );
+			if ( flag < count )
+			{
+				data[ flag / 8 ] |= ( 1 << static_cast< nv::uint8 >( flag % 8 ) );
+			}
+		}
+	}
+}
Index: trunk/src/lua/lua_state.cc
===================================================================
--- trunk/src/lua/lua_state.cc	(revision 161)
+++ trunk/src/lua/lua_state.cc	(revision 162)
@@ -279,4 +279,17 @@
 }
 
+void lua::table_guard::get_raw_flags( const std::string& element, uint8* data, uint32 count )
+{
+	lua_getfield( L->L, -1, element.c_str() );
+	if ( lua_type( L->L, -1 ) != LUA_TTABLE )
+	{
+		lua_pop( L->L, 1 );
+		return;
+	}
+	nlua_toflags( L->L, -1, data, count );
+	lua_pop( L->L, 1 );
+}
+
+
 void lua::state::log_stack()
 {
