diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-01-02 13:12:56 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-01-02 13:12:56 +0200 |
commit | ff82b95800b13d156a59d4936970dc3c8797b14e (patch) | |
tree | c8eba929746ff872fec61186028b4fb1f20bf63f /src | |
parent | 49b7055cb3f676c19dc5edd07fe72e2f5e2414a1 (diff) | |
download | minetest-ff82b95800b13d156a59d4936970dc3c8797b14e.tar.gz minetest-ff82b95800b13d156a59d4936970dc3c8797b14e.tar.bz2 minetest-ff82b95800b13d156a59d4936970dc3c8797b14e.zip |
ObjectRef:get_entity_name() and fixing of comments in default/init.lua
Diffstat (limited to 'src')
-rw-r--r-- | src/content_sao.cpp | 5 | ||||
-rw-r--r-- | src/content_sao.h | 1 | ||||
-rw-r--r-- | src/scriptapi.cpp | 13 |
3 files changed, 19 insertions, 0 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp index afe82bdd2..e9e6543d9 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -1736,6 +1736,11 @@ void LuaEntitySAO::setSprite(v2s16 p, int num_frames, float framelength, m_messages_out.push_back(aom); } +std::string LuaEntitySAO::getName() +{ + return m_init_name; +} + void LuaEntitySAO::sendPosition(bool do_interpolate, bool is_movement_end) { m_last_sent_move_precision = m_base_position.getDistanceFrom( diff --git a/src/content_sao.h b/src/content_sao.h index 04ee7ee1b..d56fdb709 100644 --- a/src/content_sao.h +++ b/src/content_sao.h @@ -218,6 +218,7 @@ public: void setTextureMod(const std::string &mod); void setSprite(v2s16 p, int num_frames, float framelength, bool select_horiz_by_yawpitch); + std::string getName(); private: void sendPosition(bool do_interpolate, bool is_movement_end); diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 6b850b19a..2e635feb9 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -1989,6 +1989,18 @@ private: return 0; } + // get_entity_name(self) + static int l_get_entity_name(lua_State *L) + { + ObjectRef *ref = checkobject(L, 1); + LuaEntitySAO *co = getluaobject(ref); + if(co == NULL) return 0; + // Do it + std::string name = co->getName(); + lua_pushstring(L, name.c_str()); + return 1; + } + /* Player-only */ // get_player_name(self) @@ -2190,6 +2202,7 @@ const luaL_reg ObjectRef::methods[] = { method(ObjectRef, getacceleration), method(ObjectRef, settexturemod), method(ObjectRef, setsprite), + method(ObjectRef, get_entity_name), // Player-only method(ObjectRef, get_player_name), method(ObjectRef, get_inventory), |