Merge pull request #4305 from SillyTavern/feat/allow-empty-setvar Allow empty values in {{setvar/setglobalvar}}

6224e20cbe1eb01ad2aa56c1f6c8068c8dc26bf2

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
1 files changed, +2 -2Ignore whitespace
public/scripts/variables.js+2 -2
@@ -238,7 +238,7 @@ export function resolveVariable(name, scope = null) {
238export function getVariableMacros() {238export function getVariableMacros() {
239 return [239 return [
240 // Replace {{setvar::name::value}} with empty string and set the variable name to value240 // Replace {{setvar::name::value}} with empty string and set the variable name to value
241 { regex: /{{setvar::([^:]+)::([^}]+)}}/gi, replace: (_, name, value) => { setLocalVariable(name.trim(), value); return ''; } },241 { regex: /{{setvar::([^:]+)::([^}]*)}}/gi, replace: (_, name, value) => { setLocalVariable(name.trim(), value); return ''; } },
242 // Replace {{addvar::name::value}} with empty string and add value to the variable value242 // Replace {{addvar::name::value}} with empty string and add value to the variable value
243 { regex: /{{addvar::([^:]+)::([^}]+)}}/gi, replace: (_, name, value) => { addLocalVariable(name.trim(), value); return ''; } },243 { regex: /{{addvar::([^:]+)::([^}]+)}}/gi, replace: (_, name, value) => { addLocalVariable(name.trim(), value); return ''; } },
244 // Replace {{incvar::name}} with empty string and increment the variable name by 1244 // Replace {{incvar::name}} with empty string and increment the variable name by 1
@@ -248,7 +248,7 @@ export function getVariableMacros() {
248 // Replace {{getvar::name}} with the value of the variable name248 // Replace {{getvar::name}} with the value of the variable name
249 { regex: /{{getvar::([^}]+)}}/gi, replace: (_, name) => getLocalVariable(name.trim()) },249 { regex: /{{getvar::([^}]+)}}/gi, replace: (_, name) => getLocalVariable(name.trim()) },
250 // Replace {{setglobalvar::name::value}} with empty string and set the global variable name to value250 // Replace {{setglobalvar::name::value}} with empty string and set the global variable name to value
251 { regex: /{{setglobalvar::([^:]+)::([^}]+)}}/gi, replace: (_, name, value) => { setGlobalVariable(name.trim(), value); return ''; } },251 { regex: /{{setglobalvar::([^:]+)::([^}]*)}}/gi, replace: (_, name, value) => { setGlobalVariable(name.trim(), value); return ''; } },
252 // Replace {{addglobalvar::name::value}} with empty string and add value to the global variable value252 // Replace {{addglobalvar::name::value}} with empty string and add value to the global variable value
253 { regex: /{{addglobalvar::([^:]+)::([^}]+)}}/gi, replace: (_, name, value) => { addGlobalVariable(name.trim(), value); return ''; } },253 { regex: /{{addglobalvar::([^:]+)::([^}]+)}}/gi, replace: (_, name, value) => { addGlobalVariable(name.trim(), value); return ''; } },
254 // Replace {{incglobalvar::name}} with empty string and increment the global variable name by 1254 // Replace {{incglobalvar::name}} with empty string and increment the global variable name by 1