From ed9c2a4d52b6d00b88002638d0aad79885c4abf8 Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Mon, 13 Dec 2021 11:50:10 -0500 Subject: [PATCH] Fix a bug that occurs when userscript doesn't have all 3 modifiers --- bridge.lua | 6 +++--- cores/default.lua | 12 +++--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/bridge.lua b/bridge.lua index e5d407bc..c950ba90 100644 --- a/bridge.lua +++ b/bridge.lua @@ -1584,9 +1584,9 @@ return function(_python, _bridged) local _userscript = old_loadfile(join_folder_and_filename(bridged.userscript_path, filename), "t", koboldbridge.get_universe(filename))() koboldbridge.logging_name = nil local userscript = deepcopy(KoboldUserScriptModule) - rawset(userscript, "_inmod", function() koboldbridge.logging_name = modulenames[i]; _userscript.inmod() end) - rawset(userscript, "_genmod", function() koboldbridge.logging_name = modulenames[i]; _userscript.genmod() end) - rawset(userscript, "_outmod", function() koboldbridge.logging_name = modulenames[i]; _userscript.outmod() end) + rawset(userscript, "_inmod", function() koboldbridge.logging_name = modulenames[i]; if _userscript.inmod ~= nil then _userscript.inmod() end end) + rawset(userscript, "_genmod", function() koboldbridge.logging_name = modulenames[i]; if _userscript.genmod ~= nil then _userscript.genmod() end end) + rawset(userscript, "_outmod", function() koboldbridge.logging_name = modulenames[i]; if _userscript.outmod ~= nil then _userscript.outmod() end end) rawset(userscript, "_filename", filename) rawset(userscript, "_modulename", modulenames[i]) rawset(userscript, "_description", descriptions[i]) diff --git a/cores/default.lua b/cores/default.lua index 6039978f..c6ad6d33 100644 --- a/cores/default.lua +++ b/cores/default.lua @@ -12,27 +12,21 @@ local corescript = {} function corescript.inmod() for i = #koboldcore.userscripts, 1, -1 do local userscript = koboldcore.userscripts[i] - if userscript.inmod ~= nil then - userscript.inmod() - end + userscript.inmod() end end -- Run all the generation modifiers from top to bottom function corescript.genmod() for i, userscript in ipairs(koboldcore.userscripts) do - if userscript.genmod ~= nil then - userscript.genmod() - end + userscript.genmod() end end -- Run all the generation modifiers from top to bottom function corescript.outmod() for i, userscript in ipairs(koboldcore.userscripts) do - if userscript.outmod ~= nil then - userscript.outmod() - end + userscript.outmod() end end