How do I give a plugin command within a script?

Hello,

I apologize for all of the questions lately. I tried finding the answer to this on my own, but didn't have much luck.

I looked in the "RPG Maker MV Script Call List" () but couldn't really understand what I was looking at...

I just want to know how to use a "plugin command" in a script.

Earlier, ATT was kind enough to help me with a script to stop my screen from shaking when I get attacked:

Game_Actor.prototype.performDamage = function() {
Game_Battler.prototype.performDamage.call(this);
if (this.isSpriteVisible()) {
this.requestMotion('damage');
} /*else {
$gameScreen.startShake(5, 5, 10);
}*/
SoundManager.playActorDamage();
};

Then, I found the RMMV - Screen Shake plugin (https://theoallen.itch.io/rmmv-screenshake) from Theo that lets you shake the entire screen with the call, for example, Shake 10 45.

How can I use this "Shake 10 45" plugin command in the script that ATT gave me?

Currently, now when I get hit, thanks to ATT's script, the screen no longer shakes, but if I wanted it to shake, I would try something like this:

Game_Actor.prototype.performDamage = function() {
Game_Battler.prototype.performDamage.call(this);
if (this.isSpriteVisible()) {
this.requestMotion('damage');
} else {
ShakeScreen.pluginCommand(10, 45);
}
SoundManager.playActorDamage();
};

This results in a ReferenceError saying that "shakeScreen" is not defined.

So, how can I access the ShakeScreen script and call a command from it within another script?

Any help would be appreciated.
It's at the bottom of the "page 3" section in that spreadsheet: interpreter.pluginCommand(command, args);.

E.g. interpreter.pluginCommand("Shake", [10,45]) for your example.
You just need to pass a reference to the interpreter to wherever you'll be using it.
Thanks a lot for your help, but I really don't understand.

I tried doing this:

PluginManager.callCommand(
this,
'ScreenShake', //this is the name of the script I want to use
'SET_SELF_VARIABLE', //I have no idea what this is
{ index: '1', type: '0', operand: '20' }
);

Game_Actor.prototype.performDamage = function() {
Game_Battler.prototype.performDamage.call(this);
if (this.isSpriteVisible()) {
this.requestMotion('damage');
} else {
interpreter.pluginCommand("Shake", [10,45]); //should I use "this" or "interpreter" here?
}
SoundManager.playActorDamage();
};

And of course, nothing happens.

I tried using "this.pluginCommand("Shake", [10,45]): but that doesn't do anything, either.

I can't really understand what I am reading in the documentation. I don't know what the "SET_SELF_VARIABLE" part is in the callCommand() and I can't understand what the index, type, or operand are referring to.
As a general rule you don't need/want to. Just find the function inside of the plugin that's being called by that plugin command and call it directly.

In this case, $gameTemp.shake_screen(10, 45)

Yanfly also has a plugin that lets you call plugin commands as code without trying to figure out what the interpreter is and such.
My apologies, ATT, but I can't really understand what you mean. My skull is particularly thick, you see.

The function inside the script is "Shake," so, if I want to use ShakeScreen's (the name of the script) command "Shake," how can I do that with $gameTemp.shake_screen(10, 45)?

Could I do what you are suggesting within RPG Maker MV currently, or is that the command I would use after making installing Yanfly's plugin?
The function inside the script is "Shake,"
No, it's not. It's $gameTemp.shake_screen()

1699152044741.png


so, if I want to use ShakeScreen's (the name of the script) command "Shake," how can I do that with $gameTemp.shake_screen(10, 45)?
Replace the line in the code above that says $gameScreen.startShake (and get rid of the /* */ that are commenting out a portion of code, preventing it from being run).
but I can't really understand what you mean.
The "Plugin Command" is basically a translator function that translates a human-readable command into the true programming function used inside the plugin.
The intention here is that you can use those function without any form of javascript knowledge.

The suggestion above was to bypass all translations since you are already using javascript and have no need to ignore that.
You tried: give me a function that uses the placeholder plugin commands and feed them to a translater to execute the unknown javascript function in the plugin.
ATT_Turan said: skip all that, look for the true function in the plugin code and call that without the hassle of the translator framework.
Just to add:
PluginManager.callCommand(
this,
'ScreenShake', //this is the name of the script I want to use
'SET_SELF_VARIABLE', //I have no idea what this is
{ index: '1', type: '0', operand: '20' }
);
This is the MZ version: see the 2 columns of checkboxes, MV and MZ, down the left-hand side of the sheet? Plugin Command has 1 example for each engine:
  • MZ specifies plugin commands with a file name and a command name.
  • MV uses a different format with only a command name, like Mac said.
Regardless, for proper fidelity you need to have a reference to an event interpreter, which you don't have in the Game_Actor#performDamage method (this returns a Game_Actor instance there, not Game_Interpreter).

Turan's suggestion is more direct and will work independent of context.

Incidentally, I'd recommend browsing the Script Call List in "full" mode rather than embedded/plain mode. That allows features like frozen rows/columns and internal links to work as intended:
https://docs.google.com/spreadsheets/d/1-Oa0cRGpjC8L5JO8vdMwOaYMKO75dtfKDOetnvh7OHs/

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-give-a-plugin-command-within-a-script.162676/