Eval in Message Windows / Help Windows

Luxanna

Veteran
Veteran
Joined
Nov 8, 2015
Messages
67
Reaction score
23
First Language
English
Primarily Uses
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. :guffaw:
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
In the meantime, you could (ab)use variables for this:

Code:
$gameVariables.setValue(1, expression);
And use that via \V[1].
 

Luxanna

Veteran
Veteran
Joined
Nov 8, 2015
Messages
67
Reaction score
23
First Language
English
Primarily Uses
Thanks. That's one possibility for the message window but unfortunately it's no option for the help window... :(
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
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).
 
Last edited by a moderator:

Luxanna

Veteran
Veteran
Joined
Nov 8, 2015
Messages
67
Reaction score
23
First Language
English
Primarily Uses
That is brilliant, thank you so much! :guffaw:
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,037
Messages
1,018,464
Members
137,821
Latest member
Capterson
Top