From 53c7bcc6d57c787033b2b829aa48ef78e77c3f41 Mon Sep 17 00:00:00 2001 From: Evil Factory <36804725+evilfactory@users.noreply.github.com> Date: Wed, 16 Mar 2022 06:39:57 -0300 Subject: [PATCH] fix errors when executing Lua mods being weird (not completely tested) --- Barotrauma/BarotraumaShared/Lua/LuaSetup.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Lua/LuaSetup.lua b/Barotrauma/BarotraumaShared/Lua/LuaSetup.lua index 9f6189f1c..3fb8d6fad 100644 --- a/Barotrauma/BarotraumaShared/Lua/LuaSetup.lua +++ b/Barotrauma/BarotraumaShared/Lua/LuaSetup.lua @@ -39,13 +39,18 @@ local function endsWith(str, suffix) return str:sub(-string.len(suffix)) == suffix end -local function runFolder(folder) - for k, str in pairs(File.DirSearch(folder)) do - local s = str:gsub("\\", "/") +local function executeProtected(s) + print(s) + dofile(s) +end - if endsWith(str, ".lua") then - print(s) - dofile(s) +local function runFolder(folder) + local search = File.DirSearch(folder) + for i = 1, #search, 1 do + local s = search[i]:gsub("\\", "/") + + if endsWith(s, ".lua") then + executeProtected(s) end end