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).