function.call doesn't work in my plugin

dayseven0314

Villager
Member
Joined
Jul 25, 2017
Messages
6
Reaction score
1
First Language
Chinese
Primarily Uses
RMMV
rpg_objects:
===========================================================================
Game_CharacterBase.prototype.isMapPassable = function(x, y, d) {
var x2 = $gameMap.roundXWithDirection(x, d);
var y2 = $gameMap.roundYWithDirection(y, d);
var d2 = this.reverseDir(d);
return $gameMap.isPassable(x, y, d) && $gameMap.isPassable(x2, y2, d2);
};
===========================================================================



my plugin :
===========================================================================
var _Game_CharacterBase_prototype_isMapPassable = Game_CharacterBase.prototype.isMapPassable;
Game_CharacterBase.prototype.isMapPassable = function(x, y, d){
_Game_CharacterBase_prototype_isMapPassable.call(this, x, y, d);
};
===========================================================================
it doesn't work!
player character can't move.




but if I change to this in my plugin :
===========================================================================
Game_CharacterBase.prototype.isMapPassable = function(x,y,d){
var x2 = $ gameMap.roundXWithDirection(x,d);
var y2 = $ gameMap.roundYWithDirection(y,d);
var d2 = this.reverseDir(d);
return $gameMap.isPassable(x,y,d)&& $gameMap.isPassable(x2,y2,d2);
};
===========================================================================
now it work...
player character is movable.
 

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
1,364
Reaction score
614
First Language
Portuguese - Br
Primarily Uses
RMMV
Hi!
This happens because the original function is returning a value.
And in your first attempt, you are not returning anything.

You have to do this:

JavaScript:
var _Game_CharacterBase_prototype_isMapPassable = Game_CharacterBase.prototype.isMapPassable;
Game_CharacterBase.prototype.isMapPassable = function(x, y, d){
const alias = _Game_CharacterBase_prototype_isMapPassable.call(this, x, y, d); // Here you are saving the original value
    // do your thing;
    return alias; // And here you are returning it :)
};
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

lunarrosecrow wrote on hiddenone's profile.
please don't lurk hiddenone I'm quarantining!!!
lunarrosecrow wrote on Edward.T's profile.
Hello Edward sorry to bother you and didn't start a conversation cause I thought i'd be a little weird or disrespectful but I was wondering do you still have your Generator resources you posted as the links on the page are dead?
Stream will be live shortly! It is my birthday, and thus I am doing an extended stream! I will be doing a variety of things. Among the activities I will be doing: Playing Oceanhorn: Monster of the Uncharted Seas, art, and some Text Adventure~ Feel free to drop by!
It would be cool if you could "copy as code" event commands :< .
Just managed to recover my Yahoo e-mail that i lost 3 months ago. Turns out an IP from U.S had hacked it and set the pass back to normal.. Like WTF ?

Forum statistics

Threads
99,485
Messages
965,925
Members
131,112
Latest member
Reji
Top