From 8b8bf645eb5222ca65e7bc6569f3e4069699fd9c Mon Sep 17 00:00:00 2001 From: kingbri Date: Wed, 14 Jun 2023 12:26:02 -0400 Subject: [PATCH] World Info: Allow disabling recursion on entries Recursive scanning is a very great tool used to create a tree hierarchy of entries. However, some entries should not be included in recursion due to possible conflicts and resulting leakage in chats. Add an individual opt-out toggle to exclude the entry from recursive scanning if the main option is enabled. Signed-off-by: kingbri --- public/index.html | 4 ++++ public/scripts/world-info.js | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 25695ae41..fa21b42d0 100644 --- a/public/index.html +++ b/public/index.html @@ -2920,6 +2920,10 @@ Disable + diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 2dc0abcbc..b322d14c1 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -332,6 +332,19 @@ function appendWorldEntry(entry) { $(this).siblings("input").click(); }); + const excludeRecursionInput = template.find('input[name="exclude_recursion"]'); + excludeRecursionInput.data("uid", entry.uid); + excludeRecursionInput.on("input", function () { + const uid = $(this).data("uid"); + const value = $(this).prop("checked"); + world_info_data.entries[uid].excludeRecursion = value; + saveWorldInfo(); + }); + excludeRecursionInput.prop("checked", entry.excludeRecursion).trigger("input"); + excludeRecursionInput.siblings(".checkbox_fancy").click(function () { + $(this).siblings("input").click(); + }); + // delete button const deleteButton = template.find("input.delete_entry_button"); deleteButton.data("uid", entry.uid); @@ -366,6 +379,7 @@ function createWorldInfoEntry() { order: 100, position: 0, disable: false, + excludeRecursion: false }; const newUid = getFreeWorldEntryUid(); @@ -505,6 +519,7 @@ function checkWorldInfo(chat) { let worldInfoBefore = ""; let worldInfoAfter = ""; let needsToScan = true; + let count = 0; let allActivatedEntries = new Set(); const sortedEntries = Object.keys(world_info_data.entries) @@ -512,10 +527,13 @@ function checkWorldInfo(chat) { .sort((a, b) => b.order - a.order); while (needsToScan) { + // Track how many times the loop has run + count++; + let activatedNow = new Set(); for (let entry of sortedEntries) { - if (allActivatedEntries.has(entry.uid) || entry.disable == true) { + if (allActivatedEntries.has(entry.uid) || entry.disable == true || (count > 1 && world_info_recursive && entry.excludeRecursion)) { continue; }