diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-01-02 16:08:59 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-01-02 16:08:59 +0200 |
commit | 2445cbbbdca54d40d1c0a069cc360b06bf44d291 (patch) | |
tree | 6223a742cef7eebd3054f3cd9623f7a4e861ed79 | |
parent | 48131bf988be2261d7abfab05ee4c41a3b002ad4 (diff) | |
download | minetest-2445cbbbdca54d40d1c0a069cc360b06bf44d291.tar.gz minetest-2445cbbbdca54d40d1c0a069cc360b06bf44d291.tar.bz2 minetest-2445cbbbdca54d40d1c0a069cc360b06bf44d291.zip |
Add ObjectRef:get_luaentity()
-rw-r--r-- | data/mods/default/init.lua | 1 | ||||
-rw-r--r-- | src/scriptapi.cpp | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/data/mods/default/init.lua b/data/mods/default/init.lua index 75fdcb012..c0df7c514 100644 --- a/data/mods/default/init.lua +++ b/data/mods/default/init.lua @@ -208,6 +208,7 @@ -- - ^ Select sprite from spritesheet with optional animation and DM-style -- - texture selection based on yaw relative to camera -- - get_entity_name() +-- - get_luaentity() -- Player-only: (no-op for other objects) -- - get_player_name(): will return nil if is not a player -- - get_inventory() -> InvRef diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 2e635feb9..9803470c3 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -2001,6 +2001,17 @@ private: return 1; } + // get_luaentity(self) + static int l_get_luaentity(lua_State *L) + { + ObjectRef *ref = checkobject(L, 1); + LuaEntitySAO *co = getluaobject(ref); + if(co == NULL) return 0; + // Do it + luaentity_get(L, co->getId()); + return 1; + } + /* Player-only */ // get_player_name(self) @@ -2203,6 +2214,7 @@ const luaL_reg ObjectRef::methods[] = { method(ObjectRef, settexturemod), method(ObjectRef, setsprite), method(ObjectRef, get_entity_name), + method(ObjectRef, get_luaentity), // Player-only method(ObjectRef, get_player_name), method(ObjectRef, get_inventory), |