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
32,345
Reaction score
8,078
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
32,345
Reaction score
8,078
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

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,866
Reaction score
14,520
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
148
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
425
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
 

Latest Threads

Latest Profile Posts

Paid material WIP~
EysZO9cVEAEWy9W

This is Alchemy pack.
I decided to add more witch elements.

Now we have wooden props, candles, pots, and potion bottles.
We also want to add herbs, kettles, fireplaces, etc.
First posts! Maybe I can use this update?
Using MV here: can i move blocks around in the event page and i'm just too stupid to do it or does it only look like you should be able to do it and i would always need to cut and paste?
Aba, aba chgb rtb fhz.
Ubp rfg hahz qr snohyvf srpv, cbfg bzarf.
Rtb vhfghf ibyb hg ivtvyb ubp hahz rk yhqb.
Qbarp fvathyvf yhqvb yhqvhf cbgrfg, aba zntvf.

Streaming Anterograde Fantasy, a new game I'm working on

Forum statistics

Threads
110,386
Messages
1,052,882
Members
143,440
Latest member
casoliopp
Top