[SOLVED] How to overwrite a "vanilla" function?

Hi, I'm somewhat new to programming. I'm messing with mouse commands on MV, but I'm altering direct on the rpg_xx.js files, and there are changes that I even don't remember which line was. HAhaha.

Well, how can I create a plugin that my function totally overwrite the original function (on rpg_xxxx files)?
Example:
Code:
Game_Player.prototype.triggerTouchActionD1 = function (x1, y1) {
    if ($gameMap.airship().pos(x1, y1)) {
        if (TouchInput.isTriggered() && this.getOnOffVehicle()) {
            return true;
        }
    }
    this.checkEventTriggerHere([0]);
    return $gameMap.setupStartingEvent();
};

I want to change the whole function in my plugin file, how I can do this? Is there like an equivalent to the way that works on RGSS

Code:
alias :my_method :method
def method
 my_method // if I remember this call the base method, I don't want to execute anything from the original JS function, just overwrite it.
 do_additional_stuff
end
If you're looking a way to make an alias, here is what you need to do.
Code:
(function(){
  var _aliasedTriggerTouch = Game_Player.prototype.triggerTouchActionD1;
  Game_Player.prototype.triggerTouchActionD1 = function (x1, y1) {
    // Your custom code here
    _aliasedTriggerTouch.call(this, x1, y1);
    // Or here
  }
})();
If you're looking a way to overwrite a method, you can just drop a file as a plugin.
Then copy whatever methods you want to overwrite.
Easiest way to completely overwrite a method from the core scripts is to copy and paste it into your new plugin, take out everything except the first line and the last line, and put whatever you want in between.
Thank you guys! This work pretty well! Solved.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-how-to-overwrite-a-vanilla-function.103287/