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
2,091
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
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 Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,083
Members
137,583
Latest member
write2dgray
Top