Debug Log File Plugin: Dev Log
I took a break from working on the menus in The Note Competition remake to make my own plugin for logging data. This was a bit of a sidetrack, so while it was in that project file, it's not officially core to the development, but something I thought would be useful to implement! This is a pretty text-heavy dev log, so be ready to see some code and not a lot of visuals.

I wanted to create a plugin that could be useful for playtesting and when players demo the game down the line. Information like play time, characters they chose, etc. I'll have more data like variable values likely in here too, but trying to print some basic data. So I started by creating a basic script like I did in #No_Hacks where it prints information to a log txt file. This was just to get the numbering set up and basic text in a text file.

Then I created a while loop where I check if a log number exists, then I iterate up by 1. This way, it could make a new log file for each time it fires.

Then I had to dive deeper into how to detect if the window is closed. I found this forum post where Caethyril details the code on how to create a custom handler to override the default close function. I started with their code just to get it functioning with my current code, then simplified it later.

Then I customized it a bit and moved it into its own function to make it a bit more readable for myself and my specific code. I was also turning this into a common event so I could have it running at all times to check.

I wanted to decide what data is printed in the file, so I created a new script command to store what's in that multi-line variable string. I tested adding some variables and data from RPG Maker in there and eventually added some extras like playtime and current team (which in this game is stored in the first party member's equipment).

It was starting to be a lot of code in these tiny script commands, so I figured because I had recently been learning about how to make a plugin for a different project, that I would turn this into a plugin. Then I could manipulate the data a bit more. So I started by copying all of my code from the first script command into a plugin and reformatting it. From there, I got it all working as a plugin that references that variable. I was having some trouble with some of the scoping, but eventually was able to turn this into a couple of functions to make it easier to look at.

The next step was just converting what was in my script command to set up the variable with plugin commands to make it a little easier on myself for editing what prints, so I wouldn't have to come back into this common event. I decided to store all of the data just in the plugin and then make plugin parameter settings where you can turn these on or off individually. I was going to have users be able to input that data themselves, but it was getting a bit complicated and I honestly will probably just use this internally anyways, so I decided to keep it all within the plugin itself. So I spent some time adding help files and parameters that you could turn on or off.

I had a lot of fun towards the end adding a bunch of parameters and seeing what data might be most useful to print. With the ability to turn them on and off, I figured I could add some that might be useful in some of my projects but not in others. I'm sure I'll continue to add to this list as I think of more parameters to add, but for now I'm calling it done! So below is the log folder with one of the log files opened.

And then because I spent so much time on polishing this plugin up, I decided to officially publish it on itchio! You can download it yourself here and use it in your projects.

So with that, I can officially say that I've finished my first RPG Maker plugin! I did a lot of research and was working on some various other plugins for this project and another one before this, but those were a lot more of learning experiences with a lot of stitched together code. For this, I feel like I understand what everything's doing fully and was able to write it on my own without a lot of coding references, and mostly core RPG Maker and JavaScript code. So I'm happy that I was able to finally do it! I've been wanting to make a plugin for awhile, so this was finally my leap into making one. And I'm hoping it'll be helpful to use across multiple projects. Maybe someone else will even find it useful for their projects too!
I know this dev log was definitely more technical and text-heavy than I usually do without many visuals (and the visuals were just more text!). But thanks for reading through my programming journey on making this plugin!
Get Debug Log File Plugin for RPG Maker MZ
Debug Log File Plugin for RPG Maker MZ
Generate debug log files for RPG Maker MZ
Leave a comment
Log in with itch.io to leave a comment.