Trihan

Speedy Scripter
Regular
Joined
Apr 12, 2012
Messages
6,554
Reaction score
7,117
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

Regular
Regular
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,924
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
Regular
Joined
Apr 12, 2012
Messages
6,554
Reaction score
7,117
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
Regular
Joined
Aug 21, 2013
Messages
1,076
Reaction score
897
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
Regular
Joined
Apr 12, 2012
Messages
6,554
Reaction score
7,117
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

Regular
Regular
Joined
Jun 6, 2020
Messages
723
Reaction score
314
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 Profile Posts

Woke up in the middle of the night with some game mechanic ideas. Unfortunately, they're for a new game, not the one I'm currently working on. Must... not... get... distracted!
I'm wondering about making a new pack of monsters or just divide them and add to my current packs. I'll end up having like 10+ packs If I just have 27 per pack xD
cesariohelp wrote on Ms Littlefish's profile.
Hi ! I see that you're a mod, right ? Can I ask you a question here ? If not, where ? So sorry
I just whipped up the blueprints for the final level in my game. (I say final, when really there is a final boss stage after this, but it's only like two maps long)
The good thing about making a scarecrow is, I can just use a T-pose on it and call it an animation. :kaojoy:
SA145K_idle.gif

Wait... it is starting to move on its own?:kaoswt2:

Forum statistics

Threads
134,936
Messages
1,252,024
Members
177,777
Latest member
philllchabbb
Top