Hi, I have this code, but when I put the plugin command in my game, and interact(player action) on that event, it doesn't call the API (hence no console log) but when I put the fetch script in the event instead of trying to use a plugin command, it works and console logs in devtools.
Code:
/*:
* @target MZ
* @plugindesc Example Plugin
* @author Your Name
*
* @param Example Parameter
* @desc An example parameter for the plugin.
* @default 5
*
* @command exampleCommand
* @desc An example command for the plugin.
*
* @arg exampleArgument
* @desc An example argument for the command.
*
* @help
* This is an example plugin for RPG Maker MZ.
*/
(function() {
var parameters = PluginManager.parameters('ExamplePlugin');
var exampleParameter = Number(parameters['Example Parameter'] || 5);
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
console.log(args, 'args')
if (command === 'exampleCommand') {
var exampleArgument = args[0] || 1;
// Add your custom code here to handle the exampleCommand
fetch('https://pokeapi.co/api/v2/pokemon/' + exampleArgument)
.then(async response => response.json())
.then((data) => console.log(data));
}
};
})();