Skip to content

Instantly share code, notes, and snippets.

@elleonard
Last active May 21, 2022 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elleonard/3b7e0d05008d17d1595daee33abde16e to your computer and use it in GitHub Desktop.
Save elleonard/3b7e0d05008d17d1595daee33abde16e to your computer and use it in GitHub Desktop.
逐次実行でウェイトをはさみながら画像を表示させていくプラグインコマンドのサンプル
(() => {
'use strict';
const fruitX = [310, 358, 382, 406];
const fruitY = 450;
const wait = 10;
const _clear = Game_Interpreter.prototype.clear;
Game_Interpreter.prototype.clear = function () {
_clear.call(this);
this._insertedCommands = [];
};
Game_Interpreter.prototype.requestInsertCommand = function(commandFunction) {
if (!this._insertedCommands) {
this._insertedCommands = [];
}
this._insertedCommands.push(commandFunction);
}
Game_Interpreter.prototype.shiftInsertedCommands = function () {
if (!this._insertedCommands) {
this._insertedCommands = [];
}
return this._insertedCommands.length > 0 ? this._insertedCommands.shift() : null;
};
const _executeCommand = Game_Interpreter.prototype.executeCommand;
Game_Interpreter.prototype.executeCommand = function () {
const insertedCommand = this.shiftInsertedCommands();
if (insertedCommand) {
return insertedCommand();
}
_executeCommand.call(this);
};
const _pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function (command, args) {
_pluginCommand.call(this, command, args);
if (command === "requestShowFruitPictures") {
this.requestShowFruitPictures(args[0]);
}
};
Game_Interpreter.prototype.requestShowFruitPictures = function (names) {
names.split("").forEach((name, index) => {
this.requestInsertCommand(() => { this.showFruitPicture(name, index); });
this.requestInsertCommand(() => { this.wait(wait); });
});
};
Game_Interpreter.prototype.showFruitPicture = function (name, index) {
const pictureId = index+1;
$gameScreen.showPicture(
pictureId,
`F${name}`,
0,
fruitX[index],
fruitY,
100,
100,
255,
0
);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment