mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Update /mul, /max and /min definition
- Update command definition for /mul, /max and /min to fit the actual code behind, split them too - Add numbersAndVariables enum provider, to centralize
This commit is contained in:
@ -152,6 +152,35 @@ export const commonEnumProviders = {
|
|||||||
].filter((item, idx, list)=>idx == list.findIndex(it=>it.value == item.value));
|
].filter((item, idx, list)=>idx == list.findIndex(it=>it.value == item.value));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum values for numbers and variable names
|
||||||
|
*
|
||||||
|
* Includes all variable names and the ability to specify any number
|
||||||
|
*
|
||||||
|
* @param {SlashCommandExecutor} executor - The executor of the slash command
|
||||||
|
* @param {SlashCommandScope} scope - The scope of the slash command
|
||||||
|
* @returns {SlashCommandEnumValue[]} The enum values
|
||||||
|
*/
|
||||||
|
numbersAndVariables: (executor, scope) => [
|
||||||
|
...commonEnumProviders.variables('all')(executor, scope),
|
||||||
|
new SlashCommandEnumValue(
|
||||||
|
'any variable name',
|
||||||
|
null,
|
||||||
|
enumTypes.variable,
|
||||||
|
enumIcons.variable,
|
||||||
|
(input) => /^\w*$/.test(input),
|
||||||
|
(input) => input,
|
||||||
|
),
|
||||||
|
new SlashCommandEnumValue(
|
||||||
|
'any number',
|
||||||
|
null,
|
||||||
|
enumTypes.number,
|
||||||
|
enumIcons.number,
|
||||||
|
(input) => input == '' || !Number.isNaN(Number(input)),
|
||||||
|
(input) => input,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All possible char entities, like characters and groups. Can be filtered down to just one type.
|
* All possible char entities, like characters and groups. Can be filtered down to just one type.
|
||||||
*
|
*
|
||||||
|
@ -1602,28 +1602,7 @@ export function registerVariableCommands() {
|
|||||||
typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
|
typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
acceptsMultiple: true,
|
acceptsMultiple: true,
|
||||||
enumProvider: (executor, scope) => {
|
enumProvider: commonEnumProviders.numbersAndVariables,
|
||||||
const vars = commonEnumProviders.variables('all')(executor, scope);
|
|
||||||
vars.push(
|
|
||||||
new SlashCommandEnumValue(
|
|
||||||
'any variable name',
|
|
||||||
null,
|
|
||||||
enumTypes.variable,
|
|
||||||
enumIcons.variable,
|
|
||||||
(input) => /^\w*$/.test(input),
|
|
||||||
(input) => input,
|
|
||||||
),
|
|
||||||
new SlashCommandEnumValue(
|
|
||||||
'any number',
|
|
||||||
null,
|
|
||||||
enumTypes.number,
|
|
||||||
enumIcons.number,
|
|
||||||
(input) => input == '' || !Number.isNaN(Number(input)),
|
|
||||||
(input) => input,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return vars;
|
|
||||||
},
|
|
||||||
forceEnum: false,
|
forceEnum: false,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
@ -1653,10 +1632,11 @@ export function registerVariableCommands() {
|
|||||||
typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
|
typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
acceptsMultiple: true,
|
acceptsMultiple: true,
|
||||||
enumProvider: commonEnumProviders.variables('all'),
|
enumProvider: commonEnumProviders.numbersAndVariables,
|
||||||
forceEnum: false,
|
forceEnum: false,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
splitUnnamedArgument: true,
|
||||||
helpString: `
|
helpString: `
|
||||||
<div>
|
<div>
|
||||||
Performs a multiplication of the set of values and passes the result down the pipe. Can use variable names.
|
Performs a multiplication of the set of values and passes the result down the pipe. Can use variable names.
|
||||||
@ -1681,10 +1661,11 @@ export function registerVariableCommands() {
|
|||||||
typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
|
typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
acceptsMultiple: true,
|
acceptsMultiple: true,
|
||||||
enumProvider: commonEnumProviders.variables('all'),
|
enumProvider: commonEnumProviders.numbersAndVariables,
|
||||||
forceEnum: false,
|
forceEnum: false,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
splitUnnamedArgument: true,
|
||||||
helpString: `
|
helpString: `
|
||||||
<div>
|
<div>
|
||||||
Returns the maximum value of the set of values and passes the result down the pipe. Can use variable names.
|
Returns the maximum value of the set of values and passes the result down the pipe. Can use variable names.
|
||||||
@ -1709,10 +1690,11 @@ export function registerVariableCommands() {
|
|||||||
typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
|
typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
acceptsMultiple: true,
|
acceptsMultiple: true,
|
||||||
enumProvider: commonEnumProviders.variables('all'),
|
enumProvider: commonEnumProviders.numbersAndVariables,
|
||||||
forceEnum: false,
|
forceEnum: false,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
splitUnnamedArgument: true,
|
||||||
helpString: `
|
helpString: `
|
||||||
<div>
|
<div>
|
||||||
Returns the minimum value of the set of values and passes the result down the pipe.
|
Returns the minimum value of the set of values and passes the result down the pipe.
|
||||||
|
Reference in New Issue
Block a user