Thx Poryg. I'm going nuts trying to find an answer to this prob... (even going to the CodeAcademy to review JS), & think I'm gonna have to rework this / start over. On the surface it seems logical & easy to me... but I'm also basing the logic on my knowledge of C#.... JS is a new beast to me (& among other things, the .prototype thing seems strange to me).
I think I see where I'm goofing this up, tho (outside of the pt you made of the wrong [], which I placed by mistake as I was typing the example ). I'm trying to use a switch to, more or less, "disable" the script, when, I think, that is impossible in MV (assuming it runs & saves plugin data every [x] ticks / seconds, & the absence of the data would corrupt the game &/or player save). Instead, I think I'm gonna have to find a way to just hide the window when either a defined switch or variable is active.
I've exhausted all of the ideas I have about how to do this (e.g. vid tutorials, sample scripts, etc.). Could you pt me in the right direction, Poryg (or any good Samaritan)?
Here's the script, as it currently is... (now where the heck does the "switch condition" go?, lol)
P.S. The plugin works GREAT... but there are game scenes where the clock needs to be hidden (e.g. cutscenes, lol), so that it isn't persistently visible. And for any willing to help me... plz bear with me. I'm an old school C++ & C# coder, so JS is new territory to me, & I am trying the best I can, (via my own research of the topic &/or probs I have, etc.).
Code:
(function() {
//-----------------------------------------------------------------------------
// Scene Map
//-----------------------------------------------------------------------------
var _Scene_Map_start = Scene_Map.prototype.start;
Scene_Map.prototype.start = function() {
_Scene_Map_start.call(this);
this.clockWindow = new DEP_WorldClock(1120, 0);
this.addWindow(this.clockWindow);
};
var _Scene_Map_update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function() {
_Scene_Map_update.call(this);
this.clockWindow.refresh();
};
//-----------------------------------------------------------------------------
// Clock Window
//-----------------------------------------------------------------------------
function DEP_WorldClock() {
this.initialize.apply(this, arguments);
};
DEP_WorldClock.prototype = Object.create(Window_Base.prototype);
DEP_WorldClock.prototype.constructor = DEP_WorldClock;
DEP_WorldClock.prototype.initialize = function(x, y) {
Window_Base.prototype.initialize.call(this, x, y, this.windowWidth(), this.windowHeight());
this._hour = -1;
this.refresh();
};
DEP_WorldClock.prototype.refresh = function() {
if(this._hour != $gameVariables.value(979)) {
this._hour = $gameVariables.value(979);
this.contents.clear();
this.drawIcon(35, 0, 0);
this.drawText(this._hour + ':00', Window_Base._iconWidth + 8, 0, this.windowWidth() - (Window_Base._iconWidth + 8), 'left');
}
};
DEP_WorldClock.prototype.windowWidth = function() {
return 160;
};
DEP_WorldClock.prototype.windowHeight = function() {
return this.fittingHeight(1);
};
})();