]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Add name field to registered entities
authorPerttu Ahola <celeron55@gmail.com>
Mon, 2 Jan 2012 14:26:40 +0000 (16:26 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Mon, 2 Jan 2012 14:26:40 +0000 (16:26 +0200)
data/mods/default/init.lua
src/scriptapi.cpp

index ac3ef1b8f666f89a6136a7e26a332303664cf5fa..073483d4e76d8d09b4c43e851ed0103f1dc6ab58 100644 (file)
 --
 -- Registered entities:
 -- - Functions receive a "luaentity" as self:
+--   - It has the member .name, which is the registered name ("mod:thing")
 --   - It has the member .object, which is an ObjectRef pointing to the object
 --   - The original prototype stuff is visible directly via a metatable
 -- - Callbacks:
index 401de8adeb477f25b0323d7e07b0a213adef0111..dbbaf3dc9493477a49d427621d8547abaf6f36ba 100644 (file)
@@ -2652,6 +2652,10 @@ static int l_register_entity(lua_State *L)
        
        // Get registered object to top of stack
        lua_pushvalue(L, 2);
+
+       // Set name field
+       lua_pushvalue(L, 1);
+       lua_setfield(L, -2, "name");
        
        // Set __index to point to itself
        lua_pushvalue(L, -1);