diff --git a/src/ts/process/infunctions.ts b/src/ts/process/infunctions.ts index 40dd0076..39b7e6c0 100644 --- a/src/ts/process/infunctions.ts +++ b/src/ts/process/infunctions.ts @@ -1,4 +1,4 @@ -import { getChatVar } from "../parser"; +import { getChatVar, getGlobalChatVar } from "../parser"; function toRPN(expression:string) { let outputQueue = ''; @@ -114,6 +114,13 @@ function executeRPNCalculation(text:string) { return "0" } return parsed.toString() + }).replace(/\@([a-zA-Z0-9_]+)/g, (_, p1) => { + const v = getGlobalChatVar(p1) + const parsed = parseFloat(v) + if(isNaN(parsed)){ + return "0" + } + return parsed.toString() }).replace(/&&/g, '&').replace(/\|\|/g, '|').replace(/<=/g, '≤').replace(/>=/g, '≥').replace(/==/g, '=').replace(/null/gi, '0') const expression = toRPN(text); const evaluated = calculateRPN(expression);