Script for plugin command

Blaink

Villager
Member
Joined
Jul 8, 2017
Messages
18
Reaction score
0
First Language
Enlgish
Primarily Uses
RMMV
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!!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,390
Reaction score
7,219
First Language
German
Primarily Uses
RMMV
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.
 

Blaink

Villager
Member
Joined
Jul 8, 2017
Messages
18
Reaction score
0
First Language
Enlgish
Primarily Uses
RMMV
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!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,390
Reaction score
7,219
First Language
German
Primarily Uses
RMMV
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,650
Reaction score
13,263
First Language
English
Primarily Uses
RMMV
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)?
 

Blaink

Villager
Member
Joined
Jul 8, 2017
Messages
18
Reaction score
0
First Language
Enlgish
Primarily Uses
RMMV
@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).
 

Naveed

Veteran
Veteran
Joined
Nov 2, 2013
Messages
314
Reaction score
145
First Language
English
Primarily Uses
RMMV
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);
 

Blaink

Villager
Member
Joined
Jul 8, 2017
Messages
18
Reaction score
0
First Language
Enlgish
Primarily Uses
RMMV
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 out
 

Blaink

Villager
Member
Joined
Jul 8, 2017
Messages
18
Reaction score
0
First Language
Enlgish
Primarily Uses
RMMV
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);
When I use this script, i get the error: "_ is undefined" do I need to replace "_" with something else?
 

Blaink

Villager
Member
Joined
Jul 8, 2017
Messages
18
Reaction score
0
First Language
Enlgish
Primarily Uses
RMMV
Does anyone have any additional opinions on this? I'm still trying to figure it out.
 

Clock Out

Veteran
Veteran
Joined
Jun 14, 2016
Messages
92
Reaction score
45
First Language
English
Primarily Uses
RMMV
Try SRD.CopyActor.createCopy([your id here]);
 

SumRndmDde

Follower of RNGesus
Veteran
Joined
Jul 30, 2013
Messages
225
Reaction score
418
First Language
English
Primarily Uses
RMMV
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.
 

Blaink

Villager
Member
Joined
Jul 8, 2017
Messages
18
Reaction score
0
First Language
Enlgish
Primarily Uses
RMMV
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, btw
 

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

Latest Threads

Latest Profile Posts

Should be able to release Haxe MV/MZ next weekend.
It look that somehow MZ tracks are messed up (for example battle4 is obviously a theme, castle2 is a ship, ship1 is a scene and so on..). Maybe they just named them after with some ambiguity.
is there a script call that return how much turn has passed in battle?
Does anyone find this hard to read?

Enjoying my weekend at home to stay Covid free. How is everyone else doing?

Forum statistics

Threads
100,603
Messages
977,740
Members
132,216
Latest member
Darkscythe25
Top