From b3ef2b3344e0f510f4f24dd6f3c21326ca2e5eda Mon Sep 17 00:00:00 2001
From: LJ Sonic <lamr@free.fr>
Date: Thu, 28 Dec 2023 17:32:36 +0100
Subject: [PATCH] Support loadfile in folder add-ons too

---
 src/blua/lbaselib.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/blua/lbaselib.c b/src/blua/lbaselib.c
index 452f101c45..2bb3d9cf09 100644
--- a/src/blua/lbaselib.c
+++ b/src/blua/lbaselib.c
@@ -275,7 +275,7 @@ static int luaB_dofile (lua_State *L) {
 	int n = lua_gettop(L);
 
 	if (!W_FileHasFolders(wadfiles[numwadfiles - 1]))
-		luaL_error(L, "dofile() only works with PK3 files");
+		luaL_error(L, "dofile() only works with PK3 files and folders");
 
 	snprintf(fullfilename, sizeof(fullfilename), "Lua/%s", filename);
 	lumpnum = W_CheckNumForFullNamePK3(fullfilename, numwadfiles - 1, 0);
@@ -293,8 +293,8 @@ static int luaB_loadfile (lua_State *L) {
   char fullfilename[256];
   UINT16 lumpnum;
 
-  if (wadfiles[numwadfiles - 1]->type != RET_PK3)
-    luaL_error(L, "loadfile() only works with PK3 files");
+	if (!W_FileHasFolders(wadfiles[numwadfiles - 1]))
+    luaL_error(L, "loadfile() only works with PK3 files and folders");
 
   snprintf(fullfilename, sizeof(fullfilename), "Lua/%s", filename);
   lumpnum = W_CheckNumForFullNamePK3(fullfilename, numwadfiles - 1, 0);
-- 
GitLab