Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // ExpressionSpy.js v1.1
- //=============================================================================
- /*:
- * @plugindesc Updates selected expressions in real time in a separate window.
- * <id:Expression Spy>
- * @author Drykul
- *
- * @param Game Variables
- * @desc The $gameVariables to be monitored. Ex: 1, 2, 5, 15
- * @default
- *
- * @param Game Switches
- * @desc The $gameSwitches to be monitored. Ex: 1, 2, 5, 15
- * @default
- *
- * @param Custom Expressions
- * @desc Custom expressions to be monitored. Ex: $gameActors.actor(1).hp, myCustomVar, 1 + 2
- * @default
- *
- * @help
- * The custom expression field can be literally any expression you'd like to
- * monitor, including any calculations. Entries such as
- * $gameActors.actor(1).hp + $gameVariables.value(1)
- * will be accepted and evaluated.
- *
- * If you have any bugs to report, requests, or questions you can contact me
- * at drykul(at)cloud9studios.net. I'm also on www.rpgmakerweb.com and
- * www.rpgmakervxace.net as shaynec1981 as well as www.rpgmakermv.co as drykul.
- *
- * No credit is necessary for use of this script in either free
- * or commercial projects. Just shoot me a line and let me know if it was
- * worth your time! :)
- *
- * /~~CHANGE LOG~~/
- * 3-23-16: 1.1 release - changed update to Game_Screen
- * - fixed multiple expression spy windows being open at once
- * - expression spy window now won't open if no variables,
- * switches, or expressions are specified
- *
- * 3-22-16: 1.0 release
- */
- ////// Main function
- function expressionSpy() {
- if (typeof Scene_Map.prototype.expressionSpyWindow != 'undefined' && typeof Scene_Map.prototype.expressionSpyWindow.document != 'undefined') {
- Scene_Map.prototype.expressionSpyWindow.document.open();
- if (esVariablesArray[0] != "") {
- for (i = 0; i < esVariablesArray.length; i++) {
- Scene_Map.prototype.expressionSpyWindow.document.write("$gameVariables[" + esVariablesArray[i] + "] = " + $gameVariables.value(esVariablesArray[i]) + "<br>");
- };
- Scene_Map.prototype.expressionSpyWindow.document.write("---------------------------------------------------------------" + "<br>");
- };
- if (esSwitchesArray[0] != "") {
- for (i = 0; i < esSwitchesArray.length; i++) {
- Scene_Map.prototype.expressionSpyWindow.document.write("$gameSwitches[" + esSwitchesArray[i] + "] = " + $gameSwitches.value(esSwitchesArray[i]) + "<br>");
- };
- Scene_Map.prototype.expressionSpyWindow.document.write("---------------------------------------------------------------" + "<br>");
- };
- if (esExpressionsArray[0] != "") {
- for (i = 0; i < esExpressionsArray.length; i++) {
- try {
- Scene_Map.prototype.expressionSpyWindow.document.write(esExpressionsArray[i] + " = " + eval(esExpressionsArray[i]) + "<br>");
- } catch (err) {
- Scene_Map.prototype.expressionSpyWindow.document.write("Watched expression " + esExpressionsArray[i] + " does not exist!" + "<br>");
- };
- };
- };
- };
- };
- ////// Create variables and Expression Spy window
- var alis_SM_initialize = Scene_Map.prototype.initialize;
- Scene_Map.prototype.initialize = function () {
- var scriptParameters = $plugins.filter(function (p) {
- return p.description.contains("<id:Expression Spy>")
- })[0].parameters;
- esVariablesArray = scriptParameters['Game Variables'].split(",");
- for (i = 0; i < esVariablesArray.length; i++) {
- esVariablesArray[i] = esVariablesArray[i].trim();
- };
- esVariablesArray = uniq(esVariablesArray);
- esSwitchesArray = scriptParameters['Game Switches'].split(",");
- for (i = 0; i < esSwitchesArray.length; i++) {
- esSwitchesArray[i] = esSwitchesArray[i].trim();
- };
- esSwitchesArray = uniq(esSwitchesArray);
- esExpressionsArray = scriptParameters['Custom Expressions'].split(",");
- esExpressionsArray = uniq(esExpressionsArray);
- alis_SM_initialize.call(this);
- if (typeof Scene_Map.prototype.expressionSpyWindow != 'undefined') {
- Scene_Map.prototype.expressionSpyWindow.close();
- };
- if (scriptParameters['Game Variables'] != "" || scriptParameters['Game Switches'] != "" || scriptParameters['Custom Expressions'] != "") {
- Scene_Map.prototype.expressionSpyWindow = window.open();
- Scene_Map.prototype.expressionSpyWindow.resizeTo(800, 400);
- Scene_Map.prototype.expressionSpyWindow.moveTo(0, 300);
- require('nw.gui').Window.get().focus();
- };
- };
- ////// Call ExpressionSpy every update frame from Game_Screen
- var alias_GS_Update = Game_Screen.prototype.update;
- Game_Screen.prototype.update = function () {
- alias_GS_Update.call(this);
- expressionSpy();
- };
- ////// Remove duplicate entries from an array
- function uniq(a) {
- var seen = {};
- return a.filter(function (item) {
- return seen.hasOwnProperty(item) ? false : (seen[item] = true);
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement