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