// remove(self) int ObjectRef::l_remove(lua_State *L) { GET_ENV_PTR; ObjectRef *ref = checkobject(L, 1); ServerActiveObject *co = getobject(ref); if (co == NULL) return 0; if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER) return 0; std::set<int> child_ids = co->getAttachmentChildIds(); std::set<int>::iterator it; for (it = child_ids.begin(); it != child_ids.end(); ++it) { ServerActiveObject *child = env->getActiveObject(*it); if (child) child->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0)); } /* verbosestream<<"ObjectRef::l_remove(): id="<<co->getId()<<std::endl; */ co->m_removed = true; return 0; }
// remove(self) int ObjectRef::l_remove(lua_State *L) { GET_ENV_PTR; ObjectRef *ref = checkobject(L, 1); ServerActiveObject *co = getobject(ref); if (co == NULL) return 0; if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER) return 0; const UNORDERED_SET<int> &child_ids = co->getAttachmentChildIds(); UNORDERED_SET<int>::const_iterator it; for (it = child_ids.begin(); it != child_ids.end(); ++it) { // Child can be NULL if it was deleted earlier if (ServerActiveObject *child = env->getActiveObject(*it)) child->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0)); } verbosestream<<"ObjectRef::l_remove(): id="<<co->getId()<<std::endl; co->m_removed = true; return 0; }