Expression Spy

shaynec1981

Veteran
Veteran
Joined
Jun 10, 2014
Messages
88
Reaction score
21
First Language
English
Primarily Uses
Expression Spy 1.1
Drykul
Introduction
While 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.

Features


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



Screenshots


How to Use


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

Demo
No 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
 
Last edited by a moderator:

Solis

Veteran
Veteran
Joined
Oct 24, 2015
Messages
376
Reaction score
84
First Language
English
Can find this super useful for testing. 
 

andai

Veteran
Veteran
Joined
Oct 19, 2014
Messages
54
Reaction score
26
First Language
English
Primarily Uses
This is actually so useful. Thanks!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

--Turn Based Battles--

Hero:
Look, it is Minotaur!
M. Knight: Let's go attack it!
Hero: Wait, no, it is just standing there!!
HUD Display: It is M. Knight's turn.
(M. Knight attacks Minotaur)
HUD Display: It is Minotaur's turn.
Hero: (Facepalms) Now look what you did! You made the Minotaur attack us!
Randomly deciding to create some tombs/sarcophagi last minute is probably not the best choice in a timed game jam...
There are only a few days left in our Spooktober Spooktacular Game Jam! Hope you are working hard to get your game in!
Where do i have to play Heisei Pistol Show the same creator that made Re: Kinder Parun
I really get the feeling I should be doing regular YouTube videos whenever I make something cool in my game, instead of waiting for massive changes. But not going to lie... I always feel like it's never quite enough to merit an update, until it's a drastic change. :kaoswt:

Forum statistics

Threads
104,558
Messages
1,007,132
Members
136,040
Latest member
Nicoh
Top