/*: * @target MZ * @plugindesc v1.0 指定秒後にBGMが鳴っていなければ自動再生します。 Author: IvI * @command AutoPlayBgm * @text 自動BGM再生 * @desc 指定時間経過後、まだBGMが再生されていなければ指定のBGMを再生します。 * * @arg delay * @type number * @text 待ち秒数 * @min 0 * @default 1 * * @arg bgmName * @type file * @dir audio/bgm * @text BGMファイル名 * * @arg volume * @type number * @default 90 * @min 0 * @max 100 * @text 音量 * * @arg pitch * @type number * @default 100 * @text ピッチ * * @arg pan * @type number * @default 0 * @text 位相 */ (() => { const PLUGIN_NAME = document.currentScript.src.match(/([^\/]+)\.js$/i)[1]; PluginManager.registerCommand(PLUGIN_NAME, "AutoPlayBgm", args => { const delay = Number(args.delay || 0); // 秒 const bgm = { name: String(args.bgmName || ""), volume: Number(args.volume || 90), pitch: Number(args.pitch || 100), pan: Number(args.pan || 0) }; if (!bgm.name) return; // ファイル名未設定なら無視 // 指定秒後に判定→再生 setTimeout(() => { if (!AudioManager._currentBgm) { // まだBGMが鳴っていない? AudioManager.playBgm(bgm); } }, delay * 1000); }); })();