1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-11-16 14:25:19 -05:00

Add ObjectRef:get_luaentity()

This commit is contained in:
Perttu Ahola 2012-01-02 16:08:59 +02:00
parent 48131bf988
commit 2445cbbbdc
2 changed files with 13 additions and 0 deletions

View File

@ -208,6 +208,7 @@
-- - ^ Select sprite from spritesheet with optional animation and DM-style -- - ^ Select sprite from spritesheet with optional animation and DM-style
-- - texture selection based on yaw relative to camera -- - texture selection based on yaw relative to camera
-- - get_entity_name() -- - get_entity_name()
-- - get_luaentity()
-- Player-only: (no-op for other objects) -- Player-only: (no-op for other objects)
-- - get_player_name(): will return nil if is not a player -- - get_player_name(): will return nil if is not a player
-- - get_inventory() -> InvRef -- - get_inventory() -> InvRef

View File

@ -2001,6 +2001,17 @@ private:
return 1; 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 */ /* Player-only */
// get_player_name(self) // get_player_name(self)
@ -2203,6 +2214,7 @@ const luaL_reg ObjectRef::methods[] = {
method(ObjectRef, settexturemod), method(ObjectRef, settexturemod),
method(ObjectRef, setsprite), method(ObjectRef, setsprite),
method(ObjectRef, get_entity_name), method(ObjectRef, get_entity_name),
method(ObjectRef, get_luaentity),
// Player-only // Player-only
method(ObjectRef, get_player_name), method(ObjectRef, get_player_name),
method(ObjectRef, get_inventory), method(ObjectRef, get_inventory),