RMMV Inserting code into default's game functionality

HenriqueBG

Villager
Member
Joined
Jan 5, 2021
Messages
8
Reaction score
1
First Language
Portuguese
Primarily Uses
RMMV
JavaScript:
var _Scene_Map_onMapLoaded_base = Scene_Map.prototype.onMapLoaded;

Scene_Map.prototype.onMapLoaded = function () {

    _Scene_Map_onMapLoaded_base.call(this);
    //code
}

I have been using this on some plugins where i need to execute after the map is loaded (events created).
I guess i am inserting code between, or before the onMapLoaded..
don't really know..

I would love if someone could explain me exactly what is going on here.

Step by step, like if i was using the debugger (i tryed this), what am i doing here? is this like a middleware?
 
Last edited:

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,064
Reaction score
7,168
First Language
Indonesian
Primarily Uses
RMVXA
It means you're preserving the previous function in order to preserve the previous code. Then add your own.

Code:
var _Scene_Map_onMapLoaded_base = Scene_Map.prototype.onMapLoaded;
This is the code that preserves it.

Code:
_Scene_Map_onMapLoaded_base.call(this);
Then call the preserved code so that the original code is executed.

Code:
   //code
Then add your own.
 

HenriqueBG

Villager
Member
Joined
Jan 5, 2021
Messages
8
Reaction score
1
First Language
Portuguese
Primarily Uses
RMMV
Thank you very much. It makes sense now!
 

Latest Threads

Latest Posts

Latest Profile Posts

I haven't been on here in forever wow(missed my forum birthday T-T). Anyways, I'm dabbling in BGMs, here's something I'm actually willing to share.

Binge-watched 6 episodes of the Erased anime... And that means I've watched half of it?! Sigh...
I'm bad at base-building games (looking at other players created an aesthetically beautiful base compared to me), but IDK why I keep playing the game and seek more of it.
Pyra and Mythra in smash ultimate are way too OP. They're basically Smash 4 Bayonetta 2.0, and not in a good way. Very toxic and unfair. At least they're hot tho.

Forum statistics

Threads
109,197
Messages
1,042,970
Members
141,700
Latest member
skybola188
Top