Created
August 18, 2013 13:21
-
-
Save PilzAdam/6261635 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/doc/lua_api.txt b/doc/lua_api.txt | |
index bd465bb..4347b3a 100644 | |
--- a/doc/lua_api.txt | |
+++ b/doc/lua_api.txt | |
@@ -1863,7 +1863,8 @@ Object Properties | |
makes_footstep_sound = false, | |
automatic_rotate = false, | |
stepheight = 0, | |
- automatic_face_movement_dir = false, | |
+ automatic_face_movement_dir = 0.0, | |
+ ^ automatically set yaw to movement direction; offset in degrees | |
} | |
Entity definition (register_entity) | |
diff --git a/src/content_cao.cpp b/src/content_cao.cpp | |
index bb8dad0..180573c 100644 | |
--- a/src/content_cao.cpp | |
+++ b/src/content_cao.cpp | |
@@ -1212,7 +1212,7 @@ class GenericCAO : public ClientActiveObject | |
} | |
if (getParent() == NULL && m_prop.automatic_face_movement_dir){ | |
- m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI; | |
+ m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI + m_prop.automatic_face_movement_dir_offset; | |
updateNodePos(); | |
} | |
} | |
diff --git a/src/content_sao.cpp b/src/content_sao.cpp | |
index 9b4ae61..101f9c4 100644 | |
--- a/src/content_sao.cpp | |
+++ b/src/content_sao.cpp | |
@@ -528,7 +528,7 @@ void LuaEntitySAO::step(float dtime, bool send_recommended) | |
} | |
if(m_prop.automatic_face_movement_dir){ | |
- m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI; | |
+ m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI + m_prop.automatic_face_movement_dir_offset; | |
} | |
} | |
diff --git a/src/object_properties.cpp b/src/object_properties.cpp | |
index b6ad9f6..f560f59 100644 | |
--- a/src/object_properties.cpp | |
+++ b/src/object_properties.cpp | |
@@ -41,7 +41,8 @@ | |
makes_footstep_sound(false), | |
automatic_rotate(0), | |
stepheight(0), | |
- automatic_face_movement_dir(false) | |
+ automatic_face_movement_dir(false), | |
+ automatic_face_movement_dir_offset(0.0) | |
{ | |
textures.push_back("unknown_object.png"); | |
colors.push_back(video::SColor(255,255,255,255)); | |
@@ -104,6 +105,7 @@ void ObjectProperties::serialize(std::ostream &os) const | |
writeU8(os, collideWithObjects); | |
writeF1000(os,stepheight); | |
writeU8(os, automatic_face_movement_dir); | |
+ writeF1000(os, automatic_face_movement_dir_offset); | |
// Add stuff only at the bottom. | |
// Never remove anything, because we don't want new versions of this | |
} | |
@@ -139,6 +141,7 @@ void ObjectProperties::deSerialize(std::istream &is) | |
collideWithObjects = readU8(is); | |
stepheight = readF1000(is); | |
automatic_face_movement_dir = readU8(is); | |
+ automatic_face_movement_dir_offset = readF1000(is); | |
}catch(SerializationError &e){} | |
} | |
else | |
diff --git a/src/object_properties.h b/src/object_properties.h | |
index edc9c39..4b7f9a5 100644 | |
--- a/src/object_properties.h | |
+++ b/src/object_properties.h | |
@@ -46,6 +46,7 @@ struct ObjectProperties | |
float automatic_rotate; | |
f32 stepheight; | |
bool automatic_face_movement_dir; | |
+ f32 automatic_face_movement_dir_offset; | |
ObjectProperties(); | |
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp | |
index 2e26adb..9f0ec8d 100644 | |
--- a/src/script/common/c_content.cpp | |
+++ b/src/script/common/c_content.cpp | |
@@ -190,7 +190,12 @@ void read_object_properties(lua_State *L, int index, | |
getfloatfield(L, -1, "automatic_rotate", prop->automatic_rotate); | |
getfloatfield(L, -1, "stepheight", prop->stepheight); | |
prop->stepheight*=BS; | |
- getboolfield(L, -1, "automatic_face_movement_dir", prop->automatic_face_movement_dir); | |
+ lua_getfield(L, -1, "automatic_face_movement_dir"); | |
+ if (!lua_isnil(L, -1)) { | |
+ prop->automatic_face_movement_dir = true; | |
+ prop->automatic_face_movement_dir_offset = luaL_checknumber(L, -1); | |
+ } | |
+ lua_pop(L, 1); | |
} | |
/******************************************************************************/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment