Index: trunk/src/lua/lua_state.cc
===================================================================
--- trunk/src/lua/lua_state.cc	(revision 185)
+++ trunk/src/lua/lua_state.cc	(revision 187)
@@ -303,19 +303,25 @@
 }
 
+lua::reference lua::state::register_object( object * o, const char* lua_name )
+{
+	if ( o == nullptr ) return ref_none;
+	stack_guard guard( this );
+	lua_getglobal( L, lua_name );
+	if ( lua_isnil( L, -1 ) )
+	{
+		NV_THROW( runtime_error, std::string( lua_name ) + " type not registered!" );
+	}
+	deep_pointer_copy( -1, o );
+	return luaL_ref( L, LUA_REGISTRYINDEX );
+}
+
 lua::reference lua::state::register_object( object * o )
 {
-	if (!o) return ref_none;
+	if ( o == nullptr ) return ref_none;
 	type_database *db = o->get_root()->get_type_database();
-	if (!db) return ref_none;
-	type_entry* t = db->get_type(typeid(o));
-	if (!t) return ref_none;
-	stack_guard guard( this );
-	lua_getglobal( L, t->name.c_str() );
-	if ( lua_isnil( L, -1 ) )
-	{
-		NV_THROW( runtime_error, std::string( t->name ) + " type not registered!" );
-	}
-	deep_pointer_copy( -1, o );
-    return luaL_ref( L, LUA_REGISTRYINDEX );
+	if ( db == nullptr ) return ref_none;
+	type_entry* t = db->get_type(typeid(*o));
+	if ( t == nullptr ) return ref_none;
+	return register_object( o, t->name.c_str() );
 }
 
@@ -403,5 +409,4 @@
 	if ( !p.resolve( L, global ) )
 	{
-		lua_pop( L, 1 );
 		NV_LOG( LOG_ERROR, "Lua error : not a valid path - " + p.to_string() );
 		return false;
@@ -416,2 +421,3 @@
 	return true;
 }
+
Index: trunk/src/object.cc
===================================================================
--- trunk/src/object.cc	(revision 185)
+++ trunk/src/object.cc	(revision 187)
@@ -16,22 +16,17 @@
 
 object::object()
-	: m_root( nullptr ), m_id(), m_name(), m_uid(0), m_lua_index(-2), m_parent( nullptr ), m_children(), m_child_count(0)
+	: m_root( nullptr ), m_id(), m_name(), m_uid(0), m_lua_index(lua::ref_none), m_parent( nullptr ), m_children(), m_child_count(0)
 {
 }
 
 object::object( root* aroot, const string& aid )
-	: m_root( aroot ), m_id(aid), m_name(), m_uid( 0 ), m_lua_index(-2), m_parent( nullptr ), m_children(), m_child_count(0)
+	: m_root( aroot ), m_id(aid), m_name(), m_uid( 0 ), m_lua_index(lua::ref_none), m_parent( nullptr ), m_children(), m_child_count(0)
 {
 	if ( m_root )
 	{
 		uid_store*  store = get_root()->get_uid_store();
-		lua::state* state = get_root()->get_lua_state();
 		if (store)
 		{
 			m_uid = store->insert( this );
-		}
-		if (state)
-		{
-			m_lua_index = state->register_object( this );
 		}
 	}
@@ -195,2 +190,18 @@
 	db->create_type<object>("object").fields(fields);
 }
+
+void nv::object::register_with_lua( const char* lua_name /*= nullptr*/ )
+{
+	lua::state* state = get_root()->get_lua_state();
+	if (state)
+	{
+		if ( lua_name != nullptr )
+		{
+			m_lua_index = state->register_object( this, lua_name );
+		}
+		else
+		{
+			m_lua_index = state->register_object( this );
+		}
+	}
+}
