Commits

Bart van Strien  committed 8a98a2b

Properly export love modules to lua, package.loaded is correct now

  • Participants
  • Parent commits 0103d2f

Comments (0)

Files changed (4)

File src/common/runtime.cpp

 			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)

File src/love.cpp

 
 	lua_setfield(L, -2, "_version_compat");
 
-	lua_pop(L, 1); // love
-
 #ifdef LOVE_BUILD_STANDALONE
 
 	// Preload module loaders.
 
 #endif // LOVE_BUILD_STANDALONE
 
-	return 0;
+	return 1;
 }
 
 #ifdef LOVE_LEGENDARY_UTF8_ARGV_HACK

File src/modules/audio/wrap_Audio.cpp

 		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

File src/modules/graphics/opengl/wrap_Graphics.cpp

 		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