Getting parameters by filename instead of hardcoding.

Trihan

Speedy Scripter
Veteran
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:

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);
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?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,355
Reaction score
7,668
First Language
German
Primarily Uses
RMMV
There has been a topic about something like this shortly after MV was released, giving a way to get the parameters independent of filename.
I do not know what was described in that topic, but a lot of scripters simply ignored that option when writing their plugins - and that includes good scripters like Yanfly.

So there has to be a reason why it is not done - that reason might be simple lazyness, or it might be something else. But a method for this was known before.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,959
First Language
English
Primarily Uses
RMMV
I figured there would have been something about it before, but I'm curious as to what that reason is, as I can't think of any downsides to it myself.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top