Add ObjectRef:get_luaentity()
authorPerttu Ahola <celeron55@gmail.com>
Mon, 2 Jan 2012 14:08:59 +0000 (16:08 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Mon, 2 Jan 2012 14:08:59 +0000 (16:08 +0200)
data/mods/default/init.lua
src/scriptapi.cpp

index 75fdcb012f9ad1f9b0241e2fb8003359b02c7d14..c0df7c514945b1ee6823b76e3ec06dd713caac13 100644 (file)
 -- - ^ 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
index 2e635feb9162504da4d7f2d50c41ce60ed0e1e36..9803470c3fcaa3b0e91efc22e147c6e5821f9e7a 100644 (file)
@@ -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),