I was reading this topic by Lavra about how plugin names are tied to filename.
So I looked at what's causing this.
From rpg_managers line 2430, I see this (I haven't updated MV since day 1 so I don't know if it's different now)
PluginManager.setup = function(plugins) { plugins.forEach(function(plugin) { if (plugin.status && !this._scripts.contains(plugin.name)) { this.setParameters(plugin.name, plugin.parameters); this.loadScript(plugin.name + '.js'); this._scripts.push(plugin.name); } }, this);};And it seems like the problem stems from the fact that the filename is used as the key for the plugin in the plugin manager.Now, this is strange: why should the filename be used as the key?
One issue is that plugins by default do not have an identifier. The plugin.js file that's generated only stores the name of the file along with the parameters.
Lavra's solution works well as it provides an identifier with which plugin writers use.
But could we have this integrated into the core somehow by default?
Perhaps have a standard annotation that the plugin manager will search for and use.
eg:
@pluginName My Plugin NameAnd then I can query the plugin parameters with
That way, no one needs to worry about the name they use for their plugin.As an alternative to specifying an annotation, we could just specify a param:
PluginManager.setup = function(plugins) { plugins.forEach(function(plugin) { var registeredName = plugin.parameters['_PluginName'] || plugin.name; if (plugin.status && !this._scripts.contains(registeredName)) { this.setParameters(registeredName, plugin.parameters); this.loadScript(plugin.name + '.js'); this._scripts.push(registeredName); } }, this);};And now, all I need to include in my plugin is
And again, the following query will work
assuming users leave that parameter alone.It would be nice if something like is already planned in a future update so there is a uniform way for scripters to provide an internal name for their plugin without having to worry about end-users' own naming preferences.
So I looked at what's causing this.
From rpg_managers line 2430, I see this (I haven't updated MV since day 1 so I don't know if it's different now)
PluginManager.setup = function(plugins) { plugins.forEach(function(plugin) { if (plugin.status && !this._scripts.contains(plugin.name)) { this.setParameters(plugin.name, plugin.parameters); this.loadScript(plugin.name + '.js'); this._scripts.push(plugin.name); } }, this);};And it seems like the problem stems from the fact that the filename is used as the key for the plugin in the plugin manager.Now, this is strange: why should the filename be used as the key?
One issue is that plugins by default do not have an identifier. The plugin.js file that's generated only stores the name of the file along with the parameters.
Lavra's solution works well as it provides an identifier with which plugin writers use.
But could we have this integrated into the core somehow by default?
Perhaps have a standard annotation that the plugin manager will search for and use.
eg:
@pluginName My Plugin NameAnd then I can query the plugin parameters with
Code:
PluginManager.parameters("My Plugin Name")
PluginManager.setup = function(plugins) { plugins.forEach(function(plugin) { var registeredName = plugin.parameters['_PluginName'] || plugin.name; if (plugin.status && !this._scripts.contains(registeredName)) { this.setParameters(registeredName, plugin.parameters); this.loadScript(plugin.name + '.js'); this._scripts.push(registeredName); } }, this);};And now, all I need to include in my plugin is
Code:
@param _PluginName@default My Plugin Name
Code:
PluginManager.parameters("My Plugin Name")