aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2018-04-30 18:43:49 +0200
committerGitHub <noreply@github.com>2018-04-30 18:43:49 +0200
commitba91624d8c354bac49c35a449029b6712022d0cb (patch)
tree8a6423ab354888691927f852754f86816f9c90c5 /src/script/lua_api
parent0b5b32b026291d5bd8e47acebca10259a379fc1c (diff)
downloadminetest-ba91624d8c354bac49c35a449029b6712022d0cb.tar.gz
minetest-ba91624d8c354bac49c35a449029b6712022d0cb.tar.bz2
minetest-ba91624d8c354bac49c35a449029b6712022d0cb.zip
Allow damage for attached objects, add attach/detach callbacks (#6786)
* Allow right-clicking on attached LuaEntities
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_object.cpp24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index 0bef23541..b3c3a55bf 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -103,12 +103,8 @@ int ObjectRef::l_remove(lua_State *L)
if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
return 0;
- const std::unordered_set<int> &child_ids = co->getAttachmentChildIds();
- for (int child_id : child_ids) {
- // Child can be NULL if it was deleted earlier
- if (ServerActiveObject *child = env->getActiveObject(child_id))
- child->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0));
- }
+ co->clearChildAttachments();
+ co->clearParentAttachment();
verbosestream << "ObjectRef::l_remove(): id=" << co->getId() << std::endl;
co->m_pending_removal = true;
@@ -721,21 +717,7 @@ int ObjectRef::l_set_detach(lua_State *L)
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());
+ co->clearParentAttachment();
return 0;
}