make MAX_LOOPS module wide
This commit is contained in:
parent
6337e0bbd6
commit
74d0ef5572
|
@ -2,6 +2,12 @@ import { chat_metadata, getCurrentChatId, saveSettingsDebounced, sendSystemMessa
|
||||||
import { extension_settings, saveMetadataDebounced } from './extensions.js';
|
import { extension_settings, saveMetadataDebounced } from './extensions.js';
|
||||||
import { executeSlashCommands, registerSlashCommand } from './slash-commands.js';
|
import { executeSlashCommands, registerSlashCommand } from './slash-commands.js';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const MAX_LOOPS = 100;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getLocalVariable(name, args = {}) {
|
function getLocalVariable(name, args = {}) {
|
||||||
if (!chat_metadata.variables) {
|
if (!chat_metadata.variables) {
|
||||||
chat_metadata.variables = {};
|
chat_metadata.variables = {};
|
||||||
|
@ -301,7 +307,6 @@ function listVariablesCallback() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function whileCallback(args, command) {
|
async function whileCallback(args, command) {
|
||||||
const MAX_LOOPS = 100;
|
|
||||||
const isGuardOff = ['off', 'false', '0'].includes(args.guard?.toLowerCase());
|
const isGuardOff = ['off', 'false', '0'].includes(args.guard?.toLowerCase());
|
||||||
const iterations = isGuardOff ? Number.MAX_SAFE_INTEGER : MAX_LOOPS;
|
const iterations = isGuardOff ? Number.MAX_SAFE_INTEGER : MAX_LOOPS;
|
||||||
|
|
||||||
|
@ -322,7 +327,6 @@ async function whileCallback(args, command) {
|
||||||
async function timesCallback(args, value) {
|
async function timesCallback(args, value) {
|
||||||
const [repeats, ...commandParts] = value.split(' ');
|
const [repeats, ...commandParts] = value.split(' ');
|
||||||
const command = commandParts.join(' ');
|
const command = commandParts.join(' ');
|
||||||
const MAX_LOOPS = 100;
|
|
||||||
const isGuardOff = ['off', 'false', '0'].includes(args.guard?.toLowerCase());
|
const isGuardOff = ['off', 'false', '0'].includes(args.guard?.toLowerCase());
|
||||||
const iterations = Math.min(Number(repeats), isGuardOff ? Number.MAX_SAFE_INTEGER : MAX_LOOPS);
|
const iterations = Math.min(Number(repeats), isGuardOff ? Number.MAX_SAFE_INTEGER : MAX_LOOPS);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue