Howto make a basic window

For display on the map itself. This is as far as I got:

function Window_DashStamina() { this.initialize.apply(this, arguments); }
// Inherit from base window
Window_DashStamina.prototype = Object.create(Window_Base.prototype);
// Set Constructor
Window_DashStamina.prototype.constructor = Window_DashStamina;

// Constructor
Window_DashStamina.prototype.initialize = function(x, y, width, height) {
    Window_Base.prototype.initialize.call(this, x, y, width, height);
    this._helpWindow = null;
    this._handlers = {};
    this._touching = false;
    this.deactivate();
    alert('window created');
};

// Update
Window_DashStamina.prototype.update = function() {
    Window_Base.prototype.update.call(this);
    console.log('updating'); // Erm... How do I hook this into the window_base update without an alias (because we inherit from Window_Base)... This is never called.
    // Update stamina bar
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var alias_SceneMapOnMapLoaded = Scene_Map.prototype.onMapLoaded;
Scene_Map.prototype.onMapLoaded = function() {
    alias_SceneMapOnMapLoaded.apply(this, arguments);
    this.dashStaminaWindow = new Window_DashStamina(10,10,100,64);
}
There is no error, but also no window... The alert message in the constructor is shown so the window is created.

Also the update method is never called.

Also I suppose that I have to dispose or close the window in Scene_Map.prototype.terminate to prevent memory leaks?

But I think windows don't update themselves. Meaning I probably have to alias the update method in the scenemanager and make it update my window.
Doesn't look like your doe is drawing anything, i put a few things in but I don't know what you are trying to display.

Spoiler
Code:
function Window_DashStamina() { this.initialize.apply(this, arguments); }// Inherit from base windowWindow_DashStamina.prototype = Object.create(Window_Base.prototype);// Set ConstructorWindow_DashStamina.prototype.constructor = Window_DashStamina;// ConstructorWindow_DashStamina.prototype.initialize = function(x, y, width, height) {    var width = this.windowWidth();    var height = this.windowHeight();    Window_Base.prototype.initialize.call(this, x, y, width, height);    this._helpWindow = null;    this._handlers = {};    this._touching = false;    this.deactivate();    alert('window created');     this.update();};// UpdateWindow_DashStamina.prototype.update = function() {    Window_Base.prototype.update.call(this);      this.contents.clear();    this.drawStaminaWindow( 0, 0, width);    console.log('updating'); // Erm... How do I hook this into the window_base update without an alias (because we inherit from Window_Base)... This is never called.    // Update stamina bar};Window_DashStamina.prototype.drawStaminaWindow = function( x, y, width) {    var unitWidth = Math.min(80);    this.resetTextColor();    this.drawText("something", x, y, width, 'left');    this.changeTextColor(this.systemColor());   };//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////var alias_SceneMapOnMapLoaded = Scene_Map.prototype.onMapLoaded;Scene_Map.prototype.onMapLoaded = function() {    alias_SceneMapOnMapLoaded.apply(this, arguments);    this.dashStaminaWindow = new Window_DashStamina(10,10,100,64);}
Just a basic window with "Hello world" would be great.

this.windowWidth(); is from Window_Command and not from Window_Base.

I added the drawing to the window (even though I assumed a window would always draw itself or atleast it's skin) but still no visible window at all. Also no errors:

Spoiler
Code:
function Window_DashStamina() { this.initialize.apply(this, arguments); }// Inherit from base windowWindow_DashStamina.prototype = Object.create(Window_Base.prototype);// Set ConstructorWindow_DashStamina.prototype.constructor = Window_DashStamina;// ConstructorWindow_DashStamina.prototype.initialize = function(x, y, width, height) {    Window_Base.prototype.initialize.call(this, x, y, width, height);    this._helpWindow = null;    this._handlers = {};    this._touching = false;    this.deactivate();    //alert('window created');    this.update();};// UpdateWindow_DashStamina.prototype.update = function() {    Window_Base.prototype.update.call(this);      this.contents.clear();    this.drawStaminaWindow( 0, 0, 100);};Window_DashStamina.prototype.drawStaminaWindow = function( x, y, width) {    var unitWidth = Math.min(80);    this.resetTextColor();    this.drawText("Hello world!", x, y, width, 'left');    this.changeTextColor(this.systemColor());	console.log('draw');   };//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////var alias_SceneMapOnMapLoaded = Scene_Map.prototype.onMapLoaded;Scene_Map.prototype.onMapLoaded = function() {    alias_SceneMapOnMapLoaded.apply(this, arguments);    this.dashStaminaWindow = new Window_DashStamina(10,10,100,64);}
Ok, I got it to display Hello World for you. Please note that I haven't messed with Scene_Map before so I don't know how it operates just yet.
You can figure that out i think.

Spoiler
function Window_DashStamina() { this.initialize.apply(this, arguments); }// Inherit from base windowWindow_DashStamina.prototype = Object.create(Window_Base.prototype);// Set ConstructorWindow_DashStamina.prototype.constructor = Window_DashStamina;// ConstructorWindow_DashStamina.prototype.initialize = function(x, y, width, height) { Window_Base.prototype.initialize.call(this, x, y, width, height); this._helpWindow = null; this._handlers = {}; this._touching = false; this.deactivate(); //alert('window created'); this.update();};// UpdateWindow_DashStamina.prototype.update = function() { Window_Base.prototype.update.call(this); this.contents.clear(); this.drawStaminaWindow( 0, 0, 100);};Window_DashStamina.prototype.drawStaminaWindow = function( x, y, width) { var unitWidth = Math.min(80); this.resetTextColor(); this.drawText($gamePlayer.dashStamina, x, y, width, 'left'); this.changeTextColor(this.systemColor()); };//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////var alias_SceneMapOnMapLoaded = Scene_Map.prototype.onMapLoaded;Scene_Map.prototype.onMapLoaded = function() { alias_SceneMapOnMapLoaded.apply(this, arguments);}Scene_Map.prototype.createDashWindow = function() {this.dashStaminaWindow = new Window_DashStamina(10,10,100,64); this.addChild(this.dashStaminaWindow);};var alias_createDisplayObjects= Scene_Map.prototype.createDisplayObjects;Scene_Map.prototype.createDisplayObjects = function() {alias_createDisplayObjects.call(this); this.createDashWindow();};
Nvm this makes the game lag so it is not the correct way.

Edit 2: Ok I got it to work with no lag and display the correct dash amount. Let me know if this is what you wanted.
I love you! Works great.

Looks like I have to dive deeper into how Javascript works with classes&objects (which are functions), prototypes (which every function has), this-keyword, polymorphism and much more... Ugh I never thought I would say this. But I really really miss the simplicity of Ruby.

I will attempt to add it to my stamina script tomorrow with a progressbar (can't be that hard).
Also if you want to change the opacity so you cant see the window and the border just put

   this.opacity = 0;

before the line where you draw everything and then you will only see the bar.

See the spoiler for example of a bar on map.

Spoiler
bars_zpsukufpiiz.png
I'm also trying to accomplish this, but in a bit of a different way. I put the last edit of this script in, however nothing shows up on my screen and i get no errors. Any thoughts on how to make it appear for me?

Original thread: https://forums.rpgmakerweb.com/threads/howto-make-a-basic-window.48700/