shaynec1981 32 Posted March 22, 2016 (edited) Expression Spy 1.1DrykulIntroductionWhile developing I thought it would be useful to be able to view variables, switches, and other custom expressions, variables, arrays, etc in real time as opposed to needing to pause gameplay through the console. Thus I set out to create a plug-in to do just this.FeaturesA dedicated window will open and keep you informed of what the monitored values are. Add as many as you'd like separated by commas in the plug-in parameters. ScreenshotsHow to UseSimply set the built in game variables you'd like to monitor separated by commas. The same with game switches. And lastly, enter any expression you'd like to monitor as well.DemoNo demo. If requested I will upload one.Script //============================================================================= // 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 + "] = " + $gameVariables.value(esVariablesArray) + "<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 + "] = " + $gameSwitches.value(esSwitchesArray) + "<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 + " = " + eval(esExpressionsArray) + "<br>"); } catch (err) { Scene_Map.prototype.expressionSpyWindow.document.write("Watched expression " + esExpressionsArray + " 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 = esVariablesArray.trim(); }; esVariablesArray = uniq(esVariablesArray); esSwitchesArray = scriptParameters['Game Switches'].split(","); for (i = 0; i < esSwitchesArray.length; i++) { esSwitchesArray = esSwitchesArray.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); }); }; FAQNone yet.Credit and Thanks- Drykul - Shadowarc82 Edited March 22, 2016 by shaynec1981 Share this post Link to post Share on other sites