Add UI element for delay recursion level - Tied and only visible to the "delay until recursion" toggle - Will set it to a numerical value if used, otherwise keeps true/false state of the toggle

eeed072ebba143e19680d6efaa9a8ee8f60f705d

Wolfsblvt <wolfsblvt@gmail.com>

3 files changed, +35 -2Showing whitespace changes
public/css/world-info.css+4 -0
@@ -274,3 +274,7 @@ select.keyselect+span.select2-container .select2-selection--multiple {
274274 align-self: center;
275275 width: 100%;
276276}
277+
278+.world_entry:has(input[name="delay_until_recursion"]:not(:checked)) .world_entry_form_control:has(input[name="delayUntilRecursionLevel"]) {
279+ display: none;
280+}
public/index.html+7 -0
@@ -5489,6 +5489,13 @@
54895489 <small class="textAlignCenter" data-i18n="Automation ID">Automation ID</small>
54905490 <input class="text_pole margin0" name="automationId" type="text" placeholder="( None )" data-i18n="[placeholder]( None )">
54915491 </div>
5492+ <div class="world_entry_form_control flex1" title="Defines delay levels for recursive scans.&#13;&#13;Initially, only the first level (smallest number) will match.&#13;Once no matches are found, the next level becomes eligible for matching.&#13;This repeats until all levels are checked.&#13;&#13;Tied to the &quot;Delay until recursion&quot; setting." data-i18n="[title]delay_until_recursion_level">
5493+ <small class="textAlignCenter">
5494+ <span data-i18n="Recursion Level">Recursion Level</span>
5495+ <div class="fa-solid fa-circle-info opacity50p"></div>
5496+ </small>
5497+ <input class="text_pole margin0" name="delayUntilRecursionLevel" type="text" placeholder="1">
5498+ </div>
54925499 </div>
54935500 <div name="contentAndCharFilterBlock" class="world_entry_thin_controls flex2">
54945501 <div class="world_entry_form_control flex1">
public/scripts/world-info.js+24 -2
@@ -2953,13 +2953,35 @@ async function getWorldEntry(name, data, entry) {
29532953 delayUntilRecursionInput.data('uid', entry.uid);
29542954 delayUntilRecursionInput.on('input', async function () {
29552955 const uid = $(this).data('uid');
29562956 const valuetoggled = $(this).prop('checked');
2957+
2958+ // If the value contains a number, we'll take that one (set by the level input), otherwise we can use true/false switch
2959+ const value = toggled ? data.entries[uid].delayUntilRecursion || true : false;
2960+
29572961 data.entries[uid].delayUntilRecursion = value;
29582962 setWIOriginalDataValue(data, uid, 'extensions.delay_until_recursion', data.entries[uid].delayUntilRecursion);
29592963 await saveWorldInfo(name, data);
29602964 });
29612965 delayUntilRecursionInput.prop('checked', entry.delayUntilRecursion).trigger('input');
29622966
2967+ // delay until recursion level
2968+ const delayUntilRecursionLevelInput = template.find('input[name="delayUntilRecursionLevel"]');
2969+ delayUntilRecursionLevelInput.data('uid', entry.uid);
2970+ delayUntilRecursionLevelInput.on('input', async function () {
2971+ const uid = $(this).data('uid');
2972+ const content = $(this).val();
2973+ const value = content === '' ? (typeof data.entries[uid].delayUntilRecursion === 'boolean' ? data.entries[uid].delayUntilRecursion : true)
2974+ : content === 1 ? true
2975+ : !isNaN(Number(content)) ? Number(content)
2976+ : false;
2977+
2978+ data.entries[uid].delayUntilRecursion = value;
2979+ setWIOriginalDataValue(data, uid, 'extensions.delay_until_recursion', data.entries[uid].delayUntilRecursion);
2980+ await saveWorldInfo(name, data);
2981+ });
2982+ // No need to retrigger inpout event, we'll just set the curret current value. It was edited/saved above already
2983+ delayUntilRecursionLevelInput.val(['number', 'string'].includes(typeof entry.delayUntilRecursion) ? entry.delayUntilRecursion : '').trigger('input');
2984+
29632985 // duplicate button
29642986 const duplicateButton = template.find('.duplicate_entry_button');
29652987 duplicateButton.data('uid', entry.uid);
@@ -3257,7 +3279,7 @@ export const newWorldInfoEntryDefinition = {
32573279 disable: { default: false, type: 'boolean' },
32583280 excludeRecursion: { default: false, type: 'boolean' },
32593281 preventRecursion: { default: false, type: 'boolean' },
32603282 delayUntilRecursion: { default: false0, type: 'booleannumber' },
32613283 probability: { default: 100, type: 'number' },
32623284 useProbability: { default: true, type: 'boolean' },
32633285 depth: { default: DEFAULT_DEPTH, type: 'number' },