From 7a48177ce617c66cb5fecfd5886f21cf8be7e74a Mon Sep 17 00:00:00 2001 From: JustAGenericUsername <92590792+JustAGenericUsername@users.noreply.github.com> Date: Sun, 30 Mar 2025 16:51:30 -0400 Subject: [PATCH] nested variable signs --- mods/nousersthings.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mods/nousersthings.js b/mods/nousersthings.js index 161d9d2c..c7a5bc7b 100644 --- a/mods/nousersthings.js +++ b/mods/nousersthings.js @@ -3939,12 +3939,18 @@ renderPostPixel(function(ctx){ if ((pixel.element == "sign") && pixel.sign){ ctx.font = `12pt Arial` ctx.fillStyle = pixel.color; - ctx.fillText(pixel.sign.replace(/\$\{(\w+)\}/g, (_, k) => globalThis[k] ?? ''), canvasCoord(pixel.x), canvasCoord(pixel.y)) + ctx.fillText(pixel.sign.replace(/\$\{([\w.]+)\}/g, (_, path) => { + const value = path.split('.').reduce((obj, key) => obj?.[key], globalThis); + return typeof value === 'object' ? JSON.stringify(value) : value ?? ''; + }), canvasCoord(pixel.x), canvasCoord(pixel.y)) } else if (pixel.element == "e_sign" && pixel.sign){ if (pixel.charge || pixel.chargeCD){ ctx.font = `12pt Arial` ctx.fillStyle = pixel.color; - ctx.fillText(pixel.sign.replace(/\$\{(\w+)\}/g, (_, k) => globalThis[k] ?? ''), canvasCoord(pixel.x), canvasCoord(pixel.y)) + ctx.fillText(pixel.sign.replace(/\$\{([\w.]+)\}/g, (_, path) => { + const value = path.split('.').reduce((obj, key) => obj?.[key], globalThis); + return typeof value === 'object' ? JSON.stringify(value) : value ?? ''; + }), canvasCoord(pixel.x), canvasCoord(pixel.y)) } else { drawSquare(ctx, pixel.color, pixel.x, pixel.y) }