make lua require use our filesystem functions

previously only lua dofile did this.
This commit is contained in:
gfgtdf 2014-10-24 15:33:06 +02:00
parent f126846be2
commit 77fb3852f9

View File

@ -1183,6 +1183,22 @@ static int intf_require(lua_State *L)
return luaL_argerror(L, 1, "file not found");
// Compile the file.
#if 1
try
{
if(lua_filestream::lua_loadfile(L, p))
throw game::error(lua_tostring(L, -1));
}
catch(const std::exception & ex)
{
chat_message("Lua error", ex.what());
ERR_LUA << ex.what() << '\n';
return 0;
}
#else
//oldcode to be deleted if newcode works
int res = luaL_loadfile(L, p.c_str());
if (res)
{
@ -1191,6 +1207,7 @@ static int intf_require(lua_State *L)
ERR_LUA << m << '\n';
return 0;
}
#endif
// Execute it.
if (!luaW_pcall(L, 0, 1)) return 0;