Eval in Message Windows / Help Windows

Hi!

I'd like to request a Plugin that evaluates a formula in message/help windows. This would mainly be used in Help Windows to convert things like

"50% MAT" to an actual value.

Thanks in advance. 🤣
In the meantime, you could (ab)use variables for this:

Code:
$gameVariables.setValue(1, expression);
And use that via \V[1].
Thanks. That's one possibility for the message window but unfortunately it's no option for the help window... 🙁
You could try this one:


/*:
* @plugindesc Adds a new escape code, that allows to isert arbitrary script calls inside text (for example messages).
* <Iavra Text Eval>
* @author Iavra
*
* @param Escape Code
* @desc Code to be used to insert evaluated expressions. {eval} serves as a placeholder for the expression.
* @default #{{eval}}
*/
(function ($) {
"use strict";

var _params = $plugins.filter(function (p) { return p.description.contains('<Iavra Text Eval>'); })[0].parameters;
var _param_escape = _params['Escape Code'];

var _eval = new RegExp(_param_escape.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&").replace('\\{eval\\}', '([\\S\\s]+?)'), 'g');

var alias_convertEscapeCharacters = $.prototype.convertEscapeCharacters;
$.prototype.convertEscapeCharacters = function (text) {
return alias_convertEscapeCharacters.call(this, text.replace(_eval, function (m, c) { return eval(c); }));
};

})(Window_Base);


Regarding the parameter, by default "#{$gameVariables.value(1)}" would be replaced with variable 1. I made it configurable, because depending on the escape code, some script calls might not work (because they will be interpreted as part of the escape code).
That is brilliant, thank you so much! 🤣

Original thread: https://forums.rpgmakerweb.com/threads/eval-in-message-windows-help-windows.53831/