1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add First Person Attachments (#10360)

Fixes some other third person camera specific attachments.
Implements a single new flag for entities to be forced visible in first person mode.
Old mods do not need to be updated to use the new flag and are fully backwards compatible.
This commit is contained in:
Jordan Snelling 2020-10-04 14:10:34 +01:00 committed by GitHub
parent 0f98b54aa4
commit 3068853e8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 101 additions and 35 deletions

View file

@ -664,7 +664,7 @@ int ObjectRef::l_get_bone_position(lua_State *L)
return 2;
}
// set_attach(self, parent, bone, position, rotation)
// set_attach(self, parent, bone, position, rotation, force_visible)
int ObjectRef::l_set_attach(lua_State *L)
{
GET_ENV_PTR;
@ -687,7 +687,8 @@ int ObjectRef::l_set_attach(lua_State *L)
std::string bone;
v3f position = v3f(0, 0, 0);
v3f rotation = v3f(0, 0, 0);
co->getAttachment(&parent_id, &bone, &position, &rotation);
bool force_visible;
co->getAttachment(&parent_id, &bone, &position, &rotation, &force_visible);
if (parent_id) {
ServerActiveObject *old_parent = env->getActiveObject(parent_id);
old_parent->removeAttachmentChild(co->getId());
@ -702,7 +703,8 @@ int ObjectRef::l_set_attach(lua_State *L)
rotation = v3f(0, 0, 0);
if (!lua_isnil(L, 5))
rotation = read_v3f(L, 5);
co->setAttachment(parent->getId(), bone, position, rotation);
force_visible = readParam<bool>(L, 6, false);
co->setAttachment(parent->getId(), bone, position, rotation, force_visible);
parent->addAttachmentChild(co->getId());
return 0;
}
@ -722,7 +724,8 @@ int ObjectRef::l_get_attach(lua_State *L)
std::string bone;
v3f position = v3f(0, 0, 0);
v3f rotation = v3f(0, 0, 0);
co->getAttachment(&parent_id, &bone, &position, &rotation);
bool force_visible;
co->getAttachment(&parent_id, &bone, &position, &rotation, &force_visible);
if (!parent_id)
return 0;
ServerActiveObject *parent = env->getActiveObject(parent_id);
@ -731,7 +734,8 @@ int ObjectRef::l_get_attach(lua_State *L)
lua_pushlstring(L, bone.c_str(), bone.size());
push_v3f(L, position);
push_v3f(L, rotation);
return 4;
lua_pushboolean(L, force_visible);
return 5;
}
// set_detach(self)