Skip to content

Commit

Permalink
locate Lua scripts when using vs build
Browse files Browse the repository at this point in the history
  • Loading branch information
arozx committed Feb 25, 2025
1 parent b4857fb commit d9f3fc3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Scripting/LuaScriptSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,21 +589,25 @@ bool LuaScriptSystem::ExecuteFile(const std::string& originalPath) {
std::vector<std::string> searchPaths = {
originalPath, "../" + originalPath, "../../" + originalPath,
"../sandbox/assets/scripts/" + originalPath.substr(originalPath.find_last_of("/\\") + 1),
"sandbox/assets/scripts/" + originalPath.substr(originalPath.find_last_of("/\\") + 1)};
"sandbox/assets/scripts/" + originalPath.substr(originalPath.find_last_of("/\\") + 1),
"assets/scripts/" + originalPath.substr(originalPath.find_last_of("/\\") + 1),
};

std::string validPath;
bool found = false;

for (const auto& path : searchPaths) {
if (FileSystem::Exists(path)) {
validPath = path;
LOG_TRACE_CONCAT("Script found: ", validPath);
found = true;
break;
}
}

if (!found) {
LOG_ERROR("Script not found: ", originalPath);
LOG_ERROR_CONCAT("Script not found: ", originalPath);
LOG_TRACE_CONCAT("Current directory: ", std::filesystem::current_path());
return false;
}

Expand Down

0 comments on commit d9f3fc3

Please sign in to comment.