mirror of
https://github.com/love2d/love.git
synced 2026-08-15 07:41:11 +02:00
Move the references from _G to the registry
This commit is contained in:
@@ -352,6 +352,10 @@ namespace love
|
||||
|
||||
int luax_insist(lua_State * L, int idx, const char * k)
|
||||
{
|
||||
// Convert to absolute index if necessary.
|
||||
if (idx < 0 && idx > LUA_REGISTRYINDEX)
|
||||
idx = lua_gettop(L) + ++idx;
|
||||
|
||||
lua_getfield(L, idx, k);
|
||||
|
||||
// Create if necessary.
|
||||
@@ -360,7 +364,7 @@ namespace love
|
||||
lua_pop(L, 1); // Pop the non-table.
|
||||
lua_newtable(L);
|
||||
lua_pushvalue(L, -1); // Duplicate the table to leave on top.
|
||||
lua_setfield(L, -3, k); // k[idx] = table
|
||||
lua_setfield(L, idx, k); // lua_stack[idx][k] = lua_stack[-1] (table)
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user