diff --git a/src/pc/lua/smlua_require.c b/src/pc/lua/smlua_require.c index 79fb45296..3b9bba015 100644 --- a/src/pc/lua/smlua_require.c +++ b/src/pc/lua/smlua_require.c @@ -120,8 +120,13 @@ static struct ModFile* smlua_find_mod_file(const char* moduleName) { char luaName[SYS_MAX_PATH] = ""; char luacName[SYS_MAX_PATH] = ""; - snprintf(luaName, SYS_MAX_PATH, "%s.lua", absolutePath); - snprintf(luacName, SYS_MAX_PATH, "%s.luac", absolutePath); + if (!path_ends_with(absolutePath, ".lua") && !path_ends_with(absolutePath, ".luac")) { + snprintf(luaName, SYS_MAX_PATH, "%s.lua", absolutePath); + snprintf(luacName, SYS_MAX_PATH, "%s.luac", absolutePath); + } else { + snprintf(luaName, SYS_MAX_PATH, "%s", absolutePath); + snprintf(luacName, SYS_MAX_PATH, "%s", absolutePath); + } // since mods' relativePaths are relative to the mod's root, we can do a direct comparison for (int i = 0; i < gLuaActiveMod->fileCount; i++) { @@ -201,6 +206,11 @@ static struct ModFile* smlua_find_file(const char* fileName) { for (int i = 0; i < gLuaActiveMod->fileCount; i++) { struct ModFile* file = &gLuaActiveMod->files[i]; + // exclude lua files + if (path_ends_with(file->relativePath, ".lua") || path_ends_with(file->relativePath, ".luac")) { + continue; + } + // check for match, normalizing to system separators strcpy(normalizedRelative, file->relativePath); normalize_path(normalizedRelative);