Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*:
- * @plugindesc v1.00 Adds a new escape code, that allows to insert 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. "code" serves as a placeholder for the expression.
- * @default #{code}
- *
- * @help
- * After activating the plugin, you can use javascript inside text by surrounding it with the escape code defined in
- * the plugin parameter "Escape Code". So the following example:
- *
- * "Actor 1 has #{$gameActors.actors(1).atk} attack."
- *
- * Would show the attack value of actor number 1. The escape code has been made configurable, since it might already be
- * used by a different plugin and, depending on the javascript code used, some characters might not be usable.
- */
- (function ($, undefined) {
- "use strict";
- var _params = $plugins.filter(function (p) { return p.description.contains('<Iavra Text Eval>'); })[0].parameters;
- var _param_escapeCode = _params['Escape Code'];
- var _regex = new RegExp(_param_escapeCode.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&").replace('code', '([\\S\\s]+?)'), 'g');
- var alias_windowBase_convertEscapeCharacters = $.prototype.convertEscapeCharacters;
- Window_Base.prototype.convertEscapeCharacters = function (text) {
- return alias_windowBase_convertEscapeCharacters.call(this, text.replace(_regex, function (m, c) { return eval(c); }));
- };
- })(this.IAVRA || (this.IAVRA = {}));
Add Comment
Please, Sign In to add comment