mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-25 03:40:40 +00:00
Merge branch 'fix2' into 'master'
Fixes in components/lua Closes #6535 See merge request OpenMW/openmw!1538
This commit is contained in:
commit
1d4de71d35
@ -99,6 +99,9 @@ namespace LuaUtil
|
|||||||
{
|
{
|
||||||
if (mI18nLoader == sol::nil)
|
if (mI18nLoader == sol::nil)
|
||||||
throw std::runtime_error("LuaUtil::I18nManager is not initialized");
|
throw std::runtime_error("LuaUtil::I18nManager is not initialized");
|
||||||
|
auto it = mContexts.find(contextName);
|
||||||
|
if (it != mContexts.end())
|
||||||
|
return sol::make_object(mLua->sol(), it->second);
|
||||||
Context ctx{contextName, mLua->newTable(), call(mI18nLoader, "i18n.init")};
|
Context ctx{contextName, mLua->newTable(), call(mI18nLoader, "i18n.init")};
|
||||||
ctx.updateLang(this);
|
ctx.updateLang(this);
|
||||||
mContexts.emplace(contextName, ctx);
|
mContexts.emplace(contextName, ctx);
|
||||||
|
@ -170,7 +170,7 @@ namespace LuaUtil
|
|||||||
sol::environment env(mLua, sol::create, mSandboxEnv);
|
sol::environment env(mLua, sol::create, mSandboxEnv);
|
||||||
sol::table loaded(mLua, sol::create);
|
sol::table loaded(mLua, sol::create);
|
||||||
for (const std::string& s : safePackages)
|
for (const std::string& s : safePackages)
|
||||||
loaded[s] = mSandboxEnv[s];
|
loaded[s] = static_cast<sol::object>(mSandboxEnv[s]);
|
||||||
env["require"] = [this, loaded, env](const std::string& module) mutable
|
env["require"] = [this, loaded, env](const std::string& module) mutable
|
||||||
{
|
{
|
||||||
if (loaded[module] != sol::nil)
|
if (loaded[module] != sol::nil)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user