Fix sticky/cooldown interaction. Add icons
This commit is contained in:
parent
aa473dd749
commit
9c3cad2df2
|
@ -5424,8 +5424,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="flex2 flex-container flexFlowColumn flexNoGap" data-i18n="[title]Sticky entries will stay active for N messages after being triggered." title="Sticky entries will stay active for N messages after being triggered.">
|
<div class="flex2 flex-container flexFlowColumn flexNoGap" data-i18n="[title]Sticky entries will stay active for N messages after being triggered." title="Sticky entries will stay active for N messages after being triggered.">
|
||||||
<div class="flex-container justifySpaceBetween marginBot5">
|
<div class="flex-container justifySpaceBetween marginBot5">
|
||||||
<small for="sticky" data-i18n="Sticky">
|
<small class="flex-container alignItemsBaseline" for="sticky" data-i18n="Sticky">
|
||||||
Sticky
|
<span data-i18n="Sticky">
|
||||||
|
Sticky
|
||||||
|
</span>
|
||||||
|
<i class="fa-solid fa-comments fa-xs"></i>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="range-block-range">
|
<div class="range-block-range">
|
||||||
|
@ -5434,8 +5437,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="flex2 flex-container flexFlowColumn flexNoGap" data-i18n="[title]Entries with a cooldown can't be activated N messages after being triggered." title="Entries with a cooldown can't be activated N messages after being triggered.">
|
<div class="flex2 flex-container flexFlowColumn flexNoGap" data-i18n="[title]Entries with a cooldown can't be activated N messages after being triggered." title="Entries with a cooldown can't be activated N messages after being triggered.">
|
||||||
<div class="flex-container justifySpaceBetween marginBot5">
|
<div class="flex-container justifySpaceBetween marginBot5">
|
||||||
<small for="cooldown" data-i18n="Cooldown">
|
<small class="flex-container alignItemsBaseline" for="cooldown" data-i18n="Cooldown">
|
||||||
Cooldown
|
<span data-i18n="Cooldown">
|
||||||
|
Cooldown
|
||||||
|
</span>
|
||||||
|
<i class="fa-solid fa-comments fa-xs"></i>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="range-block-range">
|
<div class="range-block-range">
|
||||||
|
|
|
@ -107,9 +107,14 @@ class WorldInfoBuffer {
|
||||||
static externalActivations = [];
|
static externalActivations = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {object[]} Array of entries that need to be suppressed no matter what
|
* @type {object[]} Array of entries that need to be activated due to sticky
|
||||||
*/
|
*/
|
||||||
static externalSuppressions = [];
|
static stickyActivations = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {object[]} Array of entries that need to be suppressed due to cooldown
|
||||||
|
*/
|
||||||
|
static cooldownSuppressions = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {string[]} Array of messages sorted by ascending depth
|
* @type {string[]} Array of messages sorted by ascending depth
|
||||||
|
@ -270,12 +275,21 @@ class WorldInfoBuffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the current entry is externally suppressed.
|
* Check if the current entry is sticky activated.
|
||||||
* @param {object} entry WI entry to check
|
* @param {object} entry WI entry to check
|
||||||
* @returns {boolean} True if the entry is forcefully suppressed
|
* @returns {boolean} True if the entry is sticky activated
|
||||||
*/
|
*/
|
||||||
isExternallySuppressed(entry) {
|
isStickyActivated(entry) {
|
||||||
return WorldInfoBuffer.externalSuppressions.some(x => JSON.stringify(x) === JSON.stringify(entry));
|
return WorldInfoBuffer.stickyActivations.some(x => JSON.stringify(x) === JSON.stringify(entry));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the current entry is on cooldown.
|
||||||
|
* @param {object} entry WI entry to check
|
||||||
|
* @returns {boolean} True if the entry is suppressed by cooldown
|
||||||
|
*/
|
||||||
|
isOnCooldown(entry) {
|
||||||
|
return WorldInfoBuffer.cooldownSuppressions.some(x => JSON.stringify(x) === JSON.stringify(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -283,7 +297,8 @@ class WorldInfoBuffer {
|
||||||
*/
|
*/
|
||||||
resetExternalEffects() {
|
resetExternalEffects() {
|
||||||
WorldInfoBuffer.externalActivations.splice(0, WorldInfoBuffer.externalActivations.length);
|
WorldInfoBuffer.externalActivations.splice(0, WorldInfoBuffer.externalActivations.length);
|
||||||
WorldInfoBuffer.externalSuppressions.splice(0, WorldInfoBuffer.externalSuppressions.length);
|
WorldInfoBuffer.stickyActivations.splice(0, WorldInfoBuffer.stickyActivations.length);
|
||||||
|
WorldInfoBuffer.cooldownSuppressions.splice(0, WorldInfoBuffer.cooldownSuppressions.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2913,7 +2928,10 @@ async function checkWorldInfo(chat, maxContext, isDryRun) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer.isExternallySuppressed(entry)) {
|
const isSticky = buffer.isStickyActivated(entry);
|
||||||
|
const isCooldown = buffer.isOnCooldown(entry);
|
||||||
|
|
||||||
|
if (isCooldown && !isSticky) {
|
||||||
console.debug(`WI entry ${entry.uid} suppressed by external suppression`);
|
console.debug(`WI entry ${entry.uid} suppressed by external suppression`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2926,7 +2944,7 @@ async function checkWorldInfo(chat, maxContext, isDryRun) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.constant || buffer.isExternallyActivated(entry)) {
|
if (entry.constant || buffer.isExternallyActivated(entry) || isSticky) {
|
||||||
activatedNow.add(entry);
|
activatedNow.add(entry);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -3251,8 +3269,8 @@ function checkTimedEvents(chat, entries) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processEntries('sticky', WorldInfoBuffer.externalActivations);
|
processEntries('sticky', WorldInfoBuffer.stickyActivations);
|
||||||
processEntries('cooldown', WorldInfoBuffer.externalSuppressions);
|
processEntries('cooldown', WorldInfoBuffer.cooldownSuppressions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue