- Joined
- Apr 12, 2012
- Messages
- 2,604
- Reaction score
- 1,959
- First Language
- English
- Primarily Uses
- RMMV
So it's come to my attention recently that a fair number of plugin support questions/"bugs" have been caused by the users not realising that they need to name the file exactly as per the string referenced in the call to Plugin.parameters...but what if that weren't the case? Having looked into this, I've come up with a potentially better way, but I'd like the opinions of other scripters in the community on this method:
This gets the name of the .js file that's being processed and gets its filename, then uses that as the argument to PluginManager.parameters. This means that no matter what a user calls the file itself, it'll still get the parameters appropriately.
Does anyone have any thoughts on this or potential issues I haven't considered?
Code:
var currentScriptPath = document.currentScript.src;
var startIndex = currentScriptPath.lastIndexOf('/') + 1;
var numChars = currentScriptPath.lastIndexOf('.') - startIndex;
var currentScriptName = currentScriptPath.substr(startIndex, numChars);
var parameters = PluginManager.parameters(currentScriptName);
Does anyone have any thoughts on this or potential issues I haven't considered?

