MZ Using a plugin for holding data?

I just started using RPG Maker (MZ), so I'm a total beginner. I'm kinda just hacking my way thru, just for context, so I definitely need the "explain it to me like I'm an idiot" version of stuff.

Anyway, I had this idea that instead of using a bunch of global variables for some things I need to set and have the game remember, I could define stuff in a plugin and then access it in my main plugin. I know there's parameters that can be accessed, but I need to be able to change them over time, and I dunno how to do that.

I looked at a bunch of other plugins that use registerCommand, and I thought there might be a way to make a command that would change params when I need to do that? I dunno. If anyone has a suggestion, that'd be cool. Thanks!
I could define stuff in a plugin and then access it in my main plugin
If your "main plugin" is what's utilizing these variables why not just define them in your "main plugin"?
Yeah, so, what I'm trying to do is make something that lets me set up dungeons really easily. So the storage plugin holds all that stuff, and only gets called when you first enter the dungeon. But then the main plugin gets called every time you move to a different floor, and I don't wanna have to set all that stuff every floor. I wanna have it set up once and then just use it or change it in that central place. Like I said, I know I could do it with global variables, but I also know that global variables are kinda scary, so I figured maybe this way would be better. Maybe it isn't better, tho.
It's hard to recommend anything when your descriptions are all very vague and you say things like "storage plugin that holds all that stuff". What type of data, how and when it's being called, referenced, and modified, does the player modify it through inputs, is it being saved to the save file, etc?

Also when you say things like "global variables are kinda scary", it implies you don't know what you're doing when it comes to scripting, in which case you should not be writing your own plugins.
Lemme try to give a more concrete example or whatever.
JavaScript:
var mymap2 = PluginManager.parameters('DungeonDefiner')['topmap'];
console.log(mymap2);

What I get back in the console right now is "undefined" which I'm sure makes perfect sense to other people, but what was the right way to write this so I actually got a number back instead?

And here's another related question/example. This works
JavaScript:
PluginManager.registerCommand(pluginName, "setTop", args => {
        var mymap = Number(args.topmap);
        console.log(mymap);
    });

but if I reference args.topmap other places (not in the registerCommand {} things), it's, like, "wtf is args?"

1735938352720.png
can you show the paramters you set up?
JavaScript:
/*
* @command setTop
* @text Set Top Map
* @desc any text
*
* @arg topmap
* @text topmap
* @desc set the top map
* @default 1
*/

so setTop is not defined so make sure you have it defined somewhere.
I don't know how MZ plugin commands works, but parameters are defined
like this, the parameter is more the MV way, MZ is different.

so make sure the plugin name is exactly you defined as well in order to be readed.
1736180194772.png


That's how it's set up. Is there something else that needs to be in there?

can you show the paramters you set up?
JavaScript:
/*
* @command setTop
* @text Set Top Map
* @desc any text
*
* @arg topmap
* @text topmap
* @desc set the top map
* @default 1
*/

so setTop is not defined so make sure you have it defined somewhere.
I don't know how MZ plugin commands works, but parameters are defined
like this, the parameter is more the MV way, MZ is different.

so make sure the plugin name is exactly you defined as well in order to be readed.
plugin commands works inside the register, not outside.

if you want to call it outside that, you need to call it different.

depending what the plugin does.
JavaScript:
//sample

function dataTopMap(...args) {
    let mymap = Number.args["topmap"]
    return $gameSystem._topMap
}

I cannot tell how the data is stored and where, but this is just a sample.
so you probably need to return the value to the sprite map is used there or
whatever you target it for.

if it's more for parallax, there are some out there for MZ, so you can look
how they did that as I'm not familiar with MZ, only MV, but the commands works
different there, so it's hard to tell.

as both support ES5 through ES8, MZ maybe higher, console log should
print correctly, if it does, target it correctly as well to be shown.
plugin commands works inside the register, not outside.

if you want to call it outside that, you need to call it different.

depending what the plugin does.
JavaScript:
//sample

function dataTopMap(...args) {
    let mymap = Number.args["topmap"]
    return $gameSystem._topMap
}

I cannot tell how the data is stored and where, but this is just a sample.
so you probably need to return the value to the sprite map is used there or
whatever you target it for.

if it's more for parallax, there are some out there for MZ, so you can look
how they did that as I'm not familiar with MZ, only MV, but the commands works
different there, so it's hard to tell.

as both support ES5 through ES8, MZ maybe higher, console log should
print correctly, if it does, target it correctly as well to be shown.
Sorry to ask a super dumb question, but what is "inside the register" versus outside?
like you did on the screenshot 🙂 where args works inside pluginRegister
and not outside 🙂
like you did on the screenshot 🙂 where args works inside pluginRegister
and not outside 🙂
See? I knew it was a dumb question!

Original thread: https://forums.rpgmakerweb.com/threads/using-a-plugin-for-holding-data.174393/