mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add custom dice roll
This commit is contained in:
@@ -1336,7 +1336,14 @@ async function Generate(type, automatic_trigger, force_name2) {
|
||||
|
||||
let hordeAmountGen = null;
|
||||
if (main_api == 'kobold' && horde_settings.use_horde && horde_settings.auto_adjust) {
|
||||
const adjustedParams = await adjustHordeGenerationParams(this_max_context, amount_gen);
|
||||
let adjustedParams;
|
||||
try {
|
||||
adjustedParams = await adjustHordeGenerationParams(this_max_context, amount_gen);
|
||||
}
|
||||
catch {
|
||||
activateSendButtons();
|
||||
return;
|
||||
}
|
||||
this_max_context = adjustedParams.maxContextLength;
|
||||
hordeAmountGen = adjustedParams.maxLength;
|
||||
}
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { callPopup } from "../../../script.js";
|
||||
import { getContext } from "../../extensions.js";
|
||||
export { MODULE_NAME };
|
||||
|
||||
@@ -10,8 +11,13 @@ function setDiceIcon() {
|
||||
sendButton.classList.remove('spin');
|
||||
}
|
||||
|
||||
function doDiceRoll() {
|
||||
const value = $(this).data('value');
|
||||
async function doDiceRoll() {
|
||||
let value = $(this).data('value');
|
||||
|
||||
if (value == 'custom') {
|
||||
value = await callPopup('Enter the dice formula:<br><i>(for example, <tt>2d6</tt>)</i>', 'input');
|
||||
}
|
||||
|
||||
const isValid = droll.validate(value);
|
||||
|
||||
if (isValid) {
|
||||
@@ -33,6 +39,7 @@ function addDiceRollButton() {
|
||||
<li class="list-group-item" data-value="d12">d12</li>
|
||||
<li class="list-group-item" data-value="d20">d20</li>
|
||||
<li class="list-group-item" data-value="d100">d100</li>
|
||||
<li class="list-group-item" data-value="custom">...</li>
|
||||
</ul>
|
||||
</div>
|
||||
`;
|
||||
|
Reference in New Issue
Block a user