Skip to content

Commit

Permalink
Create "scripts" directory if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickmollohan committed Dec 31, 2024
1 parent e88f45b commit d666104
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/script_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

void ScriptLoader::LoadScripts() {
if (Settings::EnableScripts) {
// Get the full path of the scripts directory
wchar_t gameRoot[MAX_PATH];
GetModuleFileNameW(NULL, gameRoot, MAX_PATH);

std::wstring gameRootPath = gameRoot;
gameRootPath = gameRootPath.substr(0, gameRootPath.find_last_of(L"\\"));

std::wstring scriptsPath = gameRootPath + L"\\scripts";

// If the scripts directory doesn't exist, create it
DWORD attributes = GetFileAttributesW(scriptsPath.c_str());
if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY)) {
CreateDirectoryW(scriptsPath.c_str(), NULL);
}

// Load scripts from the scripts directory
LoadScriptsFromDirectory(scriptsPath);
}
}
Expand Down

0 comments on commit d666104

Please sign in to comment.