コード例 #1
0
ファイル: l_object.cpp プロジェクト: theDrake/minetest
// set_detach(self)
int ObjectRef::l_set_detach(lua_State *L)
{
	GET_ENV_PTR;

	ObjectRef *ref = checkobject(L, 1);
	ServerActiveObject *co = getobject(ref);
	if (co == NULL)
		return 0;

	int parent_id = 0;
	std::string bone = "";
	v3f position;
	v3f rotation;
	co->getAttachment(&parent_id, &bone, &position, &rotation);
	ServerActiveObject *parent = NULL;
	if (parent_id) {
		parent = env->getActiveObject(parent_id);
		co->setAttachment(0, "", position, rotation);
	} else {
		co->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0));
	}
	// Do it
	if (parent != NULL)
		parent->removeAttachmentChild(co->getId());
	return 0;
}
コード例 #2
0
void UnitSAO::clearParentAttachment()
{
	ServerActiveObject *parent = nullptr;
	if (m_attachment_parent_id) {
		parent = m_env->getActiveObject(m_attachment_parent_id);
		setAttachment(0, "", m_attachment_position, m_attachment_rotation);
	} else {
		setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0));
	}
	// Do it
	if (parent)
		parent->removeAttachmentChild(m_id);
}