Fix Lua `require` not looking in Lua dir on Linux

see #3485
thanks to @CasualPokePlayer for research and initial implementation
This commit is contained in:
YoshiRulz 2022-12-11 13:13:11 +10:00
parent 9e4836d300
commit cbb335fec2
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 8 additions and 0 deletions

View File

@ -104,6 +104,14 @@ namespace BizHawk.Client.EmuHawk
}
_lua.RegisterFunction("print", this, typeof(Win32LuaLibraries).GetMethod(nameof(Print)));
if (OSTailoredCode.IsUnixHost)
{
// add %exe%/Lua to library resolution pathset (LUA_PATH)
// this is done already on windows, but not on linux it seems?
var packageTable = (LuaTable) _lua["package"];
var luaPath = PathEntries.LuaAbsolutePath();
packageTable["path"] = $"{luaPath}/?.lua;{luaPath}?/init.lua;{packageTable["path"]}";
}
EmulationLuaLibrary.FrameAdvanceCallback = Frameadvance;
EmulationLuaLibrary.YieldCallback = EmuYield;