Run mutating variable macros first

293d6ff60d026f9cde7757cc83d5fda7e244ca13

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

1 files changed, +6 -7Ignore whitespace
public/scripts/variables.js+6 -7
@@ -224,12 +224,11 @@ export function resolveVariable(name, scope = null) {
224224}
225225
226226/**
227+ * Returns built-in variable macros.
227228 * @returns {import('./macros.js').Macro[]}
228229 */
229230export function getVariableMacros() {
230231 const macros =return [
231- // Replace {{getvar::name}} with the value of the variable name
232- { regex: /{{getvar::([^}]+)}}/gi, replace: (_, name) => getLocalVariable(name.trim()) },
233232 // Replace {{setvar::name::value}} with empty string and set the variable name to value
234233 { regex: /{{setvar::([^:]+)::([^}]+)}}/gi, replace: (_, name, value) => { setLocalVariable(name.trim(), value); return ''; } },
235234 // Replace {{addvar::name::value}} with empty string and add value to the variable value
@@ -238,8 +237,8 @@ export function getVariableMacros() {
238237 { regex: /{{incvar::([^}]+)}}/gi, replace: (_, name) => incrementLocalVariable(name.trim()) },
239238 // Replace {{decvar::name}} with empty string and decrement the variable name by 1
240239 { regex: /{{decvar::([^}]+)}}/gi, replace: (_, name) => decrementLocalVariable(name.trim()) },
241240 // Replace {{getglobalvargetvar::name}} with the value of the global variable name
242241 { regex: /{{getglobalvargetvar::([^}]+)}}/gi, replace: (_, name) => getGlobalVariablegetLocalVariable(name.trim()) },
243242 // Replace {{setglobalvar::name::value}} with empty string and set the global variable name to value
244243 { regex: /{{setglobalvar::([^:]+)::([^}]+)}}/gi, replace: (_, name, value) => { setGlobalVariable(name.trim(), value); return ''; } },
245244 // Replace {{addglobalvar::name::value}} with empty string and add value to the global variable value
@@ -248,9 +247,9 @@ export function getVariableMacros() {
248247 { regex: /{{incglobalvar::([^}]+)}}/gi, replace: (_, name) => incrementGlobalVariable(name.trim()) },
249248 // Replace {{decglobalvar::name}} with empty string and decrement the global variable name by 1
250249 { regex: /{{decglobalvar::([^}]+)}}/gi, replace: (_, name) => decrementGlobalVariable(name.trim()) },
250+ // Replace {{getglobalvar::name}} with the value of the global variable name
251+ { regex: /{{getglobalvar::([^}]+)}}/gi, replace: (_, name) => getGlobalVariable(name.trim()) },
251252 ];
252-
253- return macros;
254253}
255254
256255async function listVariablesCallback(args) {