From bb4f3fc58181277f40fc308413e666e76c232e3a Mon Sep 17 00:00:00 2001 From: xLuigiGamerx <88401287+xLuigiGamerx@users.noreply.github.com> Date: Sun, 21 Dec 2025 01:21:15 +0300 Subject: [PATCH] Allowed manually appending `.lua` to the end of a file name to avoid confusion with extensionless files --- src/pc/lua/smlua_require.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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);