I'm going to be direct and respond to the individual parts of your response:
Scene_Boot.start and .create are both appropriate places to perform this if .terminate is too late in the scene boot process. If another plugin completely overwrites either of these functions then that plugin needs to be changed because that is a very destructive thing to do. We should never overwrite such fundamental functions, only extend them.
You could easily put your own version of a postDatabaseLoaded function in Scene_Boot.start, as it's is run after isDatabaseLoaded() returns a definite true anyway. That is the appropriate approach and ensures all these notetag reading functions are executed at the right time and only once. It also doesn't make confusing data alteration a part of a function that is only meant to return the status of the database loading.
Unfortunately, I don't have control over what other plugin writers do and don't do. An instance of this very thing would be the
Skip Title Screen.
And it's not just once either. Multiple people are doing it. And what they do with their plugins is none of my business, be it "good practice" or "bad practice". That said, I'm going to avoid Scene_Boot because people are likely to modify it, and I will have no control over it.
And most other plugin writers might not share the sentiment that a function that is meant to return the load status of the database objects now also -- and with no way around it -- executes your notetag data reading functions before returning true. Every time. The right thing to do is to create another function, for example "Yanfly.Core.areNotetagsLoaded()" and return the status of whether notetag loading has been performed or not, and have the actual notetag reading performed in a separate function run from Scene_Boot.start or Scene_Boot.create. This means that one could check whether your notetags are loaded or not separately, and the isDatabaseLoaded() function wouldn't be muddled with actual data reading. Because again, it's not what it's for.
Also, I'll demonstrate something for you regarding the whole areNotetagsLoaded() bit. Here's something I altered (temporarily) to simulate what you're suggesting to do.
Yanfly.Core.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;DataManager.isDatabaseLoaded = function() { if (!Yanfly.Core.DataManager_isDatabaseLoaded.call(this)) return false; console.log('Database Is Loaded'); if (!this._YanflyCoreNotetagsAreLoaded) { this._YanflyCoreNotetagsAreLoaded = true; this.processCORENotetags1($dataItems); this.processCORENotetags1($dataWeapons); this.processCORENotetags1($dataArmors); this.processCORENotetags2($dataEnemies); this.processCORENotetags3($dataActors); this.processCORENotetags4($dataClasses); } console.log($dataActors[1].maxLevel); return true;};
I inserted two console logs there. And in the process of loading, I've disabled the loading process from occuring multiple times. Let's see what happens when I start up the game in 20 tries.
This happened 18 times out of 20:
This happened 2 times out of 20:
$dataEntries are sometimes refreshed completely albiet rarely. Even if the chances of that happening are small, I'm not going to risk impacting the game developer by having the player experience of the game working properly or not. And on a personal level, I'm completely in favor of helping the game developer deliver over "bad practices".
It's not about what I consider bad practice; it is bad practice. It has nothing to do with preference either: putting data alteration code into a function that is written to return the status of whether the database is loaded or not is simply not fine. Do note that no database data handling is done in this function by default; it simply checks if the database objects have been retrieved.
Even if that percentage was true (but it's not, because we have no idea of knowing), isDatabaseLoaded() could still be called a lot of times during boot. If more and more of your plugins add to these notetag readings, and more and more other plugins need to check the status of whether the database is loaded or not at startup, it can have actual impact on startup time. And that is not acceptable when there are far better places to put the code and ensure it's only run once.
There is no reason to keep it in DataManager.isDatabaseLoaded(), neither from a logical or a practical standpoint.
I've asked you before, where do you suggest loading up the notedata? You answered Scene_Boot, but to me, that's not acceptable because of these problems:
- DataManager.extractMetaData fails to distinguish types of data.
- DataManager.onLoad loads strictly in the order of actors, classes, skills, items, weapons, armors, enemies, troops, states, animations, tilesets, common events, system, and types. This becomes a problem when you need an actor notetag to reference something in say, an enemy notetag.
- Scene_Boot.start is a no go for me because some plugins completely overwrite it.
- Scene_Boot.create also gets overwritten in some plugins.
- Scene_Boot.terminate occurs too late, in some instances where functions that fun in Scene_Boot.start already occur and require the note data.
I'll ask you once again. Where do you suggest loading up the notedata? Only this time, I'll ask that it does not involve the five listed problems seen above. If you answer Scene_Boot.start() and Scene_Boot.create(), should I expect that you cause a scene (heh) like you did here in each plugin thread or post that violates your statement from earlier?
If another plugin completely overwrites either of these functions then that plugin needs to be changed because that is a very destructive thing to do. We should never overwrite such fundamental functions, only extend them.
And as for this:
Seems like a valid reason for argument to me. While I agree that getting code out the door is important, what's more important is improving the already great code and taking criticism from peers on what's either wrong or needs improving. You also may not know this, but most people that talk about JS/Ruby/Code on this forum are real life programmers.
I'm all for criticism. And you may not know this either, but I'm a 'real life programmer', too. But being one, I can tell you straight up that being a 'real life programmer' and being an 'RPG Maker programmer' is vastly different. Oh, and let me post a blurb from
another post I've made:
A brief history of my plugin creation process: I originally went with the extractMetaData function. However, because it wasn't doing what I wanted it to, I switched over to Scene_Boot, and realized that wasn't too effective a few weeks down the line. I eventually came to the conclusion that the best time to load and extract all the notetag data is during the time the entirity of the game's database is finished loading, which is where I got to for my plugin library today. Overall, I've made two major switches for the entirity of my notetags.
That said, I'm open to criticism. There comes a problem in when doing something for a long time, programming styles can become stiff and uninnovative. That's why if you are to shed some light on where you can see my plugins can make an improvement, do share. Making a third switch for notetags isn't something I'm unwilling to do if I feel it's more beneficial.
I'm not unwilling to make changes. However, for me to make a change, my terms and conditions must be fulfilled, for they impact the player experience if not.