Last active
May 21, 2022 11:55
-
-
Save elleonard/3b7e0d05008d17d1595daee33abde16e to your computer and use it in GitHub Desktop.
逐次実行でウェイトをはさみながら画像を表示させていくプラグインコマンドのサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
'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