Functions, classes and scripts

Earlier when making a looping character animation while walking in the game, and looking for how to implement this, I ran in to this thread:

This thread answered my question entirely, but, with that said, how did this person locate and know about the functionality of $gameplayer.ismoving()?

When looking through the js folder for my project, I could only find this function being called in the rpg_scenes.js and rmmz_scenes.js files; but I was unable to locate where the function is defined. When looking at the docs online: https://developer.rpgmakerweb.com/rpg-maker-mz/ I am likewise unable to find any further info.

Where can I find information on all of the classes and functions in rpgmakermz?
Your best bet is probably going to be to continue to learn by doing, as a lot of us have. There are some websites out there that attempt to document the code, such as the one that you linked, but I'm not super familiar with them. And, ultimately, the code is right in front of you in your /js folder for you to explore and play with.

The isMoving() method is inherited from Game_CharacterBase, which you can find in rmmz_objects.js along with all of the other methods that have the Game_ prefix.
To be more specific, note this line close to the top of the definition for Game_Player:
Game_Player.prototype = Object.create(Game_Character.prototype);

It means that it inherits all properties of Game_Character, including all of its functions. So while the definition for Game_Player might have everything specific to characters controlled by the player, functions that apply to all characters will be found in Game_Character, or in Game_CharacterBase which it itself inherits from.

When examining a class, it's always useful to check which one it inherits from - a similar line can be found close to the top of the definition of almost every one of them.
In object-oriented programming, there are 2 things:
- classes
- instances

A class is like a blueprint (how to build a car?) and every instance is a car by itself. And each car can have its individualities (color, brand, ...).

As you've been asking about functions: Functions are defined in the classes. For example, every event and the player has ONE function that explains how they move, but every instance has its own x, y-coordinates and movement speed.

Sometimes, you have one class "Game_Event" but multiple instances of this class, like you have many events on your map, and sometimes it's 1:1, you've got one class "Game_Player" and one instance that is called $gamePlayer.

So, how do we know how to come from Game_Player to $gamePlayer? Well, with experience. We just know that $gamePlayer is the player instance. If you are curious, you can look for "new Game_Player" and scan the code for occurrences.

Another story: How could we identify all of the events? $gameEvents[1] does not exist. It's $gameMap.events()[1]. Well again, it's experience. We all started here. We look for keywords like "events" and scanned the code until we find a method that sounds promising.
how did this person locate and know about the functionality of $gameplayer.ismoving()?
Quick note - it's $gamePlayer, not $gameplayer.

I would suggest this is a better reference for you:

It's for MV and there are some differences between the two codebases, but most of the code and its structure is the same. Particularly for your question, this lists all of the classes used and what they inherit from.
Thanks for the help you guys!
I could be misunderstanding part of your original question, but since I didn't see it mentioned in the previous responses, I just wanted to draw your attention to the MZ Script Call List, in case you have never seen it.


If you search for "ismoving" as an example, you will find the script calls for that.

This list is absolutely amazing and you can use the script calls to do lots of things that you can't do with the regular UI Event Commands.

Good luck!

Original thread: https://forums.rpgmakerweb.com/threads/functions-classes-and-scripts.168060/