@@ -91,7 +91,7 @@ void CLuaMain::GetPackage(lua_State* L, SString& strName)
9191// Load a Lua lib of a given name
9292//
9393// /////////////////////////////////////////////////////////////
94- bool CLuaMain::LoadLuaLib (lua_State* L, SString strName, SString& strError)
94+ bool CLuaMain::LoadLuaLib (lua_State* L, SString strName, SString& strError, bool & bEmpty )
9595{
9696 SString strPath = strName;
9797 // Name format shouldn't include slashes. Subdirs are dots.
@@ -106,23 +106,23 @@ bool CLuaMain::LoadLuaLib(lua_State* L, SString strName, SString& strError)
106106#endif
107107
108108 std::vector<char > buffer;
109+ strError = " error loading module '" + strName + " ' from locations:\n\t " ;
109110 // Try <resource>/?.lua
110111 SString strFilePath = PathJoin (strResPath, strPath + " .lua" );
111112 if (FileExists (strFilePath))
112113 FileLoad (strFilePath, buffer);
113114 else
114115 {
115116 // Don't use a format string for safety, so we construct the error by hand
116- strError += " error loading module " + strName + " from file " + strFilePath + " : \n\t The specified module could not be found " ;
117+ strError += " #1: " + ConformPath (strFilePath, " resources/ " ) + " \n\t " ;
117118
118119 // Try <resource>/?/init.lua
119120 strFilePath = PathJoin (strResPath, strPath, " init.lua" );
120121 if (FileExists (strFilePath))
121122 FileLoad (strFilePath, buffer);
122123 else
123124 {
124- strError += " \n " ;
125- strError += " error loading module " + strName + " from file " + strFilePath + " :\n\t The specified module could not be found" ;
125+ strError += " #2: " + ConformPath (strFilePath, " resources/" ) + " \n\t " ;
126126 return false ;
127127 }
128128 }
@@ -137,15 +137,19 @@ bool CLuaMain::LoadLuaLib(lua_State* L, SString strName, SString& strError)
137137
138138 if (lua_type (L, -1 ) == LUA_TNIL)
139139 {
140- strError += " error loading module " + strName + " from file " + strFilePath + " :\n\t Module didn't return a value" ;
140+ strError = " module '" + strName + " ' in location " + ConformPath (strFilePath, " resources/" ) + " didn't return a value." ;
141+ bEmpty = true ;
141142 return false ;
142143 }
143144
144145 SetPackage (L, strName); // Store our package into package.loaded
145146 return true ;
146147 }
147148 else
148- strError += " error loading module " + strName + " from file " + strFilePath + " :\n\t Error loading script file" ;
149+ {
150+ strError = " could not load module '" + strName + " ' from file " + ConformPath (strFilePath, " resources/" ) + " : File is empty." ;
151+ bEmpty = true ;
152+ }
149153
150154 return false ;
151155}
0 commit comments