Add name field to registered entities

master
Perttu Ahola 2012-01-02 16:26:40 +02:00
parent 56f55ab1af
commit ab57fbe4ca
2 changed files with 5 additions and 0 deletions

View File

@ -239,6 +239,7 @@
-- --
-- Registered entities: -- Registered entities:
-- - Functions receive a "luaentity" as self: -- - 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 -- - It has the member .object, which is an ObjectRef pointing to the object
-- - The original prototype stuff is visible directly via a metatable -- - The original prototype stuff is visible directly via a metatable
-- - Callbacks: -- - Callbacks:

View File

@ -2653,6 +2653,10 @@ static int l_register_entity(lua_State *L)
// Get registered object to top of stack // Get registered object to top of stack
lua_pushvalue(L, 2); lua_pushvalue(L, 2);
// Set name field
lua_pushvalue(L, 1);
lua_setfield(L, -2, "name");
// Set __index to point to itself // Set __index to point to itself
lua_pushvalue(L, -1); lua_pushvalue(L, -1);
lua_setfield(L, -2, "__index"); lua_setfield(L, -2, "__index");