mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-02 10:57:45 +01:00
Fix group weight clamping
This commit is contained in:
parent
5e7c214c89
commit
542018cecb
@ -5256,7 +5256,7 @@
|
|||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="range-block-range">
|
<div class="range-block-range">
|
||||||
<input type="number" class="text_pole margin0" name="groupWeight" rows="1" placeholder="100" min="0" max="999999">
|
<input type="number" class="text_pole margin0" name="groupWeight" rows="1" placeholder="100" min="1" max="999999">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1478,13 +1478,24 @@ function getWorldEntry(name, data, entry) {
|
|||||||
groupWeightInput.data('uid', entry.uid);
|
groupWeightInput.data('uid', entry.uid);
|
||||||
groupWeightInput.on('input', function () {
|
groupWeightInput.on('input', function () {
|
||||||
const uid = $(this).data('uid');
|
const uid = $(this).data('uid');
|
||||||
const value = Number($(this).val());
|
let value = Number($(this).val());
|
||||||
|
const min = Number($(this).attr('min'));
|
||||||
|
const max = Number($(this).attr('max'));
|
||||||
|
|
||||||
data.entries[uid].groupWeight = !isNaN(value) ? Math.abs(value) : 0;
|
// Clamp the value
|
||||||
|
if (value < min) {
|
||||||
|
value = min;
|
||||||
|
$(this).val(min);
|
||||||
|
} else if (value > max) {
|
||||||
|
value = max;
|
||||||
|
$(this).val(max);
|
||||||
|
}
|
||||||
|
|
||||||
|
data.entries[uid].groupWeight = !isNaN(value) ? Math.abs(value) : 1;
|
||||||
setOriginalDataValue(data, uid, 'extensions.group_weight', data.entries[uid].groupWeight);
|
setOriginalDataValue(data, uid, 'extensions.group_weight', data.entries[uid].groupWeight);
|
||||||
saveWorldInfo(name, data);
|
saveWorldInfo(name, data);
|
||||||
});
|
});
|
||||||
groupWeightInput.val(entry.groupWeight).trigger('input');
|
groupWeightInput.val(entry.groupWeight ?? DEFAULT_WEIGHT).trigger('input');
|
||||||
|
|
||||||
// probability
|
// probability
|
||||||
if (entry.probability === undefined) {
|
if (entry.probability === undefined) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user