I added the escape to the ActorCommand, why doesn't it work?

Discussion in 'Learning Javascript' started by Erodaisiki, Oct 9, 2019.

  1. Erodaisiki

    Erodaisiki Veteran Veteran

    Messages:
    46
    Likes Received:
    3
    First Language:
    English
    Primarily Uses:
    RMMV
    Window_ActorCommand.prototype.makeCommandList = function() {
    if (this._actor) {
    this.addAttackCommand();
    this.addSkillCommands();
    this.addGuardCommand();
    this.addItemCommand();
    this.addCommand(TextManager.escape, 'escape', BattleManager.canEscape());
    }
    };

    What else do I need to modify?
     
    #1
  2. Drifter92

    Drifter92 Veteran Veteran

    Messages:
    122
    Likes Received:
    82
    First Language:
    English
    Primarily Uses:
    RMMV
    I don't have a whole lot of knowledge with this stuff but I've been modifying the command list myself recently. Take a look at rpg_scenes.
    Code:
    Scene_Battle.prototype.createPartyCommandWindow = function() {
        this._partyCommandWindow = new Window_PartyCommand();
        this._partyCommandWindow.setHandler('fight',  this.commandFight.bind(this));
        this._partyCommandWindow.setHandler('escape', this.commandEscape.bind(this));
        this._partyCommandWindow.deselect();
        this.addWindow(this._partyCommandWindow);
    };
    If you modify the 'createActorCommandWindow' in rpg_scenes you should be able to get it working :thumbsup-left:
     
    #2
  3. Shaz

    Shaz Veteran Veteran

    Messages:
    37,712
    Likes Received:
    11,420
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    What does happen? Do you see the command but it does nothing, or do you not see it at all? Based on the above, I'd expect that you see the command, but it may or may not be enabled, depending on whether you did a Battle Processing call and set the Can Escape option, or whether random encounters allow escape by default, and that if it's enabled, it does nothing when you select it. But that's only an assumption, because you haven't said.

    Do you have the handler? You've got to set up what shows on the menu, as well as what happens when that option is chosen.
     
    #3
  4. Erodaisiki

    Erodaisiki Veteran Veteran

    Messages:
    46
    Likes Received:
    3
    First Language:
    English
    Primarily Uses:
    RMMV
    yes´╝îit work
     
    #4
  5. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,546
    Likes Received:
    2,900
    Location:
    Philippines
    First Language:
    Tagalog
    When making or editing commands, remember that commands have 2 parts, the actual command and the handler. When commands are selected, they run the handler assigned to them.. So if you only add a command to the window but didnt define a handler for it, it wont do anything. :)

    Also, take note that handlers are usually set in the Scene that will use the command window, while commands are usually added in the command windows themselves.

    For example, on the code posted by drifter, it shows you how Scene_Battle registers the handler for the Party Command Window's Fight and Escape commands.

    Lastly, the handlers are registered per command window, so if you have two command windows that have the same command, you need to define a handler for that command on both window objects.

    In your case, you need to define the handler of "escape" in the actorCommandWindow object.
     
    #5

Share This Page