PROPER way to get parameters?

The code below retrieves the parameters filename-independent.

// Get Plugin Parametersvar params = $plugins.filter(function(p) { return p.description.contains('<SilverSkipTitle>'); })[0].parameters;alert(params.ReallySkipTitle);However, you still gotta store it somewhere so you don't have to convert a parameter to an int or bool or etc. every frame.

Snippet from Yanfly:

Yanfly.Parameters = PluginManager.parameters('YEP_VictoryAftermath');
Yanfly.Param = Yanfly.Param || {};
 
Yanfly.Param.VAOrder = String(Yanfly.Parameters['Victory Order']);
This does not seem to be filename independent. Renaming it would probably cause a problem (not entirely sure).

However, he DOES store it nicely in some sort of container (Yanfly.Param) and he can use spaces in his parameter names, which looks nicer.

What is the suggested most correct way to use parameters for a fairly large script?
The code below retrieves the parameters filename-independent.

// Get Plugin Parametersvar params = $plugins.filter(function(p) { return p.description.contains('<SilverSkipTitle>'); })[0].parameters;

alert(params.ReallySkipTitle);

However, you still gotta store it somewhere so you don't have to convert a parameter to an int or bool or etc. every frame.

Snippet from Yanfly:

This does not seem to be filename independent. Renaming it would probably cause a problem (not entirely sure).

However, he DOES store it nicely in some sort of container (Yanfly.Param) and he can use spaces in his parameter names, which looks nicer.

What is the suggested most correct way to use parameters for a fairly large script?
I'd say you just combine both of those methods. Like:

Code:
Foo.parametersData = $plugins.filter(function(p) { return p.description.contains('<_xyz_>'); })[0].parameters;Foo.Parameters = Foo.Parameters || {};Foo.Parameters.Bar = Number(Foo.parametersData['Parameter Name']); //optionally with a "|| 0" for example for a fail-safe default value
I used this for my latest plugin:

Code:
var _params = (function($) {    return {        languages: $['Supported Languages'].split(/\s*,\s*/).filter(function(value) { return !!value; }),        filePath: $['File Path'],        textRegex: new RegExp('\\\\' + $['Escape Code'] + '\\[(.+)\\]', 'g'),        menuEntry: $['Add Menu Entry'].toLowerCase() === 'true'    };})($plugins.filter(function(p) { return p.description.contains('<Iavra Localization>'); })[0].parameters);
Not the easiest to read, but it retrieves, converts and stores parameters in one closed block and forms a nice closure for me.
The way I do it is: 

var SomePluginNamePluginParamaters = PluginManager.parameters('Script-Name');Works for me.
I got this now:

var Silv = Silv || {};Silv.Parameters = $plugins.filter(function(p) { return p.description.contains('<SilverItemLog>'); })[0].parameters;Silv.ItemLog = Silv.ItemLog || {};Silv.ItemLog.WindowWidth = parseInt(Silv.Parameters['Window X']);Silv.ItemLog.WindowHeight = parseInt(Silv.Parameters['Window Y']);Silv.ItemLog.Window_X = parseInt(Silv.Parameters['Window Width']);Silv.ItemLog.Window_Y = parseInt(Silv.Parameters['Window Height']);(function(){    alert(Silv.ItemLog.WindowWidth);    alert(Silv.ItemLog.WindowHeight);    alert(Silv.ItemLog.Window_X);    alert(Silv.ItemLog.Window_Y);        })();The good part about this is that other plugins could also access this data now.

@Iavra

Wow that is some serious coding, you are not new to JS I see. But it indeed reads a bit awkward at first. But it makes sense. Mmmm... I might prefer the method I just posted because it would probably (not sure) be easier to debug in case of a typo. Performance-wise there can hardly be a difference anyway. Or am I totally wrong here in my conclusions?

The way I do it is: 

var SomePluginNamePluginParamaters = PluginManager.parameters('Script-Name');
Works for me.
It works but will suffer from unnecessary performance issues (you have to convert/cast the variables when you actually use them, which may be inside loops) and renaming your plugin may break your plugin now. AND you can't have spaces in parameter names.
Hmm, this way your parameters are available via your namespace "Silv" and can be used by other people. I don't like this, so i declare them as local variables inside my self-executing function.


I always try to make only those variable/functions publicly available that i want other people to know about and be able to modify.
If I want something public I create a very specific API and then attach that to the window. 
I just noticed I can't add spaces to default values. But you can add them as a user in the [F10] menu 🙁 .

But another advantage of using variables like this is to debug them easier:

vars.png

Original thread: https://forums.rpgmakerweb.com/threads/proper-way-to-get-parameters.49027/