Fix constants' searching SOC's vars, deny A_* and super being in constants'.

This commit is contained in:
GoldenTails 2021-11-07 01:27:59 -05:00
parent ad0c684d1d
commit fa25cdad81

View file

@ -555,11 +555,15 @@ static int constants_get(lua_State *L)
key = luaL_checkstring(L, 2);
// In Lua, mathlib is always there
ret = getEnum(L, true, key);
// In Lua, mathlib is never there
ret = getEnum(L, false, key);
if (ret != -1)
return ret;
// Don't allow A_* or super.
// All userdata is meant to be considered global variables,
// so no need to get more specific than "is it userdata?"
if (!lua_isuserdata(L, -1) && !lua_isfunction(L, -1))
return ret;
return 0;
}