MZ How to Do Parameter Call in RPG Maker MZ???

Hi, I just tried the new RM MZ, converted my RM MV project manually, and overall it went very smoothly.

Yes, I mean very smoothly because a lot of non-windows/scene-related plugins from MV works really well in MZ.

However, I still can't make any plugin with parameter to work properly.

Just like this one. This is a small plugin that I made to change the actor's sprites if they change armor/weapon/accessories. It execute a Common Event if you equip something in your equipment slot. I imported it directly from its RM MV version like other plugins:

Spoiler: But the code IS NOT WORKING
Parameter.PNG

Parameter1.PNG

That one didn't work at all. Changed the parameters type to "number", to "common event", etc ... no luck. Not even an error alert in the console.
However, if I manually changed the equipCommonEventId value to the referred Common Event ID just like this:

Spoiler: The code IS WORKING PROPERLY ._.
The actor is now wearing the proper cloth according to the equipped items!
Parameter2.PNG

I guess I made a grave mistake. But where?
I humbly ask you to teach me how to call a parameter in RM MZ. Any help will be appreciated.
You may need to add the @target MZ annotation to your plugin. It's required for MZ plugins to differentiate them from MV ones.
You may need to add the @target MZ annotation to your plugin. It's required for MZ plugins to differentiate them from MV ones.

Just did that. The @target MZ annotation only help nullifying "the plugin "RAITH_EquipCommonEventMZ" may not support RPG Maker MZ" alert in Plugin Manager
However, I still can't make any plugin with parameter to work properly.
Just like this one. This is a small plugin that I made to change the actor's sprites if they change armor/weapon/accessories. I humbly ask you to teach me how to call a parameter in RM MZ. Any help will be appreciated.

Spoiler: Plugin Parameters Example
Writing a very basic example for max battlers...
...it might help ya so I'll share now (very very early stages though)
CTB_MaxBattlers.js
Code:
//=============================================================================
// RPG Maker MZ - CT_Bolt's Max Battlers
//=============================================================================

/*:
* @target MZ
* @plugindesc v1.00 CT_Bolt's Max Battlers
* @author CT_Bolt
*
* @param Max Battlers
* @text Number of Max Battlers
* @desc Number of Max Battlers
* @default
*
* @help CTB_MaxBattlers.js
*
* This plugin provides MaxBattler settings.
*
*/

var CTB = CTB || {}; CTB.MaxBattlers  = CTB.MaxBattlers || {};
var Imported = Imported || {}; Imported["CTB_MaxBattlers"] = 1.00;

(($_$) => {
    const pluginName = "CTB_MaxBattlers";
    function getPluginParameters() {var a = document.currentScript || (function() { var b = document.getElementsByTagName('script'); return b[b.length - 1]; })(); return PluginManager.parameters(a.src.substring((a.src.lastIndexOf('/') + 1), a.src.indexOf('.js')));} $_$.par = getPluginParameters();
    $_$.par['Max Battlers'] = $_$.par['Max Battlers'] || 4;

    Window_BattleStatus.prototype.maxCols = function() {
        return $_$.par['Max Battlers'] || 4;
    };

    Game_Party.prototype.maxBattleMembers = function() {
        return  $_$.par['Max Battlers'] || 4;
    };
})(CTB.MaxBattlers);
Spoiler: Plugin Command Example
Writing a very basic example for sprite modification...
...it might help ya so I'll share now (very very early stages though)
CTB_SpriteExtras.js
Code:
//=============================================================================
// RPG Maker MZ - CT_Bolt's Sprite Extras
//=============================================================================

/*:
* @target MZ
* @plugindesc v1.00 CT_Bolt's Sprite Extras
* @author CT_Bolt
*
* @command set
* @text Set X & Y Offset
* @desc Set X & Y Offset
*
* @arg eventId
* @default 0
* @text Event ID
* @desc Event ID
*
* @arg x
* @default 0
* @text X Offset
* @desc X Offset
*
* @arg y
* @default 0
* @text Y Offset
* @desc Y Offset
*
* @help CTB_SpriteExtras.js
*
* This plugin provides extra sprite features
*
*/

var CTB = CTB || {}; CTB.SpriteExtras  = CTB.SpriteExtras || {};
var Imported = Imported || {}; Imported["CTB_SpriteExtras"] = 1.00;

(($_$) => {
    const pluginName = "CTB_SpriteExtras";

    PluginManager.registerCommand(pluginName, "set", args => {
        //console.log(SceneManager._scene._spriteset._characterSprites);
        var e = SceneManager._scene._spriteset._characterSprites.filter(function(v){
            if (v._character._eventId === eval(args.eventId)) {return v;}
        });  
        e.forEach(function(v){
            v._ctbExtra.x = eval(args.x);
            v._ctbExtra.y = eval(args.y);
        });
    });


    //-----------------------------------------------------------------------------
    // Sprite_Character
    //
    // The sprite for displaying a character.

    $_$['Sprite_Character.prototype.initialize'] = Sprite_Character.prototype.initialize;
    Sprite_Character.prototype.initialize = function(character) {
        $_$['Sprite_Character.prototype.initialize'].apply(this, arguments);
        this._ctbExtra = this._ctbExtra || {x:0,y:0};
        this._ctbExtra.x = this._ctbExtra.x || 0;
        this._ctbExtra.y = this._ctbExtra.y || 0;
    };


    Sprite_Character.prototype.updatePosition = function() {
        this.x = this._character.screenX()+this._ctbExtra.x;
        this.y = this._character.screenY()+this._ctbExtra.y;
        this.z = this._character.screenZ();
    };

})(CTB.SpriteExtras);

That help at all?
If you type "equipCommonEventId" in the console, what does it show?
@ct_bolt That shed some light... Can you give explanation for this part in particular? because it seems important for declaring parameter:

JavaScript:
 * @command set
* @text Set X & Y Offset
* @desc Set X & Y Offset
*
* @arg eventId
* @default 0
* @text Event ID
* @desc Event ID

   const pluginName = "CTB_SpriteExtras";

    PluginManager.registerCommand(pluginName, "set", args => {
        //console.log(SceneManager._scene._spriteset._characterSprites);
        var e = SceneManager._scene._spriteset._characterSprites.filter(function(v){
            if (v._character._eventId === eval(args.eventId)) {return v;}
        });      
        e.forEach(function(v){
            v._ctbExtra.x = eval(args.x);
            v._ctbExtra.y = eval(args.y);
        });
    });

@Trihan It shows "" (just like the code in the screenshot)

[EDIT: added the screenshot for console result]

console.PNG
@ct_bolt That shed some light... Can you give explanation for this part in particular?
Sorry I was confused at first thought you needed plugin commands... so gave you example of that but also have an example for ya now of parameter setup too.

Are you looking for parameters or plugin commands?
Parameters are like this:
Code:
/*:
* @target MZ
* @plugindesc v1.00 CT_Bolt's Max Battlers
* @author CT_Bolt
*
* @param Max Battlers
* @text Number of Max Battlers
* @desc Number of Max Battlers
* @default
*
* @help CTB_MaxBattlers.js
*
* This plugin provides MaxBattler settings.
*
*/

var CTB = CTB || {}; CTB.MaxBattlers  = CTB.MaxBattlers || {};
var Imported = Imported || {}; Imported["CTB_MaxBattlers"] = 1.00;

(($_$) => {
    const pluginName = "CTB_MaxBattlers";
    function getPluginParameters() {var a = document.currentScript || (function() { var b = document.getElementsByTagName('script'); return b[b.length - 1]; })(); return PluginManager.parameters(a.src.substring((a.src.lastIndexOf('/') + 1), a.src.indexOf('.js')));} $_$.par = getPluginParameters();

    // Just set default in case none was specified in via plugin manager
    $_$.par['Max Battlers'] = $_$.par['Max Battlers'] || 4;
    console.log($_$.par['Max Battlers'])

})(CTB.MaxBattlers);
More info here: https://tkool.jp/mz/plugin/make/koushiki.html
...though that might not really be too much more helpful lol]
@ct_bolt The parameters. Oh my god I clicked and quick copy-pasted the second spoiler -____-
Please pardon my 23.41 GMT+7 partial sleepiness.

I meant this part:

JavaScript:
    const pluginName = "CTB_MaxBattlers";
    function getPluginParameters() {var a = document.currentScript || (function() { var b = document.getElementsByTagName('script'); return b[b.length - 1]; })(); return PluginManager.parameters(a.src.substring((a.src.lastIndexOf('/') + 1), a.src.indexOf('.js')));} $_$.par = getPluginParameters();
    $_$.par['Max Battlers'] = $_$.par['Max Battlers'] || 4;

    Window_BattleStatus.prototype.maxCols = function() {
        return $_$.par['Max Battlers'] || 4;
    };

I never see that "getPluginParameters()" back in MV...
What does the console show if you do "parameters"?
@ct_bolt The parameters.

I never see that "getPluginParameters()" back in MV...

I created that "getPluginParameters" function myself, used in mostly all my MV plugins. Easiest way to get the parameters without knowing the filename or having any keywords inside the plugin file.

Well anyways...
Trimmed out the unnecessary parts...

CT_Bolt's Parameter Tech Demo
Spoiler
Code:
/*:
* @target MZ
* @plugindesc v1.00 CT_Bolt's Parameter Tech Demo
* @author CT_Bolt
*
* @param Parameter Name
* @desc Parameter Description
* @default
*/
var CTB = CTB || {}; CTB.ParameterTechDemo  = CTB.ParameterTechDemo || {};
(($_$) => {
    function getPluginParameters() {var a = document.currentScript || (function() { var b = document.getElementsByTagName('script'); return b[b.length - 1]; })(); return PluginManager.parameters(a.src.substring((a.src.lastIndexOf('/') + 1), a.src.indexOf('.js')));}
    // Store/Set the parameters
    $_$.par = getPluginParameters();

    // Just set default in case none was specified in via plugin manager
    $_$.par['Parameter Name'] = $_$.par['Parameter Name'] || 0;
    console.log($_$.par['Parameter Name'])
})(CTB.ParameterTechDemo);

That help make it clearer I hope at least a little?

Edit: Posted again below cuz this may have been missed... also to prevent you from double posting
What does the console show if you do "parameters"?
"do", like this?
@ct_bolt The parameters.
I never see that "getPluginParameters()" back in MV...

I created that "getPluginParameters" function myself, used in mostly all my MV plugins actually.
Found it to be the easiest way to get the parameters without knowing the filename or having any keywords inside the plugin file.

Well anyways...
Trimmed out the unnecessary parts...

Spoiler: CT_Bolt's Parameter Tech Demo
Code:
/*:
* @target MZ
* @plugindesc v1.00 CT_Bolt's Parameter Tech Demo
* @author CT_Bolt
*
* @param Parameter Name
* @desc Parameter Description
* @default
*/
var CTB = CTB || {}; CTB.ParameterTechDemo  = CTB.ParameterTechDemo || {};
(($_$) => {
    function getPluginParameters() {var a = document.currentScript || (function() { var b = document.getElementsByTagName('script'); return b[b.length - 1]; })(); return PluginManager.parameters(a.src.substring((a.src.lastIndexOf('/') + 1), a.src.indexOf('.js')));}
    // Store/Set the parameters
    $_$.par = getPluginParameters();

    // Just set default in case none was specified in via plugin manager
    $_$.par['Parameter Name'] = $_$.par['Parameter Name'] || 0;
    console.log($_$.par['Parameter Name'])
})(CTB.ParameterTechDemo);
That help make it clearer I hope at least a little?
"do", like this?
Okay, so it's the first line that's causing issues.

Have you put in the correct name of your plugin?
@ct_bolt I think I will study your works tomorrow morning. The "PluginManager.parameters(a.src.substring((a.src...." part got my attention. It kinds of advanced for me right now (I did not receive formal education for JavaScript) so it may take some times to learn that.

@Trihan I swear I have renamed it, but no change...

The plugin still work if I assign the "29" value manually, tho

Here's a screenshot of the full code along with how it appear in Plugin Manager.

Parameter.PNG
@ct_bolt I think I will study your works tomorrow morning. The "PluginManager.parameters(a.src.substring((a.src...." part got my attention. It kinds of advanced for me right now (I did not receive formal education for JavaScript) so it may take some times to learn that.

Lol ok sounds good but in the mean time...
...Well... decided to write it for ya...

Here's a plugin that will do as you need 😉
CTB_CommonEventOnEquip (MZ Plugin): Click Here to Download

Very very minimal version though (for now at least)
...but does also support javascript in the parameter also so you could use a game variable to set the common event even 😉
Like this:
Spoiler: Plugin Settings & Parameters
1598030657574.png

Using it like that it will "run" whatever common event the game variable #1 has as it's value 🙂
@ct_bolt man, you don't have to do that far, thank you! Guess I'll use it until I know how to make MZ parameter properly.

But yeah, I still need explanation why mine is still not working.
I'll attach the .js file if the others want to look to the problem
@ct_bolt man, you don't have to do that far, thank you! Guess I'll use it until I know how to make MZ parameter properly.

But yeah, I still need explanation why mine is still not working.
I'll attach the .js file if the others want to look to the problem
No prob. 😉

LOL oh my... spotted it right away...
such simple of a problem... (happens to the best of us, don't feel bad)

Soooo yours doesn't work because:
Code:
var parameters = PluginManager.parameters('RAITH_EquipCommonEventMZ.js');
...should be...
Code:
var parameters = PluginManager.parameters('RAITH_EquipCommonEventMZ');
Remove the ".js"
No prob. 😉

LOL oh my... spotted it right away...
such simple of a problem... (happens to the best of us, don't feel bad)

Soooo yours doesn't work because:
Code:
var parameters = PluginManager.parameters('RAITH_EquipCommonEventMZ.js');
...should be...
Code:
var parameters = PluginManager.parameters('RAITH_EquipCommonEventMZ');
Remove the ".js"


Thank you! It worked like a charm!

Aaah, this is so shameful, I thought RPG Maker MZ just pour up some new coding rules :dizzy:

So in conclusion, we can just use the usual, traditional parameter call to work in MZ, and you need to annotate the @target MZ to avoid "plugin doesn't support MZ" notification in the plugin manager.

I hereby declare this thread as solved.
Thank you! It worked like a charm!

Aaah, this is so shameful, I thought RPG Maker MZ just pour up some new coding rules :dizzy:

So in conclusion, we can just use the usual, traditional parameter call to work in MZ, and you need to annotate the @target MZ to avoid "plugin doesn't support MZ" notification in the plugin manager.

I hereby declare this thread as solved.
Wooo! Yay! Yep yep.
Glad it worked as it should & glad I could help out.

Happy Game Making! :popcorn:

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-do-parameter-call-in-rpg-maker-mz.125609/