From 595d3aec9a08da8de7c98ba00ea67868d36b4ac4 Mon Sep 17 00:00:00 2001 From: jayden <46307433+krmeet@users.noreply.github.com> Date: Sat, 30 Dec 2023 19:18:11 +0000 Subject: [PATCH 1/3] accept .luac as valid lua files --- src/pc/mods/mod.c | 4 ++-- src/pc/mods/mod_import.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pc/mods/mod.c b/src/pc/mods/mod.c index 5e5d5cec..86a53590 100644 --- a/src/pc/mods/mod.c +++ b/src/pc/mods/mod.c @@ -13,7 +13,7 @@ size_t mod_get_lua_size(struct Mod* mod) { for (int i = 0; i < mod->fileCount; i++) { struct ModFile* file = &mod->files[i]; - if (!str_ends_with(file->relativePath, ".lua")) { continue; } + if (!(str_ends_with(file->relativePath, ".lua") || str_ends_with(file->relativePath, ".luac"))) { continue; } size += file->size; } @@ -318,7 +318,7 @@ static bool mod_load_files(struct Mod* mod, char* modName, char* fullPath) { // deal with mod directory { - const char* fileTypes[] = { ".lua", NULL }; + const char* fileTypes[] = { ".lua", ".luac", NULL }; if (!mod_load_files_dir(mod, fullPath, "", fileTypes)) { return false; } } diff --git a/src/pc/mods/mod_import.c b/src/pc/mods/mod_import.c index 2833dd5c..3aa2d754 100644 --- a/src/pc/mods/mod_import.c +++ b/src/pc/mods/mod_import.c @@ -76,7 +76,7 @@ static bool mod_import_zip(char* path, bool* isLua, bool* isDynos) { return false; } - if (str_ends_with(file_stat.m_filename, ".lua")) { + if (str_ends_with(file_stat.m_filename, ".lua") || str_ends_with(file_stat.m_filename, ".luac")) { path_get_folder(file_stat.m_filename, luaPath); *isLua = true; break; @@ -214,7 +214,7 @@ bool mod_import_file(char* path) { return false; } - if (str_ends_with(path, ".lua")) { + if (str_ends_with(path, ".lua") || str_ends_with(path, ".luac")) { isLua = true; ret = mod_import_lua(path); } else if (str_ends_with(path, ".zip")) { From 7e06eb37fd93e9f097adfb83bde82d927dafb0b7 Mon Sep 17 00:00:00 2001 From: jayden <46307433+krmeet@users.noreply.github.com> Date: Sat, 30 Dec 2023 19:18:37 +0000 Subject: [PATCH 2/3] tell git to stop changing luac files --- .gitattributes | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index d66b590e..5af6fc99 100644 --- a/.gitattributes +++ b/.gitattributes @@ -16,6 +16,7 @@ *.ld text *.inc text *.txt text +*.lua text *.json text *.yaml text @@ -27,4 +28,5 @@ *.ico binary *.mp3 binary *.lvl binary -*.tex binary \ No newline at end of file +*.tex binary +*.luac binary \ No newline at end of file From 216a6db872f8901c3d2ca2587f3addca5c4b49f9 Mon Sep 17 00:00:00 2001 From: jayden <46307433+krmeet@users.noreply.github.com> Date: Sat, 30 Dec 2023 19:26:04 +0000 Subject: [PATCH 3/3] let luac files actually run --- src/pc/lua/smlua.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pc/lua/smlua.c b/src/pc/lua/smlua.c index 0a219f21..fd9ca690 100644 --- a/src/pc/lua/smlua.c +++ b/src/pc/lua/smlua.c @@ -275,7 +275,7 @@ void smlua_init(void) { gPcDebug.lastModRun = gLuaActiveMod; for (int j = 0; j < mod->fileCount; j++) { struct ModFile* file = &mod->files[j]; - if (!str_ends_with(file->relativePath, ".lua")) { + if (!(str_ends_with(file->relativePath, ".lua") || str_ends_with(file->relativePath, ".luac"))) { continue; } smlua_load_script(mod, file, i); @@ -288,7 +288,7 @@ void smlua_init(void) { void smlua_update(void) { lua_State* L = gLuaState; if (L == NULL) { return; } - + smlua_call_event_hooks(HOOK_UPDATE); // Collect our garbage after calling our hooks. // If we don't, Lag can quickly build up from our mods.