Hello!
I'm hoping to execute this plugin command through Java script, so that I can replace the arguments (I think thats what theyr're called) with game variables. Correct me if I'm wrong, but I don't think plugin commands support java script or text-based variable calls...
The plugin command I want to invoke is: CopyActor x y
(I want x = variable1, while just using 4 for y)
Plugin:
Copy Actors
Version 1.00
SumRndmDde
So, I tried the following :
Script attempt at plugin command:
CopyActor $gameVariables.value(1) 4
Text attempt at plugin command:
CopyActor \V[1] 4
Both have failed... which is why I think using a script, instead of a plugin command would work better.
Thank you a thousand times!!
Script for plugin command
● ARCHIVED · READ-ONLY
-
-
you completely misunderstood what the plugin command does.
If someone writes a plugin with a function, then he can include in that plugin an option to respond to plugin commands.
The plugin command itself is nothing but a text line that is transfered to the plugin to be parsed and processed there.
So if you want to change how the plugin command works, you need to rewrite the plugin itself.
The alternative is using a script function, but again the plugin needs to provide that script function. It is nothing that would work on general purpose but only specific to each plugin.
And if the plugin does not contain the script function you want, then it needs to be rewritten to give that option. -
you completely misunderstood what the plugin command does.
If someone writes a plugin with a function, then he can include in that plugin an option to respond to plugin commands.
The plugin command itself is nothing but a text line that is transfered to the plugin to be parsed and processed there.
So if you want to change how the plugin command works, you need to rewrite the plugin itself.
The alternative is using a script function, but again the plugin needs to provide that script function. It is nothing that would work on general purpose but only specific to each plugin.
And if the plugin does not contain the script function you want, then it needs to be rewritten to give that option.
Thanks for the quick response, Andar!
So you're saying what I'm trying to do is essentially impossible for someone like me who knows nothing about Java script?
Here's what I found on how to use script instead of a plugin command:
var aliasPluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
aliasPluginCommand.call(this, command, args);
if (command === 'plugincommandtextname') {
dostuff(args);
}
};
This doesn't mean anything to me... I've tried to deconstruct it, referencing SumRndmDde's code, but I just can't wrap my brain around it. I also found this website and tried to follow it, but failed again. https://rpgmakermv.co/threads/scripting-how-to-call-a-plugin-command-in-script.3307/
Any guidance would be incredibly appreciated!
Thank you! -
it can be done, but as you realised yourself the person doing that needs to be able to read the code.
In your example the next step would be to search for "dostuff(args)", because that would be the place where the command gets executed, and where the arguments of the plugin command are turned into scriptcode. -
That author is a member of this forum, and he probably has a thread here for the plugin. Why don't you just ask him if he can make it accept variables (or do an evaluation of the arguments)?
-
@SumRndmDde, is there any way you could help me with this? I did a quick search of the forum for a thread dedicated to this plugin, but I didn't find one (I also checked the youtube thread for this plugin for any leads).
-
Well, you can instead use the script command directly to do what the plugin command would do.
Use the following script call:
Code:var id = $gameVariables.value(1); var currentIndex = $gameSystem.copyIndex; $gameParty.addActor(_.createCopy(id).id); $gameActors.actor(currentIndex).setup(currentIndex); $gameVariables.setValue(4, currentIndex); -
Thank you so much Naveed! I will try this outWell, you can instead use the script command directly to do what the plugin command would do.
Use the following script call:
Code:var id = $gameVariables.value(1); var currentIndex = $gameSystem.copyIndex; $gameParty.addActor(_.createCopy(id).id); $gameActors.actor(currentIndex).setup(currentIndex); $gameVariables.setValue(4, currentIndex); -
When I use this script, i get the error: "_ is undefined" do I need to replace "_" with something else?Well, you can instead use the script command directly to do what the plugin command would do.
Use the following script call:
Code:var id = $gameVariables.value(1); var currentIndex = $gameSystem.copyIndex; $gameParty.addActor(_.createCopy(id).id); $gameActors.actor(currentIndex).setup(currentIndex); $gameVariables.setValue(4, currentIndex); -
Does anyone have any additional opinions on this? I'm still trying to figure it out.
-
Try SRD.CopyActor.createCopy([your id here]);
-
Hey, sorry for the late reply, but I made a plugin just for this kind of thing!
First, install this plugin: http://sumrndm.site/plugin-command-evals/
Then, within a plugin command, replace one of the parameters with ${ eval-here }
Replace "eval-here" with a JavaScript eval.
For example, for your issue, you would need to do:
Code:CopyActor ${ $gameVariables.value(1) } 4
The "${ $gameVariables.value(1) }" is the evaluated and the resulting value replaces it once the command is parsed in other plugins. -
Thank you! Fantastic tutorials and plugins, btwHey, sorry for the late reply, but I made a plugin just for this kind of thing!
First, install this plugin: http://sumrndm.site/plugin-command-evals/
Then, within a plugin command, replace one of the parameters with ${ eval-here }
Replace "eval-here" with a JavaScript eval.
For example, for your issue, you would need to do:
Code:CopyActor ${ $gameVariables.value(1) } 4
The "${ $gameVariables.value(1) }" is the evaluated and the resulting value replaces it once the command is parsed in other plugins.