mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Adjust /while to fit new optional args
This commit is contained in:
@ -1342,18 +1342,19 @@ export function registerVariableCommands() {
|
|||||||
typeList: [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER],
|
typeList: [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER],
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
enumProvider: commonEnumProviders.variables('all'),
|
enumProvider: commonEnumProviders.variables('all'),
|
||||||
forceEnum: false,
|
|
||||||
}),
|
}),
|
||||||
SlashCommandNamedArgument.fromProps({
|
SlashCommandNamedArgument.fromProps({
|
||||||
name: 'right',
|
name: 'right',
|
||||||
description: 'right operand',
|
description: 'right operand',
|
||||||
typeList: [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER],
|
typeList: [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER],
|
||||||
isRequired: true,
|
|
||||||
enumProvider: commonEnumProviders.variables('all'),
|
enumProvider: commonEnumProviders.variables('all'),
|
||||||
forceEnum: false,
|
|
||||||
}),
|
}),
|
||||||
new SlashCommandNamedArgument(
|
SlashCommandNamedArgument.fromProps({
|
||||||
'rule', 'comparison rule', [ARGUMENT_TYPE.STRING], true, false, null, [
|
name: 'rule',
|
||||||
|
description: 'comparison rule',
|
||||||
|
typeList: [ARGUMENT_TYPE.STRING],
|
||||||
|
defaultValue: 'eq',
|
||||||
|
enumList: [
|
||||||
new SlashCommandEnumValue('gt', 'a > b'),
|
new SlashCommandEnumValue('gt', 'a > b'),
|
||||||
new SlashCommandEnumValue('gte', 'a >= b'),
|
new SlashCommandEnumValue('gte', 'a >= b'),
|
||||||
new SlashCommandEnumValue('lt', 'a < b'),
|
new SlashCommandEnumValue('lt', 'a < b'),
|
||||||
@ -1364,10 +1365,15 @@ export function registerVariableCommands() {
|
|||||||
new SlashCommandEnumValue('in', 'a includes b'),
|
new SlashCommandEnumValue('in', 'a includes b'),
|
||||||
new SlashCommandEnumValue('nin', 'a not includes b'),
|
new SlashCommandEnumValue('nin', 'a not includes b'),
|
||||||
],
|
],
|
||||||
),
|
forceEnum: true,
|
||||||
new SlashCommandNamedArgument(
|
}),
|
||||||
'guard', 'disable loop iteration limit', [ARGUMENT_TYPE.STRING], false, false, null, commonEnumProviders.boolean('onOff')(),
|
SlashCommandNamedArgument.fromProps({
|
||||||
),
|
name: 'guard',
|
||||||
|
description: 'disable loop iteration limit',
|
||||||
|
typeList: [ARGUMENT_TYPE.STRING],
|
||||||
|
defaultValue: 'off',
|
||||||
|
enumList: commonEnumProviders.boolean('onOff')(),
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
new SlashCommandArgument(
|
new SlashCommandArgument(
|
||||||
@ -1404,6 +1410,10 @@ export function registerVariableCommands() {
|
|||||||
<pre><code class="language-stscript">/setvar key=i 0 | /while left=i right=10 rule=lte "/addvar key=i 1"</code></pre>
|
<pre><code class="language-stscript">/setvar key=i 0 | /while left=i right=10 rule=lte "/addvar key=i 1"</code></pre>
|
||||||
adds 1 to the value of "i" until it reaches 10.
|
adds 1 to the value of "i" until it reaches 10.
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<pre><code class="language-stscript">/while left={{getvar::currentword}} {: /setvar key=currentword {: /do-something-and-return :}() | /echo The current work is "{{getvar::currentword}}" :}</code></pre>
|
||||||
|
executes the defined subcommand as long as the "currentword" variable is truthy (has any content that is not false/empty)
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
Reference in New Issue
Block a user