Added in plugin table.

This commit is contained in:
Adam Harrison 2021-09-20 23:38:10 -04:00
parent 3ca127793a
commit c01c5a23b0
2 changed files with 6 additions and 1 deletions

View File

@ -690,8 +690,10 @@ static int f_load_native_plugin(lua_State* L) {
void* library = SDL_LoadObject(path);
if (name == 0 || !library)
return luaL_error(L, "Unable to load %s: %s", name, SDL_GetError());
lua_getfield(L, LUA_REGISTRYINDEX, "native_plugins");
lua_pushlightuserdata(L, library);
lua_setfield(L, LUA_REGISTRYINDEX, name);
lua_setfield(L, -2, name);
lua_pop(L, 1);
for (sname = namelen - 1; sname > 0 && name[sname] != '.'; --sname);
snprintf(olib, sizeof(olib), "lua_open_lite_xl_%s", &name[sname+1]);
int (*ext_entrypoint)(lua_State* L, void*) = SDL_LoadFunction(library, olib);

View File

@ -152,6 +152,9 @@ init_lua:
lua_setglobal(L, "LINUX");
#endif
lua_newtable(L);
lua_setfield(L, LUA_REGISTRYINDEX, "native_plugins");
const char *init_lite_code = \
"local core\n"
"xpcall(function()\n"