MV Why the status window ain't updating

This is the status window code. It doesn't refresh with the cursor on the active window "deck edit". where am i missing the this.refresh? the index position of the cursor is in the deck edit window. then i get that index to determine the deck ID from the index to display the cards.

Spoiler: code
JavaScript:
function Window_PlayerDeckSelectStatus() {
        this.initialize.apply(this, arguments);
    }

    Window_PlayerDeckSelectStatus.prototype = Object.create(Window_Base.prototype);
    Window_PlayerDeckSelectStatus.prototype.constructor = Window_PlayerDeckSelectStatus;

    Window_PlayerDeckSelectStatus.prototype.initialize = function(playerName, playerItemCardId, playerCardIds) {
        this._playerName = playerName;
        this._playerItemCardId = playerItemCardId;
        this._playerCardIds = playerCardIds;
        var width = this.windowWidth();
        var height = this.fittingHeight(2) + 144;
        var x = Graphics.boxWidth - width;
        var y = 64;
        Window_Base.prototype.initialize.call(this, x, y, width, height);
        this.createCardObjects();
        this.createCardSprites();
        this.refresh();
    };

    Window_PlayerDeckSelectStatus.prototype.isItemCardValid = function() {
        return this._playerItemCardId !== 0;
    };

    Window_PlayerDeckSelectStatus.prototype.windowWidth = function() {
        return (this._playerCardIds.length + (this.isItemCardValid() ? 1 : 0)) * 112 - 16 +
            this.standardPadding() * 2;
    };

    Window_PlayerDeckSelectStatus.prototype.createCardObjects = function() {
        this._cards = [];
        var cardIds = this._playerCardIds.concat();
        if (this.isItemCardValid()) cardIds.push(this._playerItemCardId);
        for (var i = 0; i < cardIds.length; i++) {
            var card = new Game_Card(cardIds[i]);
            var xx = (Graphics.width - 816) / 2 // new line
            var x = this.standardPadding() + i * 112 + 48 - xx; // editted line
            var y = this.standardPadding() + this.lineHeight() * 2 + 72;
            card.setPosition(x, y);
            card.setScale(0.5, 0.5);
            this._cards.push(card);
        }
    };

    Window_PlayerDeckSelectStatus.prototype.createCardSprites = function() {
        this._cardSprites = [];
        for (var i = 0; i < this._cards.length; i++) {
            var sprite = new Sprite_Card(this._cards[i], false, 1000000);
            this._cardSprites.push(sprite);
            this.addChild(sprite);
        }
    };

    Window_PlayerDeckSelectStatus.prototype.refresh = function() {
        this.contents.clear();
        this.changeTextColor(this.normalColor());
        this.drawText(this._playerName, 0, 0, this.contents.width, 'center');
        this.changeTextColor(this.systemColor());
        for (var i = 0; i < this._playerCardIds.length; i++) {
            var x = i * 112;
            this.drawText(TMPlugin.Card.PositionNames[i], x, this.lineHeight(), 96, 'center');
        }
        if (this.isItemCardValid()) {
            this.drawText(TMPlugin.Card.ItemCardPositionName, (this._cards.length - 1) * 112,
                this.lineHeight(), 96, 'center');
        }
    };

Spoiler: choice window
JavaScript:
//-----------------------------------------------------------------------------
    // Window_DeckEdit
    //

    function Window_DeckEdit() {
        this.initialize.apply(this, arguments);
    }

    Window_DeckEdit.prototype = Object.create(Window_Selectable.prototype);
    Window_DeckEdit.prototype.constructor = Window_DeckEdit;

    Window_DeckEdit.prototype.initialize = function(x, y, selectMode) {
        var width = this.windowWidth();
        var height = this.fittingHeight(Math.min($gameParty.maxDeck(), 7));
        Window_Selectable.prototype.initialize.call(this, x, y, width, height);
        this._selectMode = selectMode;
        this.select(0);
        this.activate();
        this.refresh();
    };

    Window_DeckEdit.prototype.windowWidth = function() {
        return TMPlugin.Card.StatusWindowWidth;
    };

    Window_DeckEdit.prototype.update = function() {
        Window_Selectable.prototype.update.call(this);
        if (this._slotWindow) this._slotWindow.setDeckId(this.index());
    };

    Window_DeckEdit.prototype.maxItems = function() {
        return $gameParty.maxDeck();
    };

    Window_DeckEdit.prototype.drawItem = function(index) {
        var deckName = TMPlugin.Card.DeckNames[index];
        if (deckName) {
            var maxCost = $gameParty.maxCost();
            var deckCost = $gameParty.deckCost(index);
            var rect = this.itemRectForText(index);
            this.changePaintOpacity(this.isEnabled(index));
            this.drawTextEx(deckName, rect.x, rect.y, rect.width); //edited line
            this.drawText(deckCost + '/' + maxCost, rect.x, rect.y, rect.width, 'right');
            this.changePaintOpacity(1);
        }
    };

    Window_DeckEdit.prototype.isEnabled = function(index) {
  
        return this._selectMode ? $gameParty.isDeckValid(index) : true;
    };

    Window_DeckEdit.prototype.isCurrentItemEnabled = function() {
        return this.isEnabled(this.index());
    };

    Window_DeckEdit.prototype.setSlotWindow = function(slotWindow) {
        this._slotWindow = slotWindow;
        this.callUpdateHelp();
    };

    Window_DeckEdit.prototype.updateHelp = function() {
        Window_Selectable.prototype.updateHelp.call(this);
        if (this._selectMode) {
            this._helpWindow.setText('Select the deck to use.');
        } else {
            this._helpWindow.setText('Select a deck to edit.');
        }
    };

EDIT:

so the only thing wrong was that $gamepParty.cards was an array. so this was the correction
Code:
const playerCardIds = $gameParty.cards(deckId).map(card => card ? card.id : null);

and the ITM in the 4th card slot was being handled differently. outptuting stuff to the console is the best trouble shooter.
For an example of one window that triggers another window to refresh/redraw based on its selection index, you can check out default windows like Window_BattleSkill, or any other window that has a help window associated with it.

Difficult to say much more, because you've shared two segments of incomplete code and the rest of your post honestly reads like a ChatGPT prompt.
It's not ChatGPT generated lol. It's a copy of the window in the existing codes, i just changed the name from enemy to player. I'll just have to do trial and error since i really cant code much.
i just changed the name from enemy to player.
arbitrary name changes like that rarely work in code - basically only if it is self-contained code.
as soon as any part of code interacts with a larger engine, your naming has to follow the code of the larger engine to jump correctly there.

and while the battlers for both enemy and player follow mostly the same rules and functions, the way the data in those battlers is set has a lot of differences - for example there is no enemy level and therefore the enemy data is much more simple than the player data.
It doesn't refresh with the cursor on the active window "deck edit". where am i missing the this.refresh? the index position of the cursor is in the deck edit window. then i get that index to determine the deck ID from the index to display the cards.
Assuming all else works, it sounds like you just need to redraw the status window whenever the index changes within the edit window. stick a line in the edit window's select() function to refresh the status window or something
Assuming all else works, it sounds like you just need to redraw the status window whenever the index changes within the edit window. stick a line in the edit window's select() function to refresh the status window or something
you are right, that's what ive been doing.. i even use the console to check if i'm calling the right thing..

i've been comparing the original "slot window" and made this playerdeckselectstatus window same structure with it. i found the index being called by the deck edit window

JavaScript:
    Window_DeckEdit.prototype.update = function() {
        Window_Selectable.prototype.update.call(this);
        if (this._slotWindow) this._slotWindow.setDeckId(this.index());
        //x21 link current index to deck
        if (this._playerDeckSelectStatusWindow) this._playerDeckSelectStatusWindow.setDeckId(this.index());
                
    };

JavaScript:
  Scene_DeckSelect.prototype.createSlotWindow = function() {
        var wx = this._deckWindow.width;
        var wy = this._helpWindow.height;
        var ww = Graphics.boxWidth - wx;
        this._slotWindow = new Window_DeckEditSlot(wx, wy, ww);
        this._deckWindow.setSlotWindow(this._slotWindow);
        this.addWindow(this._slotWindow);
    };

JavaScript:
Scene_DeckSelect.prototype.createPlayerDeckSelectStatusWindow = function() {
        
        const playerName = $gameParty.leader().name(); // Get player name
        const playerItemCardId = $gameParty.itemCard() ? $gameParty.itemCard().id : 0; // Get player item card ID
        const playerCardIds = $gameParty.activeDeck(this._deckWindow.index()); // Get active deck card IDs
         // Create the PlayerDeckSelectStatus window
        this._playerDeckSelectStatusWindow = new Window_PlayerDeckSelectStatus(playerName, playerItemCardId, playerCardIds);
        // Bind the PlayerDeckSelectStatus window with the DeckEdit window
        this._deckWindow.setPlayerDeckStatusWindow(this._playerDeckSelectStatusWindow);
        this.addWindow(this._playerDeckSelectStatusWindow);

    };

so i really don't know what's wrong. when i try to replace
(this draws the "active deck" correctly
const playerCardIds = $gameParty.activeDeck(this._deckWindow.index());

with (which i think is correct) the cards go missing.
const playerCardIds = $gameParty.cards(this._deckWindow.index());
you are right, that's what ive been doing.. i even use the console to check if i'm calling the right thing..
i mentioned select() specifically because your edit window inherits from Window_Selectable. Window_Selectable has a select() function that is ran every time the cursor moves. your edit window even if you havent explicitly wrote it in still has one and uses it. To make it easy, copy the function directly out of Window_Selectable, put it with your Window_DeckEdit stuff, rename it so that its Window_DeckEdit's, and then add the call to refresh the selection status window.

i've been comparing the original "slot window" and made this playerdeckselectstatus window same structure with it. i found the index being called by the deck edit window
Putting the check into update() can work, but update gets called every frame. theres absolutely no need to refresh the selection window every frame. Just when the index changes

youre skipping steps now and things are all over the place.
not sure if you meant to show the scene creating an edit slot window, but you havent shown us what Window_DeckEditSlot is. youve shared Window_DeckEdit, but that isnt the same window.
Youre also showing code using functions absent from windows you did show. You havent shown us a Window_PlayerDeckSelectStatus.prototype.setDeckId() function. without seeing it, we cant tell if it at any point refreshes the window.
what is $gameParty.activeDeck() supposed to be, what is $gameParty.cards() suposed to be, and why did you change it without knowing the data it contains or having an expectation of what itd do if the data isnt similar

you did end up relating the selection window to the scene through _playerDeckSelectStatusWindow, so if you choose to find and overwrite the select() function for the edit window, you can use SceneManager._scene._playerDeckSelectStatusWindow.refresh() to refresh the status window whenever the cursor moves on the edit window.
But that being said, im not sure how youve made the data the window look at and change with the index on closer inspection. you initialize the window with _playerItemCardId and _playerCardIds properties, but you dont seem to re-initialize the window, update the values at any point, or provide a way to update them
thanks, this was satisfying to solve and trouble shoot.. console helps alot
1729286779907.png
This thread is closed due to being reported as solved. If you need it reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/why-the-status-window-aint-updating.172669/