aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_object.cpp33
-rw-r--r--src/script/lua_api/l_object.h5
2 files changed, 36 insertions, 2 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index e801ddd5f..8f2bde036 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -406,7 +406,7 @@ int ObjectRef::l_set_animation(lua_State *L)
return 0;
}
-// set_local_animation(self, {stand/ilde}, {walk}, {dig}, {walk+dig}, frame_speed)
+// set_local_animation(self, {stand/idle}, {walk}, {dig}, {walk+dig}, frame_speed)
int ObjectRef::l_set_local_animation(lua_State *L)
{
//NO_MAP_LOCK_REQUIRED;
@@ -431,6 +431,36 @@ int ObjectRef::l_set_local_animation(lua_State *L)
return 0;
}
+// set_eye_offset(self, v3f first pv, v3f third pv)
+int ObjectRef::l_set_eye_offset(lua_State *L)
+{
+ //NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkobject(L, 1);
+ Player *player = getplayer(ref);
+ if (player == NULL)
+ return 0;
+ // Do it
+ v3f offset_first = v3f(0, 0, 0);
+ v3f offset_third = v3f(0, 0, 0);
+
+ if(!lua_isnil(L, 2))
+ offset_first = read_v3f(L, 2);
+ if(!lua_isnil(L, 3))
+ offset_third = read_v3f(L, 3);
+
+ // Prevent abuse of offset values (keep player always visible)
+ offset_third.X = rangelim(offset_third.X,-10,10);
+ offset_third.Z = rangelim(offset_third.Z,-5,5);
+ /* TODO: if possible: improve the camera colision detetion to allow Y <= -1.5) */
+ offset_third.Y = rangelim(offset_third.Y,-10,15); //1.5*BS
+
+ if (!getServer(L)->setPlayerEyeOffset(player, offset_first, offset_third))
+ return 0;
+
+ lua_pushboolean(L, true);
+ return 0;
+}
+
// set_bone_position(self, std::string bone, v3f position, v3f rotation)
int ObjectRef::l_set_bone_position(lua_State *L)
{
@@ -1296,5 +1326,6 @@ const luaL_reg ObjectRef::methods[] = {
luamethod(ObjectRef, set_sky),
luamethod(ObjectRef, override_day_night_ratio),
luamethod(ObjectRef, set_local_animation),
+ luamethod(ObjectRef, set_eye_offset),
{0,0}
};
diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h
index be1068c14..f6070585d 100644
--- a/src/script/lua_api/l_object.h
+++ b/src/script/lua_api/l_object.h
@@ -231,9 +231,12 @@ private:
// override_day_night_ratio(self, type, list)
static int l_override_day_night_ratio(lua_State *L);
- // set_local_animation(self, {stand/ilde}, {walk}, {dig}, {walk+dig}, frame_speed)
+ // set_local_animation(self, {stand/idle}, {walk}, {dig}, {walk+dig}, frame_speed)
static int l_set_local_animation(lua_State *L);
+ // set_eye_offset(self, v3f first pv, v3f third pv)
+ static int l_set_eye_offset(lua_State *L);
+
public:
ObjectRef(ServerActiveObject *object);