Help with hiding and showing window

Discussion in 'Learning Javascript' started by JUICY_PINEFIELDS, Jan 7, 2019.

  1. JUICY_PINEFIELDS

    JUICY_PINEFIELDS はい! 十四松です!! Member

    Messages:
    4
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    Hi! I'm currently editing a script to hide a window, specifically Window_BattleStatus when you escape from battle. This is because when my windows fade in and out, there's an extra second of Window_BattleStatus fading that looks sloppy. Sometimes it doesn't show up, sometimes it does. Here's what it looks like.
    The script I'm editing is AutoBattlePlus. Here is what I have so far:
    Code:
    //=============================================================================
    // AutoBattlePlus.js
    //=============================================================================
    
    /*:
     * @plugindesc add 'auto' and 'repeat' to battle party command
     * @author Sasuke KANNAZUKI (thx to tomoaky)
     *
     * @param Auto Command Name
     * @desc Command name of Auto
     * @default Auto
     *
     * @param Repeat Command Name
     * @desc Command name of Repeat
     * @default Repeat
     *
     * @help This plugin does not provide plugin commands.
     *
     * - Choose "Auto" to all actors determine automatically their actions
     *   at the turn.
     * - Choose "Repeat" to make actors the same action as the previous turn.
     *
     * note:
     * - At "Repeat" mode, when the actor cannot perform the same action
     * (ex. MP has run out), perform normal attack instead.
     * - When choose "Repeat" at first turn, let all actions be normal attack.
     *
     * copyright: this plugin is based on tomoaky's RGSS3 script material.
     * see "Hikimoki" http://hikimoki.sakura.ne.jp/
     * Thanks to tomoaky.
     *
     * This plugin is released under MIT license.
     * http://opensource.org/licenses/mit-license.php
     */
    
    
    (function() {
    
    var parameters = PluginManager.parameters('AutoBattlePlus');
    var autoName = parameters['Auto Command Name'] || 'Auto';
    var repeatName = parameters['Repeat Command Name'] || 'Repeat';
    
    
    Window_PartyCommand.prototype.makeCommandList = function() {
    this.addCommand(autoName,           'auto');
    this.addCommand(TextManager.escape, 'escape');
    };
    
    var _Scene_Battle_createPartyCommandWindow =
    Scene_Battle.prototype.createPartyCommandWindow;
    Scene_Battle.prototype.createPartyCommandWindow = function() {
    _Scene_Battle_createPartyCommandWindow.call(this);
    this._partyCommandWindow.setHandler('auto', this.commandAuto.bind(this)); 
    this._partyCommandWindow.setHandler('escape', this.commandEscape.bind(this));
    };
    
    Scene_Battle.prototype.commandAuto = function() {
    $gameParty.members()[0].addState(11);
    $gameParty.members()[0].makeAutoBattleActions();
    BattleManager.startTurn();
    };
    
    Scene_Battle.prototype.commandEscape = function() {
    BattleManager.processEscape();
    Window_BattleStatus.prototype.update = function() {
    this.visible = false;};
    };
    
    })()
    

    Using this.visible = false gives me the effect that I want at first, but when entering another battle Window_BattleStatus is as expected, not visible. I'm not really sure how to get it to appear normally again. Or should I just do something else entirely?
    Any and all help is appreciated, thanks in advance.
     
    #1
  2. Felski

    Felski Veteran Veteran

    Messages:
    68
    Likes Received:
    58
    First Language:
    german
    Primarily Uses:
    RMMV
    As you already said, the issue is with the this.visible = false part. Normally you would want to use one of the window functions to hide the window instead of permanently changing the update function of Window_BattleStatus.

    this._statusWindow.hide() or this._statusWindow.close() should do the trick.

    Best regards,
    Felski
     
    #2
    JUICY_PINEFIELDS likes this.
  3. JUICY_PINEFIELDS

    JUICY_PINEFIELDS はい! 十四松です!! Member

    Messages:
    4
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    Thank you so much! This worked.
    It's funny, I knew about those functions before and one of things I tried in the beginning was put those under the update function. I don't know what was going through my head.
    I'll be sure to keep this in mind in future scripts and editing.
     
    #3

Share This Page