Bladeren bron

Removed Exists() check when trying to load the .lua variant of a Lua script resource (after .luc was not found.) Log an info message when a Lua script is successfully loaded, similar to AngelScript.

Lasse Öörni 12 jaren geleden
bovenliggende
commit
06c93d84ef
2 gewijzigde bestanden met toevoegingen van 6 en 8 verwijderingen
  1. 1 0
      Source/Engine/LuaScript/LuaFile.cpp
  2. 5 8
      Source/Engine/LuaScript/LuaScript.cpp

+ 1 - 0
Source/Engine/LuaScript/LuaFile.cpp

@@ -118,6 +118,7 @@ bool LuaFile::LoadChunk(lua_State* luaState)
         return false;
     }
 
+    LOGINFO("Loaded Lua script " + GetName());
     hasLoaded_ = true;
 
     return true;

+ 5 - 8
Source/Engine/LuaScript/LuaScript.cpp

@@ -272,7 +272,7 @@ int LuaScript::Loader(lua_State* L)
     // Get module name
     const char* name = luaL_checkstring(L, 1);
 
-    // Try get Luc file
+    // Try get .luc file. Use Exists() check here to avoid log error in case only the .lua file exists
     String lucFileName = String(name) + ".luc";
     if (cache->Exists(lucFileName))
     {
@@ -281,14 +281,11 @@ int LuaScript::Loader(lua_State* L)
             return lucFile->LoadChunk(L) ? 1 : 0;
     }
 
-    // Try get Lua file
+    // Try get .lua file. If this also fails, error is logged
     String luaFileName = String(name) + ".lua";
-    if (cache->Exists(luaFileName))
-    {
-        LuaFile* luaFile = cache->GetResource<LuaFile>(luaFileName);
-        if (luaFile)
-            return luaFile->LoadChunk(L) ? 1 : 0;
-    }
+    LuaFile* luaFile = cache->GetResource<LuaFile>(luaFileName);
+    if (luaFile)
+        return luaFile->LoadChunk(L) ? 1 : 0;
 
     return 0;
 }