And it's completely off topic.
You don't see an issue with having every single plugin check if it's the one to execute the command, when the first one that checks is the one that needs to do it? You don't see a performance issue with running ALL the checks in ALL the plugins, when you could reduce the number of plugins that are checked just by stopping the recursion when you've found the right one?
wait... sorry... i guess i misunderstand what you mean earlier...
i misread your post. and i though the problem lies with same aliased name used over and over again.
(i read it at 3 am btw >.<)
now i see what you mean
😀 .
how about creating a hash containing your command keyword (sorta like imported variable we always use)
then access it like hash instead if's.
example:
var hashname = hashname || {}; <<<< init if people haven't register any command...
hashname["COPY_EVENT"] = Game_Interpreter.prototype.myfunction; << register our command here... just like aliasing...
😀
at the top of the plugin. just like our old imported
😀 .
edit: this might need at the bottom of the plugins after we create the Game_Interpreter.prototype.myfunction
if we put it above. it might throw error maybe?
then to access it maybe?
in game interpreter:
var est_myalias = Game_Interpreter.prototype.pluginCommand; Game_Interpreter.prototype.pluginCommand = function(command, args) { if(hashname[command.toUpperCase()]) return hashname[command.toUpperCase()].call(this,args); return est_myalias.call(this, command, args); };edit: changed to call the alias last so if key found. don't need to interpret it again if we do found the match..
<also let's call the if blablabla above as return hash access for now>
i'm not 100% sure though.
😀 . need some test first
but by my logic it could work...
ex:
scripter a => alias original mv plugin command
add return hash access like above.
when executed it will check original mv plugin command / any people alias the plugin command
then stop when reaching return hash access. execute the function.
edit: since i change calling alias after return hash access. then the aliased might not executed at all if found match
scripter b => alias scripter a
add return hash access
when executed. it will run the alias first. and stop when reaching return hash access at "scripter a" the add return hash access in this modification is never executed.
edit: since i change calling alias after return hash access. then the aliased might not executed at all if found the command match
viable??? if yes... can we decide on community variable name for the hash (like our beloved imported... btw who the first scripter that use imported? anyone know?)
edit2: some example 'full' code:
var est_myalias = Game_Interpreter.prototype.pluginCommand;Game_Interpreter.prototype.pluginCommand = function(command, args) { if(hashname[command.toUpperCase()]) return hashname[command.toUpperCase()].call(this,args); return est_myalias.call(this, command, args);}; Game_Interpreter.prototype.myfunction = function(args) { // do something here}; var hashname = hashname || {};hashname['COPY_EVENT'] = Game_Interpreter.prototype.myfunctionedit 3: by calling the return hash access first before the alias... we're also indirectly 'forcing' people to also use the hash access. if using aliasing like what we currently do... it will be forced the plugin command checking to behind.
(except if you put your plugin check before the calling alias too and place the plugin at the top most of plugin manager LOL)
not to mention if many scripter use this method... it might have many duplicate if's check for hash value.
when checking 'default aliasing' plugin command
so i'm not sure... is this a good approach or not.
ex:
scripter a = alias like usual
scripter b = use hash access.
scripter c = use hash access.
scripter d = use hash access.
when the command for scripter a plugins show up... it will execute 3 duplicate ifs check before executing scripter a plugin command...
sorry for so many edit... while typing this... more idea show up.
😀 .