Make math module work better in threads;
conf doesn't work in threads.  While this seems problematic, it can
kinda be considered the right thing.  Right now the math module can't
be required at all in threads which seems bad, so we'll make it work
and just ignore the "globals" flag for now.
@@ -382,6 +382,7 @@ int luaopen_lovr_math(lua_State* L) {
// Globals
luax_pushconf(L);
+ if (lua_istable(L, -1)) {
lua_getfield(L, -1, "math");
if (lua_istable(L, -1)) {
lua_getfield(L, -1, "globals");
@@ -393,7 +394,9 @@ int luaopen_lovr_math(lua_State* L) {
}
lua_pop(L, 1);
}
- lua_pop(L, 2);
+ lua_pop(L, 1);
+ }
+ lua_pop(L, 1);
return 1;
}
