[GH-ISSUE #5024] [Issue]: Add addnumvar macro for numeric variable addition #2776

Closed
opened 2026-10-21 05:55:18 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @SpicyMarinara on GitHub (Aug 14, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5024

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Add an {{addnumvar::name::value}} macro that performs numeric addition without changing the existing string-concatenation behavior of {{addvar}}.

Expected behavior

{{addnumvar::name::value}} should read the variable and value as numbers, add them, store the result back as a string, and return an empty string.

Actual behavior

{{addvar::name::value}} concatenates values as strings. For example, adding a modifier to a roll produces 20-2 instead of the numeric result 18, preventing subsequent numeric comparisons.

Steps to reproduce

  1. Set natroll to 20, modifier to 2, and final_result to natroll.
  2. Execute {{addvar::final_result::{{modifier}}}}.
  3. Read {{getvar::final_result}}.
  4. Observe that the result is a concatenated string such as 20-2 rather than the expected numeric result 18.

Environment

  • Marinara Engine version: 2.4.2 (commit 65c8ebc180)
  • Install type: Not provided
  • OS + version: Windows 10.0
  • Browser or app shell: Mozilla Firefox 153.0

Logs, screenshots, or video

Attached macro-engine.ts: https://cdn.discordapp.com/attachments/1537564144256028742/1537651206623862794/macro-engine.ts?ex=6a807987&is=6a7f2807&hm=7f8ea60a1aa82a25c99e234eceb61c764ebde3a6e60f912f45cf2163db0b40f4f4&. Attached image: https://cdn.discordapp.com/attachments/1537564144256028742/1537651206967529552/image.png?ex=6a807987&is=6a7f2807&hm=43dee54ee8c192c569bdeaf9fe5f3c4583a3539366054e97450276ac8cb0adb5&.

Additional context

The existing {{incvar::name}} and {{decvar::name}} macros only support increments or decrements of 1. The requested behavior mirrors SillyTavern's numeric addvar behavior while preserving Marinara's existing addvar behavior. The use case is adding dice-roll modifiers before comparing the result against a difficulty class. Marinara indicated that this can be added.

Discord thread: [FR] Add addnumvar macro for numeric variable addition
Discord thread link: https://discord.com/channels/1417099416812392641/1537564144256028742
Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653)

Discord thread transcript (5 messages)
[2026-08-13T20:50:58.551Z] ylliselmanii: Version: 2.4.2
Commit: 65c8ebc180ce
OS: Windows 10.0
Browser / app shell: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:153.0) Gecko/20100101 Firefox/153.0

My problem is this: {{addvar::name::value}} does string concatenation, not numeric addition. This makes arithmetic on variables (e.g. dice roll + modifier) pretty much impossible. {{incvar::name}} / {{decvar::name}} already exist, but they only do +1 / -1. The fact that its behaviour is different from ST's addvar has led to much confusion on my part.

My proposal is this: 
Add {{addnumvar::name::value}}. It simply reads the variable as a number, adds the value as a number, stores the result back as a string, returns empty string. Mirrors SillyTavern's addvar numeric behavior without breaking Marinara's existing addvar behavior -> and people's prompts with it.

Now, my use case is obviously very niche, but i don't think this is like feature bloat or anything, since it would just match SillyTavern's addvar or '+-' operator. And since ME has so much going on for it, I'm obviously not gonna switch to ST for a single thing, but I would be very glad if that was possible.

Could even do a PR myself, if you can't be bothered.
[Discord message: https://discord.com/channels/1417099416812392641/1537564144256028742/1537564144256028742]

[2026-08-13T21:07:41.113Z] ylliselmanii: My personal Use Case: maybe not relevant, but In my case, I'm doing a custom pre-processing agent that simply returns a DC and a modifier for a dice roll. Then in the Prompt Marker Section for the custom agent it looks something like this:
> {{agentoutput}} {{setvar::natroll::{{roll:1d20}}}}{{setvar::final_result::{{natroll}}}}{{addvar::final_result::{{modifier}}}} Natural Roll: {{natroll}} Final Roll: {{getvar::final_result}}.
 
For example, the modifier was set as 2, the roll came out as 20, but the Final Roll/final_result comes out as 20-2, instead of 18. This prevents me from doing a following {{#if final_result >=  dc}} success, or something like that. Addnumvar would simply do 'final_result + {{modifier}} -> 20 - 2 -> 18'. simple numeric addition. nothing else.
[Discord message: https://discord.com/channels/1417099416812392641/1537564144256028742/1537568349305831455]

[2026-08-13T23:15:10.891Z] Marinara: Later.
[Discord message: https://discord.com/channels/1417099416812392641/1537564144256028742/1537600434800296066]

[2026-08-14T02:36:55.991Z] ylliselmanii: fair, fair, fair. You do it when you feel it's right for ME. though, I did add it for myself personally, and if you're interested in seeing it: it's a tiny, tiny change, that worked for me so far.
[attached file: macro-engine.ts — https://cdn.discordapp.com/attachments/1537564144256028742/1537651206623862794/macro-engine.ts?ex=6a807987&is=6a7f2807&hm=7f8ea60a1aa82a25c99e234eceb61c764ebde3a6e60f912f45cf2163db0b40f4&]

[attached image 1: https://cdn.discordapp.com/attachments/1537564144256028742/1537651206967529552/image.png?ex=6a807987&is=6a7f2807&hm=43dee54ee8c192c569bdeaf9fe5f3c4583a3539366054e97450276ac8cb0adb5&]
[Discord message: https://discord.com/channels/1417099416812392641/1537564144256028742/1537651207269781565]

[2026-08-14T14:43:04.521Z] Marinara: Okay, can be added now.
[Discord message: https://discord.com/channels/1417099416812392641/1537564144256028742/1537833946929434665]

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @SpicyMarinara on GitHub (Aug 14, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5024 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Add an `{{addnumvar::name::value}}` macro that performs numeric addition without changing the existing string-concatenation behavior of `{{addvar}}`. ## Expected behavior `{{addnumvar::name::value}}` should read the variable and value as numbers, add them, store the result back as a string, and return an empty string. ## Actual behavior `{{addvar::name::value}}` concatenates values as strings. For example, adding a modifier to a roll produces `20-2` instead of the numeric result `18`, preventing subsequent numeric comparisons. ## Steps to reproduce 1. Set `natroll` to `20`, `modifier` to `2`, and `final_result` to `natroll`. 2. Execute `{{addvar::final_result::{{modifier}}}}`. 3. Read `{{getvar::final_result}}`. 4. Observe that the result is a concatenated string such as `20-2` rather than the expected numeric result `18`. ## Environment - Marinara Engine version: 2.4.2 (commit 65c8ebc180ce) - Install type: Not provided - OS + version: Windows 10.0 - Browser or app shell: Mozilla Firefox 153.0 ## Logs, screenshots, or video Attached `macro-engine.ts`: https://cdn.discordapp.com/attachments/1537564144256028742/1537651206623862794/macro-engine.ts?ex=6a807987&is=6a7f2807&hm=7f8ea60a1aa82a25c99e234eceb61c764ebde3a6e60f912f45cf2163db0b40f4f4&. Attached image: https://cdn.discordapp.com/attachments/1537564144256028742/1537651206967529552/image.png?ex=6a807987&is=6a7f2807&hm=43dee54ee8c192c569bdeaf9fe5f3c4583a3539366054e97450276ac8cb0adb5&. ## Additional context The existing `{{incvar::name}}` and `{{decvar::name}}` macros only support increments or decrements of 1. The requested behavior mirrors SillyTavern's numeric addvar behavior while preserving Marinara's existing `addvar` behavior. The use case is adding dice-roll modifiers before comparing the result against a difficulty class. Marinara indicated that this can be added. Discord thread: [FR] Add addnumvar macro for numeric variable addition Discord thread link: https://discord.com/channels/1417099416812392641/1537564144256028742 Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653) <details> <summary>Discord thread transcript (5 messages)</summary> ```text [2026-08-13T20:50:58.551Z] ylliselmanii: Version: 2.4.2 Commit: 65c8ebc180ce OS: Windows 10.0 Browser / app shell: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:153.0) Gecko/20100101 Firefox/153.0 My problem is this: {{addvar::name::value}} does string concatenation, not numeric addition. This makes arithmetic on variables (e.g. dice roll + modifier) pretty much impossible. {{incvar::name}} / {{decvar::name}} already exist, but they only do +1 / -1. The fact that its behaviour is different from ST's addvar has led to much confusion on my part. My proposal is this: Add {{addnumvar::name::value}}. It simply reads the variable as a number, adds the value as a number, stores the result back as a string, returns empty string. Mirrors SillyTavern's addvar numeric behavior without breaking Marinara's existing addvar behavior -> and people's prompts with it. Now, my use case is obviously very niche, but i don't think this is like feature bloat or anything, since it would just match SillyTavern's addvar or '+-' operator. And since ME has so much going on for it, I'm obviously not gonna switch to ST for a single thing, but I would be very glad if that was possible. Could even do a PR myself, if you can't be bothered. [Discord message: https://discord.com/channels/1417099416812392641/1537564144256028742/1537564144256028742] [2026-08-13T21:07:41.113Z] ylliselmanii: My personal Use Case: maybe not relevant, but In my case, I'm doing a custom pre-processing agent that simply returns a DC and a modifier for a dice roll. Then in the Prompt Marker Section for the custom agent it looks something like this: > {{agentoutput}} {{setvar::natroll::{{roll:1d20}}}}{{setvar::final_result::{{natroll}}}}{{addvar::final_result::{{modifier}}}} Natural Roll: {{natroll}} Final Roll: {{getvar::final_result}}. For example, the modifier was set as 2, the roll came out as 20, but the Final Roll/final_result comes out as 20-2, instead of 18. This prevents me from doing a following {{#if final_result >= dc}} success, or something like that. Addnumvar would simply do 'final_result + {{modifier}} -> 20 - 2 -> 18'. simple numeric addition. nothing else. [Discord message: https://discord.com/channels/1417099416812392641/1537564144256028742/1537568349305831455] [2026-08-13T23:15:10.891Z] Marinara: Later. [Discord message: https://discord.com/channels/1417099416812392641/1537564144256028742/1537600434800296066] [2026-08-14T02:36:55.991Z] ylliselmanii: fair, fair, fair. You do it when you feel it's right for ME. though, I did add it for myself personally, and if you're interested in seeing it: it's a tiny, tiny change, that worked for me so far. [attached file: macro-engine.ts — https://cdn.discordapp.com/attachments/1537564144256028742/1537651206623862794/macro-engine.ts?ex=6a807987&is=6a7f2807&hm=7f8ea60a1aa82a25c99e234eceb61c764ebde3a6e60f912f45cf2163db0b40f4&] [attached image 1: https://cdn.discordapp.com/attachments/1537564144256028742/1537651206967529552/image.png?ex=6a807987&is=6a7f2807&hm=43dee54ee8c192c569bdeaf9fe5f3c4583a3539366054e97450276ac8cb0adb5&] [Discord message: https://discord.com/channels/1417099416812392641/1537564144256028742/1537651207269781565] [2026-08-14T14:43:04.521Z] Marinara: Okay, can be added now. [Discord message: https://discord.com/channels/1417099416812392641/1537564144256028742/1537833946929434665] ``` </details> ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:55:18 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2776
No description provided.