pure-full-lily/js/plugins/SkipAutorunOnLoad.js
2025-09-16 10:12:44 -05:00

40 lines
1.3 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*:
* @target MZ
* @author IvI
* @plugindesc [v1.0] ロード直後だけ自動実行を無効化するフラグを追加します
*
* @help SkipAutorunOnLoad.js
* ----------------------------------------
* ■ 使い方
* スキップしたい自動実行イベントのページ条件に
*   !$gameSystem.isJustLoaded()
* と記述してください。
* ニューゲームや場所移動では実行され、ロード直後だけ実行されません。
*
* ■ プラグインコマンド
* ありません。
* ----------------------------------------
*/
(() => {
// ■ DataManager.loadGame をフックして「ロード直後」フラグを立てる
const _loadGame = DataManager.loadGame;
DataManager.loadGame = async function(savefileId) {
const result = await _loadGame.call(this, savefileId);
if (result) $gameSystem._justLoaded = true;
return result;
};
// ■ Game_System に判定用メソッドを追加
Game_System.prototype.isJustLoaded = function() {
return !!this._justLoaded;
};
// ■ Scene_Map.start でフラグをリセット
const _start = Scene_Map.prototype.start;
Scene_Map.prototype.start = function() {
_start.call(this);
if (this.isActive() && $gameSystem._justLoaded) {
$gameSystem._justLoaded = false;
}
};
})();