MZ Custom Window Help (SOLVED)

I looked I really did and found plenty topics about refreshing custom windows that use that prototype syntax but my custom window is a class and I cannot find anything about how to refresh it. The problem is the my sprite image won't go away. I set it up the load and animate the sv actor depending on who's the party leader and all that works I can see the sprite change underneath the initial one. But the initial one just stops animating and won't go away until I leave the scene. I've search how to remove images and only got one thing to worked that removed everything else but the one that won't go away. It's been days and I given up before on the same problem and though I could work around it and still ran into the same problem.

The other problem was when I made a custom horizontal command menu. same problem only I wanted to be able to toggle it open and close but nope couldn't figure it out. It was a class menu too.

Screenshot 2023-01-05 at 11.07.54 AM.png
Screenshot 2023-01-05 at 11.08.10 AM.png
First of all, the screenshots make it look like your update() function is defined outside of the Window_Hud class. Just something you might want to consider for next time. Posting your code within [code] tags might help avoid this issue.

As for why your sprite isn't disappearing:
JavaScript:
this.actor = new Sprite(ImageManager.loadSvActor($gameParty.leader()._battlerName));
this.removeChild(this.actor);

You are creating a new Sprite() and are then trying to remove it from the window. The problem is, this is a new sprite which has never been added to the window, and therefore cannot be removed from it.

Without knowing the entire code, the best fix I can suggest at this point is to simply exchange both lines. In other words, your update() function should look like this:

JavaScript:
update() {
    if (thePartyLeader != $gameParty.leader()._battlerName) {
        thePartyLeader = $gameParty.leader()._battlerName;
        this.removeChild(this.actor);
        this.actor = new Sprite(ImageManager.loadSvActor(thePartyLeader));
    }
}
O.M.G.
I literally lost sleep over this. I just woke up. I really appreciate these forums but I hate not being able to figure this out on my own. I posted screenshots because I thought it be easier for people to help when line numbers are there but duly noted I can post the script next time I'm sure I'll need help. Like right now!

I'm hoping the other thing I mentioned would be an easy problem to solve. It was about toggling the window classes I make on and off. like let's say I do want to close the Window_Hud, is there a simple script for that? Or a scene refresh that doesn't fade the screen I had to edit my first post too I was so sleep depraved.

[
Wait do I need to just add an update function to the Scene_Map function?
If I do I don't know how I tried Update() {}; but the red error comes up on the curly braces.
O.M.G.
I literally lost sleep over this. I just woke up. I really appreciate these forums but I hate not being able to figure this out on my own. I posted screenshots because I thought it be easier for people to help when line numbers are there but duly noted I can post the script next time I'm sure I'll need help. Like right now!

I'm hoping the other thing I mentioned would be an easy problem to solve. It was about toggling the window classes I make on and off. like let's say I do want to close the Window_Hud, is there a simple script for that? Or a scene refresh that doesn't fade the screen I had to edit my first post too I was so sleep depraved.

JavaScript:
(() => {
  
    PluginManager.registerCommand('myplugin','open', args => {

      

    });

    var Imported = Imported || {};
    Imported["LadyLegend myplugin"] = "0.1.0";
  
    var LadyLegend = LadyLegend || {};
    LadyLegend.myplugin = LadyLegend.myplugin || {};

    parameters = PluginManager.parameters("myplugin");

    LadyLegend.myplugin._HUDb    = String(parameters["HUD Background"]);
    LadyLegend.myplugin._HUDx    = String(parameters["HUD X"]);
    LadyLegend.myplugin._HUDy    = String(parameters["HUD Y"]);
    LadyLegend.myplugin._IconX    = Number(parameters["Icon X"]);
    LadyLegend.myplugin._IconY    = Number(parameters["Icon Y"]);
    LadyLegend.myplugin._HUDw    = Number(parameters["HUD Width"]);
    LadyLegend.myplugin._HUDh    = Number(parameters["HUD Height"]);
  
    const min = Math.min;
    const max = Math.max;
    const floor = Math.floor;
    const round = Math.round;
    let thePartyLeader = "";

    class Window_Hud extends Window_Base {
      
        constructor(rect) {
          
            super(rect);
          
            this.actor = new Sprite(ImageManager.loadSvActor($gameParty.leader()._battlerName));
            this.actor.x = 0;
            this.actor.y = 0;
            this.animation = [
              
                [0,0],
                [1,0],
                [2,0],
                [1,0]

            ];
          
            this.animationSpeed = 60/15;
            this.tick = 0;
            this.frame = 0;
          
        };

        async calcSize(width, height) {
          
            return [

                floor(64),
                floor(64),

            ];

        };
  
        setFrame(actor, x, y) {
  
            this.calcSize(actor.bitmap.width, actor.bitmap.height).then(f => {
              
                x *= f[0];
                y *= f[1];
  
                actor.setFrame(x, y, f[0], f[1]);
              
                this.addChildAt(this.actor,1);

            })
        };

        update() {

            if (thePartyLeader != $gameParty.leader()._battlerName) {
              
                thePartyLeader = $gameParty.leader()._battlerName;
                this.removeChild(this.actor);
                this.actor = new Sprite(ImageManager.loadSvActor(thePartyLeader));
              
            };
          
            this.tick+=this.animationSpeed;
          
            if(this.tick>=60) {
              
                this.tick=0
                this.setFrame(this.actor, this.animation[this.frame][0], this.animation[this.frame][1]);
                this.frame++;
              
                if(this.frame>=this.animation.length) this.frame=0;

            };
            // Gets the icon to draw to the Window
            this.contents.clear();
                
            let ix = LadyLegend.myplugin._IconX;
            let iy = LadyLegend.myplugin._IconY;
            let leftHandIcon = $gameVariables.value(1) > 0 ? $gameVariables.value(1) : 1;
            let rightHandIcon = $gameVariables.value(2) > 0 ? $gameVariables.value(2) : 1;
                  
            this.drawIcon($dataItems[leftHandIcon].iconIndex, ix, iy);
            this.drawIcon($dataItems[rightHandIcon].iconIndex, ix + 35, iy);
                  
            var _Game_Player_moveByInput = Game_Player.prototype.moveByInput;
                  
            Game_Player.prototype.moveByInput = function() { 
                      
                if ($gameSwitches.value(1) == true)
                          
                    return;
                          
                    _Game_Player_moveByInput.call(this);
                          
            }
                  
            if(Input.isTriggered('hand')) {

                if($gameSwitches.value(1) == true) {
                          
                    $gameSwitches.setValue(1,false);
                        
                }
                else {
                          
                    $gameSwitches.setValue(1,true);
                          
                }

            }
                  
        }

  
    }
    // Draws the Window
    const sms = Scene_Map.prototype.start;
 
    Scene_Map.prototype.start = function() {

        sms.call(this);

        let x = eval(LadyLegend.myplugin._HUDx);
        let y = eval(LadyLegend.myplugin._HUDy);
        let w = LadyLegend.myplugin._HUDw;
        let h = LadyLegend.myplugin._HUDh;
        let xOffset = x > Graphics.width/2 ? w : x == 0 ? 0 : w/2;
        let yOffset = y == Graphics.height ? h : 0;

        this.hud = new Window_Hud(new Rectangle(x-xOffset, y-yOffset, w, h));
        this.hud.opacity = 255;
        this.addChild(this.hud);
      
    }
  
})();
this.hud.close();

Wait do I need to just add an update function to the Scene_Map function?

Yes, any update function you define in a scene class will run once per frame, as maintained by the base scene class.
this.hud.close();

Wait do I need to just add an update function to the Scene_Map function?

Yes, any update function you define in a scene class will run once per frame, as maintained by the base scene class.
Where am I putting this. I can't get it to close in the update function of the window. Even if I did get it to close I wouldn't be able to use that update function to reopen it right?
Where am I putting this. I can't get it to close in the update function of the window. Even if I did get it to close I wouldn't be able to use that update function to reopen it right?
You'd put it wherever you want the window to actually be closed. I definitely wouldn't put it in update or it would close every frame and never open.

What you could do is tie it to a switch like I've done for one of my commissions:

1672967588446.png
You'd put it wherever you want the window to actually be closed. I definitely wouldn't put it in update or it would close every frame and never open.

What you could do is tie it to a switch like I've done for one of my commissions:

View attachment 249825
It isn't working for me I tried it everywhere.
What is it you're actually trying to do?
What is it you're actually trying to do?
I want to toggle the window to open and close by button press. The window I was complaining about was a horizontal command window I made. It's not in the script because I gave up on trying to figurere it out. But if I can toggle the menu I do have in the script then I can do it with any window I make.

I think for the command window though I need to remove it then add it because of the button selection.
but the window in the script is just information it can just be a show and hide but the removal and adding may be better.
I want to toggle the window to open and close by button press. The window I was complaining about was a horizontal command window I made. It's not in the script because I gave up on trying to figurere it out. But if I can toggle the menu I do have in the script then I can do it with any window I make.

I think for the command window though I need to remove it then add it because of the button selection.
but the window in the script is just information it can just be a show and hide but the removal and adding may be better.
What you can do is like I did where your window's update function opens and closes itself depending on the value of a switch, then add a handler to the window in your scene for the button you want that calls a scene-bound function where you turn the switch on/off.
What you can do is like I did where your window's update function opens and closes itself depending on the value of a switch, then add a handler to the window in your scene for the button you want that calls a scene-bound function where you turn the switch on/off.
My update function won't close my window with anything I try. Sorry it took me so long to respond. I was tryin everything I could think of.

edit: I and trying this I didn't read thoroughly gotta figure out how to do the handler and scene-bound function you mentioned. But you know I my window is open as soon as the game starts so I don't have it anywhere to open and close it. I have the update function that has a if else button statement but I never got it to close the scene window.
1. You don't have the super.update() in your update function of your window class.

The window has a default update function.
1673134866221.png

Your update function will override that function.

To ensure the original update function is still called, you have to call it through the inherited class properties. This is done via super.update();

JavaScript:
class MyClass extends Window_Base {
    constructor() {
    }
    
    update() {
        super.update();
    }
}
This will take the function of the original Window_Base prototype and use it here.

If you don't do that, those tone, open, close and dim functions will no longer work.

2. Checking for a button press can be done inside your window class, but you're limited in the buttons you can check for by the buttons registered by default.
1673135125796.png


These are the keys you can check for by using the yellow string.

JavaScript:
class MyClass extends Window_Base {
    constructor() {
    }
    
    update() {
        if (Input.isTriggered("control")) {
            if (this.isOpen()) {
                this.close();
            } else {
                this.open();
            }
        }
        super.update();
    }
}
This opens the window by pressing "control" (which is both ctrl or alt as indicated by the keymapper) if it's closed, or closes it if it's open.
Code:
const openWindow = Scene_Map.prototype.start;
let hudWidth = 200;
let hudHeight = 55;
const floor = Math.floor;
var newCharacterGraphic =  '';


//WINDOW CONTAINERS


Scene_Map.prototype.start = function() {
    openWindow.call(this);
    //THIS FUNCTIONS VARIABLES
    let x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? 0 : eval(LadyLegend.PlayerHud._HUDx) == Graphics.width ? Graphics.width-hudWidth : Graphics.width/2-hudWidth/2;
    let y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? 0 : Graphics.height-hudHeight;
    //WINDOW PARAMETERS
    this.lefthud = new Window_LeftHUD(new Rectangle(x, y, hudWidth, hudHeight));
    //OPACITY OF THE WINDOW BOXES
    this.lefthud.opacity = 255;
    //CREATES THE WINDOWS THE GRAPHICS ATTACH TO  
    this.addChildAt(this.lefthud,1);

    Window_Base.prototype.update = function() {
        Window.prototype.update.call(this);
        this.updateOpen();
        this.updateClose();
   
    }
}
Window_Base.prototype.update = function() {
    Window.prototype.update.call(this);
    this.updateOpen();
    this.updateClose();

}

//GRAPHICS


class Window_LeftHUD extends Window_Base {
   
    //GRAPHICS/ANIMATIONS SETTINGS
    constructor(rect) {  Window_Base.prototype.update = function() {
        Window.prototype.update.call(this);
        this.updateOpen();
        this.updateClose();
   
    }
        super(rect);
        //LEFT/RIGHT BACKGROUND GRAPHIC POSITION
        this.sidesBackground = new Sprite(ImageManager.loadPicture(LadyLegend.PlayerHud._HUDsb));
        this.sidesBackground.anchor.set(0.5);
        this.sidesBackground.x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? hudWidth/1.5 :hudWidth-hudWidth/1.5;
        this.sidesBackground.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0;
        if(eval(LadyLegend.PlayerHud._HUDx) > hudWidth) this.sidesBackground.scale.x *= -1;
        if(eval(LadyLegend.PlayerHud._HUDx) == '0' || LadyLegend.PlayerHud._HUDgx == Graphics.width) this.addChildAt(this.sidesBackground,1);
        //CENTER BACKGROUND GRAPHIC POSITION
        this.centerBackground = new Sprite(ImageManager.loadPicture(LadyLegend.PlayerHud._HUDcb));
        this.centerBackground.anchor.set(0.5);
        this.centerBackground.x = eval(LadyLegend.PlayerHud._HUDx)-hudWidth*1.45;
        this.centerBackground.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0;
        if(eval(LadyLegend.PlayerHud._HUDx) == Graphics.width/2)this.addChildAt(this.centerBackground,1);
        //CHARACTER GRAPHIC POSITIONS
        this.characterGraphic = new Sprite(ImageManager.loadPicture($gameParty.leader()._name));
        this.characterGraphic.anchor.set(0.5);
        this.characterGraphic.x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? hudWidth/4.2 : eval(LadyLegend.PlayerHud._HUDx) == Graphics.width ? hudWidth-hudWidth/4.2: hudWidth/2 ;
        this.characterGraphic.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0 ;
        if(eval(LadyLegend.PlayerHud._HUDx) < hudWidth) this.characterGraphic.scale.x *= -1;

        //ANIMATION FRAMES
        if(LadyLegend.PlayerHud._HUDaf == 'true') {
            this.animation = [    
            [0,0],
            [1,0],
            [2,0],
            [1,0]
        ];
        //ANIMATION SPEED SETTINGS
        this.animationSpeed = 60/15;
        this.tick = 0;
        this.frame = 0;
    }
    else {
        this.animation = [    
            [0,0],
        ]
        this.animationSpeed = 60/15;
        this.tick = 0;
        this.frame = 0;
    }
    };
    //CROP SIZE SETUP FOR ANIMATED GLOBAL GRAPHIC
    async calcSize(width, height) {
        return [
            floor(64),
            floor(64),
        ];  
    };
    //ANIMATED GRAPHIC CROPPED AND DISPLAYED
    setFrame(characterGraphic, x, y) {
       this.calcSize(characterGraphic.bitmap.width, characterGraphic.bitmap.height).then(f => {  
            x *= f[0];
            y *= f[1];
            characterGraphic.setFrame(x, y, f[0], f[1]);
            this.addChildAt(this.characterGraphic,3);
        })
    }
    update() {
        if(Input.isTriggered('hand')) {
            if(this.isOpen()) {
                this.close;
            }
                else {
                this.open;  
                }
           
        }
        super.update();
        //CHANGES CHARACTER GRAPHIC IF DATABASE RECORD USED
        if (newCharacterGraphic != $gameParty.leader()._name) {
            newCharacterGraphic = $gameParty.leader()._name;
            this.removeChild(this.characterGraphic);
            this.characterGraphic = new Sprite(ImageManager.loadPicture(newCharacterGraphic));
            this.characterGraphic.anchor.set(0.5);
            this.characterGraphic.x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? hudWidth/4.2 : eval(LadyLegend.PlayerHud._HUDx) == Graphics.width ? hudWidth-hudWidth/4.2 : hudWidth/2;
            this.characterGraphic.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0;
            if(eval(LadyLegend.PlayerHud._HUDx) < hudWidth) this.characterGraphic.scale.x *= -1;
        }
        //ANIMATION SPEED
        this.tick+=this.animationSpeed;
        if(this.tick>=60) {
            this.tick=0
            this.setFrame(this.characterGraphic, this.animation[this.frame][0], this.animation[this.frame][1]);
            this.frame++;
            if(this.frame>=this.animation.length) this.frame=0;
        };
        //DRAWS PARTY LEADERS STATE ICON
        if($gameParty.leader().states().length != 0) this.drawIcon($dataStates[$gameParty.leader()._states].iconIndex, eval(LadyLegend.PlayerHud._HUDix), eval(LadyLegend.PlayerHud._HUDiy));
    }
1. You don't have the super.update() in your update function of your window class.

The window has a default update function.
View attachment 249981
Your update function will override that function.

To ensure the original update function is still called, you have to call it through the inherited class properties. This is done via super.update();

JavaScript:
class MyClass extends Window_Base {
    constructor() {
    }
   
    update() {
        super.update();
    }
}
This will take the function of the original Window_Base prototype and use it here.

If you don't do that, those tone, open, close and dim functions will no longer work.

2. Checking for a button press can be done inside your window class, but you're limited in the buttons you can check for by the buttons registered by default.
View attachment 249982

These are the keys you can check for by using the yellow string.

JavaScript:
class MyClass extends Window_Base {
    constructor() {
    }
   
    update() {
        if (Input.isTriggered("control")) {
            if (this.isOpen()) {
                this.close();
            } else {
                this.open();
            }
        }
        super.update();
    }
}
This opens the window by pressing "control" (which is both ctrl or alt as indicated by the keymapper) if it's closed, or closes it if it's open.
Hey sorry for such a late update on this its just I spent a lot of time trying to figure this out and moved on so now that Im back at it because this is the last step and tried your approach I still can't get it to close. I have it in my code in three places here to show you where I tried it and to no avail. ***sigh...
You know what.. I think I'm just going to set up a control window that will toggle a boolean that hides the windows content and just set the window opacity to zero. The reason being that I think that if I somehow figure out how to close the window it won't remove the sprites I created with it.

I know how to open a close a window when the scene changes but I need to figure out how the choice window opens and closes or the select item window because it doesn't change scenes it pops on and off on the scene and Thats what I'm trying to accomplish.

I don't know if that came across when I asked about opening and closing windows.
If you close or hide a window, the Sprites become invisible.
Is there a reason why you wish the sprites to disappear entirely, instead of just not having them visible?

There's a couple of confusing things in your code that I don't quite understand.
Why are you trying to redefine what the prototype update function does inside of the start function?
1673589587911.png

You are changing the original function, which is this:
1673589666510.png

To your version, which no longer has any of these other functions in it?

And you're doing that on multiple occasions?

I also have the feeling that your code is confusing you, making it difficult to keep track of what you're actually doing.
Have you considered using functions as a way to make your code more readable by splitting large functions into segments?

Spoiler: Example update function
JavaScript:
update() {
    this.processOpenCloseButton();
    super.update();
    this.changeCharacterGraphics();
    this.processAnimationTicks();
    this.drawPartyLeaderStateIcon();   
}

processOpenCloseButton() {
    if(Input.isTriggered('hand')) {
        if(this.isOpen()) {
            this.close;
        } else {
            this.open; 
        }
    }
}

changeCharacterGraphics() {   
    if (newCharacterGraphic != $gameParty.leader()._name) {
        newCharacterGraphic = $gameParty.leader()._name;
        this.removeChild(this.characterGraphic);
        this.characterGraphic = new Sprite(ImageManager.loadPicture(newCharacterGraphic));
        this.characterGraphic.anchor.set(0.5);
        this.characterGraphic.x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? hudWidth/4.2 : eval(LadyLegend.PlayerHud._HUDx) == Graphics.width ? hudWidth-hudWidth/4.2 : hudWidth/2;
        this.characterGraphic.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0;
        if(eval(LadyLegend.PlayerHud._HUDx) < hudWidth) this.characterGraphic.scale.x *= -1;
    }
}

processAnimationTicks() {
    this.tick+=this.animationSpeed;
    if(this.tick>=60) {
        this.tick=0
        this.setFrame(this.characterGraphic, this.animation[this.frame][0], this.animation[this.frame][1]);
        this.frame++;
        if(this.frame>=this.animation.length) this.frame=0;
    };   
}

drawPartyLeaderStateIcon() {
    if($gameParty.leader().states().length != 0) this.drawIcon($dataStates[$gameParty.leader()._states].iconIndex, eval(LadyLegend.PlayerHud._HUDix), eval(LadyLegend.PlayerHud._HUDiy));
}
The above example would be part of the Class object. By splitting the code into segments it becomes more readable. Instead of having to modify a big function chunk, you only have to focus on component functions that have a very clear goal.

I also don't understand what you're trying to do here:
1673590292871.png

I don't understand how you expect this to work. "hand" is not a recognizeable input.
How can the code know what you mean by "hand"?

The Input.isTriggered() function checks if the argument you're giving it (in this case "hand") is a registered entry mapped in the Input.keyMapper to a keyCode (which is an outdated way of knowing what key is currently being pressed).

Unless you've altered the Input.keyMapper, there is no way Input.isTriggered("hand") will ever be true, and thus the condition will never be fulfilled and there is never a point that part of the function will run.

Overall, I feel like you're trying to do something that is very doable, but you're doing it in a way that has you confusing yourself.
Perhaps you can give a brief overview over what you're trying to do overall (the plugin idea) and how you're trying to make it work?

Have you considered rewriting the plugin in a very simple way that you're just trying to create the framework without adding complex elements to it? It usually helps to build something simple first (e.g. a simple window displaying a fixed sprite) and then working on that to gradually add complexity (custom display position, changing sprite images, etc.)

It makes detecting problems a lot easier.
If you close or hide a window, the Sprites become invisible.
Is there a reason why you wish the sprites to disappear entirely, instead of just not having them visible?

No. I was just assuming it wouldn't wouldn't disappear when close because I can change the opacity of the window and that did'nt effect the sprites. I said I had a feeling that it wouldn't but I never got it to works so IDK. I would prefer opening and closing it to entirely disappearing.


There's a couple of confusing things in your code that I don't quite understand.
Why are you trying to redefine what the prototype update function does inside of the start function?

I was following a tutorial so I don't know what the "prototype" this even is. I understand Scene Map and start and what functions are generally.

View attachment 250569
You are changing the original function, which is this:
View attachment 250570
To your version, which no longer has any of these other functions in it?

I thought I only needed the open and close part of that update function so I left the other ones out. Like what is updateTone or BackgroundDimmer? What came to mind was transitioning which I don't want. I want to reinterate that I do not want the screen to dim open a new scene menu this is just a pop up window. How I explain that clearly.

And you're doing that on multiple occasions?

Nope I have it in three locations to show where I've tried it in my code and didn't work.

I also have the feeling that your code is confusing you, making it difficult to keep track of what you're actually doing.
Have you considered using functions as a way to make your code more readable by splitting large functions into segments?

Spoiler: Example update function
JavaScript:
update() {
    this.processOpenCloseButton();
    super.update();
    this.changeCharacterGraphics();
    this.processAnimationTicks();
    this.drawPartyLeaderStateIcon();  
}

processOpenCloseButton() {
    if(Input.isTriggered('hand')) {
        if(this.isOpen()) {
            this.close;
        } else {
            this.open;
        }
    }
}

changeCharacterGraphics() {  
    if (newCharacterGraphic != $gameParty.leader()._name) {
        newCharacterGraphic = $gameParty.leader()._name;
        this.removeChild(this.characterGraphic);
        this.characterGraphic = new Sprite(ImageManager.loadPicture(newCharacterGraphic));
        this.characterGraphic.anchor.set(0.5);
        this.characterGraphic.x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? hudWidth/4.2 : eval(LadyLegend.PlayerHud._HUDx) == Graphics.width ? hudWidth-hudWidth/4.2 : hudWidth/2;
        this.characterGraphic.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0;
        if(eval(LadyLegend.PlayerHud._HUDx) < hudWidth) this.characterGraphic.scale.x *= -1;
    }
}

processAnimationTicks() {
    this.tick+=this.animationSpeed;
    if(this.tick>=60) {
        this.tick=0
        this.setFrame(this.characterGraphic, this.animation[this.frame][0], this.animation[this.frame][1]);
        this.frame++;
        if(this.frame>=this.animation.length) this.frame=0;
    };  
}

drawPartyLeaderStateIcon() {
    if($gameParty.leader().states().length != 0) this.drawIcon($dataStates[$gameParty.leader()._states].iconIndex, eval(LadyLegend.PlayerHud._HUDix), eval(LadyLegend.PlayerHud._HUDiy));
}
The above example would be part of the Class object. By splitting the code into segments it becomes more readable. Instead of having to modify a big function chunk, you only have to focus on component functions that have a very clear goal.

No I understand how I wrote the code and where everything is so I'm not confused on that part. What confuses me is calling other functions and how this:

Code:
changeCharacterGraphics() { 
    if (newCharacterGraphic != $gameParty.leader()._name) {
        newCharacterGraphic = $gameParty.leader()._name;
        this.removeChild(this.characterGraphic);
        this.characterGraphic = new Sprite(ImageManager.loadPicture(newCharacterGraphic));
        this.characterGraphic.anchor.set(0.5);
        this.characterGraphic.x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? hudWidth/4.2 : eval(LadyLegend.PlayerHud._HUDx) == Graphics.width ? hudWidth-hudWidth/4.2 : hudWidth/2;
        this.characterGraphic.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0;
        if(eval(LadyLegend.PlayerHud._HUDx) < hudWidth) this.characterGraphic.scale.x *= -1;
    }
}

would work without any update indicators that checks if it true or not constantly. I need it to be checked constantly to update the image when the party leader changes.

I also don't understand what you're trying to do here:
View attachment 250571
I don't understand how you expect this to work. "hand" is not a recognizeable input.
How can the code know what you mean by "hand"?]

The Input.isTriggered() function checks if the argument you're giving it (in this case "hand") is a registered entry mapped in the Input.keyMapper to a keyCode (which is an outdated way of knowing what key is currently being pressed).

Unless you've altered the Input.keyMapper, there is no way Input.isTriggered("hand") will ever be true, and thus the condition will never be fulfilled and there is never a point that part of the function will run.

I did remapped the spacebar key in the core js. I eventually will add my own key for my personal project but as a plugin others can use it'll be the default buttons they will choose from.

Overall, I feel like you're trying to do something that is very doable, but you're doing it in a way that has you confusing yourself.
Perhaps you can give a brief overview over what you're trying to do overall (the plugin idea) and how you're trying to make it work?

I'm still learning and I know there's a million ways to do one thing and my way or at least the way the tutorial went I understand how to display a permanent window that displays information. I am trying to work off that and make that window toggle on and off the screen NOT open a menu scene and close it. That I know how to do that. I don't want that. Sort of how the choice window opens and closes but I don't want a command menu. I do but one thing at a time.
Have you considered rewriting the plugin in a very simple way that you're just trying to create the framework without adding complex elements to it? It usually helps to build something simple first (e.g. a simple window displaying a fixed sprite) and then working on that to gradually add complexity (custom display position, changing sprite images, etc.)
I did this very exact thing. At first all I had was a window and the animated sprite and couldn't figure out how to close the window. I moved on because I tend to spend an entire day trying to find a solution. So instead of getting little work done and holding the project up to solve a problem I save the problem for later.
It makes detecting problems a lot easier.
No. I was just assuming it wouldn't wouldn't disappear when close because I can change the opacity of the window and that did'nt effect the sprites. I said I had a feeling that it wouldn't but I never got it to works so IDK. I would prefer opening and closing it to entirely disappearing.
open() and close() are similar to show() and hide() - they manipulate the opacity of the window, causing it - and everything assigned to it, to become utterly invisible and thus transparent. Open & close do it gradually, show & hide do it instantly.
I was following a tutorial so I don't know what the "prototype" this even is. I understand Scene Map and start and what functions are generally.
That's unfortunate. I'd recommend checking JS tutorials on prototypes and classes. Understanding how they work is essential.
I thought I only needed the open and close part of that update function so I left the other ones out. Like what is updateTone or BackgroundDimmer? What came to mind was transitioning which I don't want. I want to reinterate that I do not want the screen to dim open a new scene menu this is just a pop up window. How I explain that clearly.
Those are update functions that only do something when the window has been told to use them. They're inert, they only do something when you need them to. Stripping them out of an update function is a really bad idea. What you've done is even worse - you've stripped them out of the prototype of all windows. Which means you've prevented all windows in existence from being able to change the tone color, or to dim a background.

And since you didn't change your window, but the prototype of all windows, you've basically destroyed important functionality in all your windows. Some plugins or windows are probably going to crash or malfunction as a result.

Furthermore, you haven't actually added the necessary update functionality to your own window, because you're still overriding the update function that you've just redefined, meaning the change you did in that update function of the Window_Base affects all windows but yours.
Nope I have it in three locations to show where I've tried it in my code and didn't work.
As outlined above, what you did 3 times was change the way all default windows work, essentially destroying part of their functionality, while leaving only your window unaffected.
No I understand how I wrote the code and where everything is so I'm not confused on that part. What confuses me is calling other functions and how this:

Code:
changeCharacterGraphics() {
    if (newCharacterGraphic != $gameParty.leader()._name) {
        newCharacterGraphic = $gameParty.leader()._name;
        this.removeChild(this.characterGraphic);
        this.characterGraphic = new Sprite(ImageManager.loadPicture(newCharacterGraphic));
        this.characterGraphic.anchor.set(0.5);
        this.characterGraphic.x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? hudWidth/4.2 : eval(LadyLegend.PlayerHud._HUDx) == Graphics.width ? hudWidth-hudWidth/4.2 : hudWidth/2;
        this.characterGraphic.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0;
        if(eval(LadyLegend.PlayerHud._HUDx) < hudWidth) this.characterGraphic.scale.x *= -1;
    }
}

would work without any update indicators that checks if it true or not constantly. I need it to be checked constantly to update the image when the party leader changes.
They would change because the update function, once the Window is the child of a scene (via addWindow or addChild when adding it to a Window that's a child of the scene) is invoked 60 times a second. The main JS file loops a section of itself, that section calls all main game objects, among them the Scene Manager, the SceneManager updates the scene, and the scene updates all of its children and all of their childrens children update their children - so long as you leave the original update function in existence - as I showed you in my earlier example - instead of overwriting it or overwriting the Window_Base functionality.
I did remapped the spacebar key in the core js. I eventually will add my own key for my personal project but as a plugin others can use it'll be the default buttons they will choose from.
Those are not good ideas. Playing around with the keyMapper with new buttons will conflict with every other plugin that tries the same, potentially causing massive incompatibility or other problems.
If you want custom buttons to work, you're going to have to either layer a new Input Manager on top of the old one - or use the one I provide in my Plugin for Plugin Developers, which allows all developers, across all plugins, to simply write one line to make a key work.

Since your modifications of the core file are not part of the code above, I cannot tell you whether you correctly changed anything or not.
I'm still learning and I know there's a million ways to do one thing and my way or at least the way the tutorial went I understand how to display a permanent window that displays information. I am trying to work off that and make that window toggle on and off the screen NOT open a menu scene and close it. That I know how to do that. I don't want that. Sort of how the choice window opens and closes but I don't want a command menu. I do but one thing at a time.

I did this very exact thing. At first all I had was a window and the animated sprite and couldn't figure out how to close the window. I moved on because I tend to spend an entire day trying to find a solution. So instead of getting little work done and holding the project up to solve a problem I save the problem for later.
Windows can be toggled either via show&hide or open&close very easily. If the sprite is a child of that window, the sprite will adopt the opacity of its parent (the window) and become invisible as well.

1. Start RPG Maker in playtesting.
2. Open the console. (F12 or F8 for RPGMV)
3. On the Title Screen, write this into the console:
SceneManager._scene._commandMenu.hide()

This will make the window with the commands disappear. use show() to make it reappear.
1673675967131.png


1673676016285.png

This is a very basic way to manipulate a window.

This can be done, with those commands, for every window. Close and open do the same, but they're gradual. In the case of this command Window, close() will not work quite right, because the window checks to see if it is closed and opens if so automatically. But you can do the same for every other window in the game, including message windows, menu windows, etc.
And if they open or close, they'll gradually disappear or appear rather than instantaneously.
open() and close() are similar to show() and hide() - they manipulate the opacity of the window, causing it - and everything assigned to it, to become utterly invisible and thus transparent. Open & close do it gradually, show & hide do it instantly.


Ok so now I know it will since you've confirmed it but I'm still not sure why the this.opacity = 255; didn't effect the sprites when I set it to 0. It only made the rectangle invisible but not the contents, its not a concern if I can get it to work properly.
View attachment 250678

That's unfortunate. I'd recommend checking JS tutorials on prototypes and classes. Understanding how they work is essential.

I thought prototypes were a rpgmaker thing. When little I learned using those learning apps in javascript I don't remember seeing anything on prototypes but classes, objects and functions yes. I will definitely study more.

Those are update functions that only do something when the window has been told to use them. They're inert, they only do something when you need them to. Stripping them out of an update function is a really bad idea. What you've done is even worse - you've stripped them out of the prototype of allwindows. Which means you've prevented all windows in existence from being able to change the tone color, or to dim a background.

And since you didn't change your window, but the prototype of all windows, you've basically destroyed important functionality in all your windows. Some plugins or windows are probably going to crash or malfunction as a result.

Furthermore, you haven't actually added the necessary update functionality to your own window, because you're still overriding the update function that you've just redefined, meaning the change you did in that update function of the Window_Base affects all windows but yours.

As outlined above, what you did 3 times was change the way all default windows work, essentially destroying part of their functionality, while leaving only your window unaffected.

Ok I understand what you're saying about how it changes it for all windows, but did I needed to add this entire function to my plugin or was it an example you used to try to explain to me what I was missing? Was I suppose to add this.updateOpen() and close to my Scene_Map.prototype.start function?

1673589666510.png


They would change because the update function, once the Window is the child of a scene (via addWindow or addChild when adding it to a Window that's a child of the scene) is invoked 60 times a second. The main JS file loops a section of itself, that section calls all main game objects, among them the Scene Manager, the SceneManager updates the scene, and the scene updates all of its children and all of their childrens children update their children - so long as you leave the original update function in existence - as I showed you in my earlier example - instead of overwriting it or overwriting the Window_Base functionality.

So what I took from this is that the class I made Window_ActorHUD extends WindowBase essentially updates 60 times a second....If so why would I even need the update(){super.update();}?

I did copy and pasted your example but the open close still doesn't work....This is the whole code:

Code:
//PLUGIN VARIABLES
const openWindow = Scene_Map.prototype.start;
let hudWidth = 200;
let hudHeight = 55;
const floor = Math.floor;
var newCharacterGraphic =  '';
//WINDOW CONTAINERS
Scene_Map.prototype.start = function() {
    openWindow.call(this);
    //THIS FUNCTIONS VARIABLES
    let x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? 0 : eval(LadyLegend.PlayerHud._HUDx) == Graphics.width ? Graphics.width-hudWidth : Graphics.width/2-hudWidth/2;
    let y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? 0 : Graphics.height-hudHeight;
    //WINDOW PARAMETERS
    this.actorHud = new Window_ActorHUD(new Rectangle(x, y, hudWidth, hudHeight));
    //OPACITY OF THE WINDOW BOXES
    this.actorHud.opacity = 255;

    //CREATES THE WINDOWS THE GRAPHICS ATTACH TO
    this.addChildAt(this.actorHud,1);
}
//GRAPHICS
class Window_ActorHUD extends Window_Base {
    //GRAPHICS/ANIMATIONS SETTINGS
    constructor(rect) {
        super(rect);
        //LEFT/RIGHT BACKGROUND GRAPHIC POSITION
        this.sidesBackground = new Sprite(ImageManager.loadPicture(LadyLegend.PlayerHud._HUDsb));
        this.sidesBackground.anchor.set(0.5);
        this.sidesBackground.x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? hudWidth/1.5 :hudWidth-hudWidth/1.5;
        this.sidesBackground.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0;
        if(eval(LadyLegend.PlayerHud._HUDx) > hudWidth) this.sidesBackground.scale.x *= -1;
        if(eval(LadyLegend.PlayerHud._HUDx) == '0' || LadyLegend.PlayerHud._HUDgx == Graphics.width) this.addChildAt(this.sidesBackground,1);
        //CENTER BACKGROUND GRAPHIC POSITION
        this.centerBackground = new Sprite(ImageManager.loadPicture(LadyLegend.PlayerHud._HUDcb));
        this.centerBackground.anchor.set(0.5);
        this.centerBackground.x = eval(LadyLegend.PlayerHud._HUDx)-hudWidth*1.45;
        this.centerBackground.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0;
        if(eval(LadyLegend.PlayerHud._HUDx) == Graphics.width/2)this.addChildAt(this.centerBackground,1);
        //CHARACTER GRAPHIC POSITIONS
        this.characterGraphic = new Sprite(ImageManager.loadPicture($gameParty.leader()._name));
        this.characterGraphic.anchor.set(0.5);
        this.characterGraphic.x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? hudWidth/4.2 : eval(LadyLegend.PlayerHud._HUDx) == Graphics.width ? hudWidth-hudWidth/4.2: hudWidth/2 ;
        this.characterGraphic.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0 ;
        if(eval(LadyLegend.PlayerHud._HUDx) < hudWidth) this.characterGraphic.scale.x *= -1;

        //ANIMATION FRAMES
        if(LadyLegend.PlayerHud._HUDaf == 'true') {
            this.animation = [     
            [0,0],
            [1,0],
            [2,0],
            [1,0]
        ];
        //ANIMATION SPEED SETTINGS
        this.animationSpeed = 60/15;
        this.tick = 0;
        this.frame = 0; 
    }
    else {
        this.animation = [     
            [0,0],
        ]
        this.animationSpeed = 60/15;
        this.tick = 0;
        this.frame = 0;
    }
    };
    //CROP SIZE SETUP FOR ANIMATED GLOBAL GRAPHIC
    async calcSize(width, height) {
        return [
            floor(64),
            floor(64),
        ];   
    };
    //ANIMATED GRAPHIC CROPPED AND DISPLAYED
    setFrame(characterGraphic, x, y) {
       this.calcSize(characterGraphic.bitmap.width, characterGraphic.bitmap.height).then(f => {   
            x *= f[0];
            y *= f[1];
            characterGraphic.setFrame(x, y, f[0], f[1]);
            this.addChildAt(this.characterGraphic,3);
        })
    }
    update() {
        this.processOpenCloseButton();
        super.update();
        this.changeCharacterGraphics();
        this.processAnimationTicks();
        this.drawPartyLeaderStateIcon();   
    }
    
    processOpenCloseButton() {
        if(Input.isTriggered('ok')) {
            if(this.isOpen()) {
                this.close;
            } else {
                this.open;
            }
        }
    }
    
    changeCharacterGraphics() {   
        if (newCharacterGraphic != $gameParty.leader()._name) {
            newCharacterGraphic = $gameParty.leader()._name;
            this.removeChild(this.characterGraphic);
            this.characterGraphic = new Sprite(ImageManager.loadPicture(newCharacterGraphic));
            this.characterGraphic.anchor.set(0.5);
            this.characterGraphic.x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? hudWidth/4.2 : eval(LadyLegend.PlayerHud._HUDx) == Graphics.width ? hudWidth-hudWidth/4.2 : hudWidth/2;
            this.characterGraphic.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0;
            if(eval(LadyLegend.PlayerHud._HUDx) < hudWidth) this.characterGraphic.scale.x *= -1;
        }
    }
    
    processAnimationTicks() {
        this.tick+=this.animationSpeed;
        if(this.tick>=60) {
            this.tick=0
            this.setFrame(this.characterGraphic, this.animation[this.frame][0], this.animation[this.frame][1]);
            this.frame++;
            if(this.frame>=this.animation.length) this.frame=0;
        };   
    }
    
    drawPartyLeaderStateIcon() {
        if($gameParty.leader().states().length != 0) this.drawIcon($dataStates[$gameParty.leader()._states].iconIndex, eval(LadyLegend.PlayerHud._HUDix), eval(LadyLegend.PlayerHud._HUDiy));
    }
}

Those are not good ideas. Playing around with the keyMapper with new buttons will conflict with every other plugin that tries the same, potentially causing massive incompatibility or other problems.
If you want custom buttons to work, you're going to have to either layer a new Input Manager on top of the old one - or use the one I provide in my Plugin for Plugin Developers, which allows all developers, across all plugins, to simply write one line to make a key work.

Since your modifications of the core file are not part of the code above, I cannot tell you whether you correctly changed anything or not.

I did get the button to work by testing a switch but I remapped my core button for my personal project. For the most part I'm not trying to use many plugins or any at all from others is my ultimate goal because of that whole compatibility issue that halts not just my own but many peoples projects. So I thought I'd try my hand in it considering I'm a quick learner but I understand the problem if I want others to use the plugin which I do so I really only have one question about that. You know how the "ok" has like 3 buttons mapped to it(Z, Spacebar,Enter), how to I target the spacebar "ok" press?

Windows can be toggled either via show&hide or open&close very easily. If the sprite is a child of that window, the sprite will adopt the opacity of its parent (the window) and become invisible as well.

1. Start RPG Maker in playtesting.
2. Open the console. (F12 or F8 for RPGMV)
3. On the Title Screen, write this into the console:
SceneManager._scene._commandMenu.hide()

This will make the window with the commands disappear. use show() to make it reappear.
View attachment 250666

View attachment 250667
This is a very basic way to manipulate a window.

This can be done, with those commands, for every window. Close and open do the same, but they're gradual. In the case of this command Window, close() will not work quite right, because the window checks to see if it is closed and opens if so automatically. But you can do the same for every other window in the game, including message windows, menu windows, etc.
And if they open or close, they'll gradually disappear or appear rather than instantaneously.

The test didn't work and I tried to using an event to see if it would close my window both hide and close didn't work..
SceneManager._scene._Window_ActorHUD.hide()
I also tried it as a plugin command

View attachment 250682

Original thread: https://forums.rpgmakerweb.com/threads/custom-window-help-solved.153796/