MZ Detect Which Engine Being Used?

Since I got MZ before getting MV, my plugins are written with MZ in mind, and the bigger the plugins get, the more likely that they CAN'T work with MV. Is there a good way to detect if a plugin is being used in one over the other? I figure the most obvious way is to try calling a function native to MZ, and deciding MV is being used if that fails... but I'd like something a bit less... random-looking? A dev who doesn't look at the code wouldn't notice or care, but a fellow code monkey might be wondering why a ColorManager call(for example) was being tried when there was nothing in the plugin dealing with colors.

Basically I'd like to make all my plugins compatible with both engines without having to code and release a separate version. Ideally I'd detect the engine at startup, have MV and MZ versions of functions with exclusive code, and call the right one based on the engine detected.

Kinda got inspired by reading up on FOSSIL, and thought about doing pretty much the reverse, "retro-proofing" my plugins.
I wish I had this approach before =/
Anyway, you can use the Utils for both: In one engine it will return "MV" in another "MZ".
JavaScript:
if(Utils.RPGMAKER_NAME === "MV"){
// Do MV code
}else{
// Do MZ code
}
I wish I had this approach before =/
Anyway, you can use the Utils for both: In one engine it will return "MV" in another "MZ".
JavaScript:
if(Utils.RPGMAKER_NAME === "MV"){
// Do MV code
}else{
// Do MZ code
}
Awesome, that is EXACTLY what I needed! I'd already gotten the "ColorManager" version working, and along the way discovered I was using try... catch... wrong. MZ didn't care, but MV threw an absolute fit over it. Oh well, I already needed to rewrite parts of my TP Control plugin if I was gonna retro-proof it, I just need to remember to update all the try... catch... code in there while I'm at it.

...also means I need to start studying MV's code as I work on retro-proofing what I have... and as I work on stuff in the future, since I DO eventually want to start working on scenes and such. And I had just started getting a glimmer of hope that I was figuring MZ out.... :dizzy:

Thanks!
Awesome, that is EXACTLY what I needed! I'd already gotten the "ColorManager" version working, and along the way discovered I was using try... catch... wrong. MZ didn't care, but MV threw an absolute fit over it. Oh well, I already needed to rewrite parts of my TP Control plugin if I was gonna retro-proof it, I just need to remember to update all the try... catch... code in there while I'm at it.

...also means I need to start studying MV's code as I work on retro-proofing what I have... and as I work on stuff in the future, since I DO eventually want to start working on scenes and such. And I had just started getting a glimmer of hope that I was figuring MZ out.... :dizzy:

Thanks!

My advice is to open up notepad++, put the rmmv version on the left tab, the rmmz on the right tab, and cross your eyes so you look at both version at once 😛
My advice is to open up notepad++, put the rmmv version on the left tab, the rmmz on the right tab, and cross your eyes so you look at both version at once 😛
I use Visual Studio Code. Could potential still do it that way, but I think the easier option is to try to run my plugins in MV, see what breaks, and chase it down. Right now it's all simple stuff, and the only strict incompatibility I'm aware of in my plugins all involve ColorManager. So if I want to make a retro-proofing plugin like a reverse FOSSIL, that'd be the first place to start. Which I think I might start doing now... the idea has wormed into my brain. This is gonna be a long, hard, frustrating ride.... and I don't think I could come up with as creative a name as FOSSIL....
Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/detect-which-engine-being-used.135622/