diff --git a/src/common/runtime.cpp b/src/common/runtime.cpp index 3bb7f29c6..18cdb0a65 100644 --- a/src/common/runtime.cpp +++ b/src/common/runtime.cpp @@ -187,10 +187,11 @@ namespace love for (const lua_CFunction * t = m.types; *t != 0; t++) (*t)(L); - lua_setfield(L, -2, m.name); // love.graphics = table - lua_pop(L, 1); // love + lua_pushvalue(L, -1); + lua_setfield(L, -3, m.name); // love.graphics = table + lua_remove(L, -2); // love - return 0; + return 1; } int luax_preload(lua_State * L, lua_CFunction f, const char * name) diff --git a/src/love.cpp b/src/love.cpp index 5cb9d5766..d6b5a91e7 100644 --- a/src/love.cpp +++ b/src/love.cpp @@ -125,8 +125,6 @@ extern "C" LOVE_EXPORT int luaopen_love(lua_State * L) lua_setfield(L, -2, "_version_compat"); - lua_pop(L, 1); // love - #ifdef LOVE_BUILD_STANDALONE // Preload module loaders. @@ -139,7 +137,7 @@ extern "C" LOVE_EXPORT int luaopen_love(lua_State * L) #endif // LOVE_BUILD_STANDALONE - return 0; + return 1; } #ifdef LOVE_LEGENDARY_UTF8_ARGV_HACK diff --git a/src/modules/audio/wrap_Audio.cpp b/src/modules/audio/wrap_Audio.cpp index d0effc94c..274cd9285 100644 --- a/src/modules/audio/wrap_Audio.cpp +++ b/src/modules/audio/wrap_Audio.cpp @@ -327,12 +327,12 @@ namespace audio w.functions = functions; w.types = types; - luax_register_module(L, w); + int n = luax_register_module(L, w); if (luaL_loadbuffer(L, (const char *)audio_lua, sizeof(audio_lua), "audio.lua") == 0) lua_call(L, 0, 0); - return 0; + return n; } } // audio diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index 08809903e..92a4991c6 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -1300,12 +1300,12 @@ namespace opengl w.functions = functions; w.types = types; - luax_register_module(L, w); + int n = luax_register_module(L, w); if (luaL_loadbuffer(L, (const char *)graphics_lua, sizeof(graphics_lua), "graphics.lua") == 0) lua_call(L, 0, 0); - return 0; + return n; } } // opengl