How do I indicate that I want something to run only when the player uses the plugin command?

FatalErrorDriveB

Villager
Member
Joined
Dec 12, 2019
Messages
16
Reaction score
1
First Language
English
Primarily Uses
RMMV
So I'm sure this is a simple thing, and I've looked through other plugins to see if I could figure it out, but I must be missing it because I can't see what tells the code to run only once called via a plugin command?

To make sure I'm clear enough, basically, I'm writing a card mini-game, and I'd like for it to be called when a player adds the plugin command "Monster Fighter", (The name of my card game.) to an event.

Any help here is greatly appreciated.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,653
Reaction score
1,105
First Language
EN
Primarily Uses
RMMV
Plugin Command invokes the pluginCommand method of Game_Interpreter. You can alias this method and check the input against your plugin's specific notation, e.g.
JavaScript:
// Plugin command handler
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;  // alias
Game_Interpreter.prototype.pluginCommand = function(command, args) {  // replace method
    _Game_Interpreter_pluginCommand.call(this, command, args);  // invoke original method
    if (command.toUpperCase() === 'MONSTER_FIGHTER') {  // check for your plugin command
        // do stuff!
    }
};
Note that a plugin command comprises a number of "words" split by spaces:
  • command is the first word, often used to determine which plugin the command is for.
  • args is an array containing all the subsequent words, in order. These can be used to refine the command, e.g.
    JavaScript:
    if (args[0].toUpperCase() === 'TRUE') { // first argument is "true"?
    // do stuff~
    }
    Sounds like you just want a simple thing though, so you probably won't need to worry about the args. :kaothx:
 

FatalErrorDriveB

Villager
Member
Joined
Dec 12, 2019
Messages
16
Reaction score
1
First Language
English
Primarily Uses
RMMV
Plugin Command invokes the pluginCommand method of Game_Interpreter. You can alias this method and check the input against your plugin's specific notation, e.g.
JavaScript:
// Plugin command handler
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;  // alias
Game_Interpreter.prototype.pluginCommand = function(command, args) {  // replace method
    _Game_Interpreter_pluginCommand.call(this, command, args);  // invoke original method
    if (command.toUpperCase() === 'MONSTER_FIGHTER') {  // check for your plugin command
        // do stuff!
    }
};
Note that a plugin command comprises a number of "words" split by spaces:
  • command is the first word, often used to determine which plugin the command is for.
  • args is an array containing all the subsequent words, in order. These can be used to refine the command, e.g.
    JavaScript:
    if (args[0].toUpperCase() === 'TRUE') { // first argument is "true"?
    // do stuff~
    }
    Sounds like you just want a simple thing though, so you probably won't need to worry about the args. :kaothx:
Thank you very much, this is exactly what I was looking for!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

What are your experience on trying to boost a MV project on an Android 7+ phone to a constant 60 fps? It's very hard for me(mine is 720x1440 px with Octa-core 1.8 GHz Cortex-A53 and Adreno 506), especially with an ATB system plugin. The best minimum I can get is 30+ fps :)
MZ Spoiler Thread: Blah, blah, blah, blah...
Me: :kaoslp:
Mog: Star Ocean Battle system!
Me:
:MV1:
Hosting a private game jam...might have smthng to post soon if I can fix these dang parallaxes.
Oof it's been a while...well I'm back to stay!

Forum statistics

Threads
99,241
Messages
963,357
Members
130,827
Latest member
baochau
Top