Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,392
Reaction score
5,085
First Language
English
Primarily Uses
RMMZ
Hi everyone! Answering a recent post has reminded me that a lot of users don't understand how powerful the console is and how you can use it to better understand what makes your game tick, so I decided to extract that part of the answer into its own post.

For anyone who doesn't know, when you're playing the game you can hit F8 to open the developer console, which allows you to run JS code immediately. You can use this to trace source code, check that a function works as expected, find out what values are held in a particular object at the time etc.

Let's say I have a fairy on my map that fully recovers the party (and has no other event command in it), and I want to know exactly what that's doing due to plugins that might affect it. The event's ID is 1. If I open the console, I can do this:

1595928354568.png

Then I can open up that object (the little arrow pointing right) and see the properties/functions it has access to:

1595928361676.png

If you scroll down and open "__proto__" you can see the details of its parent class:

1595928368060.png

One of these is "page", which contains the event code:

1595928374436.png

This is where you need to know a bit about the interpreter and event codes, but since we only have one command, it's obvious that the 0 element in "list" is our "Recover All" meaning that command has a code of 314. From there, you can open up rpg_objects.js and look up command314:

1595928386215.png

Now that we know it's calling the recoverAll function, we can enter that in the console on an actor to see what it does (if you enter a function name without the (), it'll show you the function itself:

1595928393226.png

Then click the f () { part to be taken to the actual source that it's referring to:

1595928402397.png

So here we can see that the "most recent" version of the function is in YEP_BattleEngineCore.js, and you can see from there what changes the overwrite has made.

This is invaluable for debugging, and can often show up the sources of bugs way more easily than trawling through the individual js files will.

Let me know if you have any comments or questions about this!
 

modulusia

So much to learn
Member
Joined
Feb 17, 2016
Messages
12
Reaction score
11
First Language
Indonesian
Primarily Uses
RMXP
Thank you so much! I've always been confused about how to use the console. You've made it clear! I'm studying JS too so this'll come in handy. :kaothx:
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,920
First Language
English
Have you used the debugger to troubleshoot issues in RM before? Breakpoints etc.
Personally I haven't because usually the problems are quite obvious (eg: something dumb lol) but might be useful
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,392
Reaction score
5,085
First Language
English
Primarily Uses
RMMZ
Have you used the debugger to troubleshoot issues in RM before? Breakpoints etc.
Personally I haven't because usually the problems are quite obvious (eg: something dumb lol) but might be useful

I haven't tried it yet but next time I come across a tricky issue I'm gonna give it a shot.

Edit: Just had a play with it and it's actually really good. I may end up using this more often.
 
Last edited:

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
883
First Language
English
Primarily Uses
RMMV
I haven't tried it yet but next time I come across a tricky issue I'm gonna give it a shot.

Edit: Just had a play with it and it's actually really good. I may end up using this more often.

I used to use a ton of 'console.log(variable)' to debug issues, but I have been using the actual debugger and break points lately and it is so much better.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,392
Reaction score
5,085
First Language
English
Primarily Uses
RMMZ
I still use console.log a lot when debugging stuff with Yanfly's notetags for people, I think that's probably quicker than finding the line to set a breakpoint at.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
717
Reaction score
310
First Language
English
Primarily Uses
RMMV
Have you used the debugger to troubleshoot issues in RM before? Breakpoints etc.
Personally I haven't because usually the problems are quite obvious (eg: something dumb lol) but might be useful
I've used the debugger quite a bit when trying to figure out why something isn't working correctly. I strongly recommend it.

Supposedly there's also some way to link VSCode to the game so you can set breakpoints right in VSCode, but I haven't figured out a way to do that yet.
 

Latest Threads

Latest Posts

Latest Profile Posts

ScreenShot_11_27_2022_10_0_8.png
finally finished all the sprites for my friend's Comic book OC that I put in my game.
1669612924226.png
Added collectible trading cards to my current game, bio-Synthetica.
I plan to have a total of 20 different BATTLE-bot cards you can find & collect.
100 likes.jpg

I reached 100 followers on my new twitter! It's not much but it's honest work

Forum statistics

Threads
126,896
Messages
1,182,157
Members
166,694
Latest member
Roze_
Top