■今回は便利なスクリプトを紹介していくぞ!u・∞・u
★スクリプトとは?
●1行書くだけで色々できる超便利なシロモノだ!
●複数組み合わせていくとツクールそのものになる。
(ツクールはJavaScriptの塊だ)
●プラグインも出来る!
(使い回したい塊が出来た時、人はそれをプラグインと呼ぶ)
ーーーーーーーーーーーーーーーーーーーーーーーーーーーー
今回は1行書くだけでいいスクリプトを体験してみよう!
★★コピペしてMZの「スクリプト」の項目に貼りつければOK!★★
ーーーーーーーーーーーーーーーーーーーーーーーーーーーー
ピクチャをまとめて全部消す
$gameScreen.clearPictures();
ピクチャ番号で範囲指定して一括消去する
(★例では1~5)
for (let i = 1; i <= 5; i++) {$gameScreen.erasePicture(i);}
ピクチャの原点を右上にするスクリプト
(左上: 0 中央: 1 右上: 2)
$gameScreen.picture(1)._origin = 2;
BGMフェードイン
AudioManager.fadeInBgm(duration);
指定したアクターの装備を変更
$gameActors.actor(1).changeEquip(0, $dataWeapons[5]);
メッセージウィンドウ透明度選択
Window_Message.prototype.updateBackground = function() {
this.setBackgroundType(2); // 0: ウィンドウ, 1: 暗くする, 2: 透明};
指定したイベントのセルフスイッチ操作
$gameSelfSwitches.setValue([mapId, eventId, 'A'], true);
スイッチ#0001~#0004の全てがONならOK
[1,2,3,4].every(function(id){return $gameSwitches.value(id) > 0});
ーーーーーーーーーーーーーーーーーーーーーーーーーーー
(★マウスゲー作ってる人には必須のスクリプト)
マウスの左クリック(決定)検知
TouchInput.isTriggered();
マウスの右クリック(キャンセル)検知
TouchInput.isCancelled();
ーーーーーーーーーーーーーーーーーーーーーーーーーーー
n番フォロワーのx座標を取得
$gamePlayer.followers().follower(i).x
フォロワーにアニメ表示
$gamePlayer.followers().follower(index).requestAnimation(id);
indexには「フォロワーのindex」を、idにはアニメーションIDを記入
フォロワーにフキダシ(バルーン)表示
$gamePlayer.followers().follower(n).requestBalloon(m);
n:フォロワー番号(パーティの2番目が0、3番目が1...)、m:バルーンID
(★くっついて来てるキャラになにかしたい時
例えば崖下を主人公は通過する、だが仲間の上に岩が!
みたいなイベントを作る時に組み合わせてどうぞ)
ーーーーーーーーーーーーーーーーーーーーーーーーーーー
キャラクターの座標がXYと一致するか
(★シンプルにプレーヤーが罠の上に来た時などに)
$gameMap.event(id).pos(x, y)
ーーーーーーーーーーーーーーーーーーーーーーーーーーー
データベースで設定した音を鳴らす
(★ミニゲームなどと連動させられる!)
カーソル
SoundManager.playCursor()
決定
SoundManager.playOk()
キャンセル
SoundManager.playCancel()
ブザー
SoundManager.playBuzzer()
ーーーーーーーーーーーーーーーーーーーーーーーーーーーー
◆イベントを指定場所まで移動
(★XYで指定できると便利!)
this.moveStraight(this.findDirectionTo(X座標,Y座標));
ーーーーーーーーーーーーーーーーーーーーーーーーーーーー
選択肢の表示位置を変更するスクリプト
(★こちらは番号でなくxy指定
★スクリプト→選択肢で選択肢を好きな位置に表示)
画面中央に表示
Window_ChoiceList.prototype.windowX = function() {return (Graphics.boxWidth - this.windowWidth()) / 2;};
画面左に表示
Window_ChoiceList.prototype.windowX = function() {return 0;};
画面右に表示
Window_ChoiceList.prototype.windowX = function() {return Graphics.boxWidth - this.windowWidth();};
画面上部に表示
Window_ChoiceList.prototype.windowY = function() {return 0;};
画面下部に表示
Window_ChoiceList.prototype.windowY = function() {return Graphics.boxHeight - this.windowHeight();};
ーーーーーーーーーーーーーーーーーーーーーーーーーーーー
■さあ、究極のスクリプトの時間だ。↓(u・∞・uぼく的に超便利)
ーーーーーーーーーーーーーーーーーーーーーーーーーーーー
イベントのトリガーを変更したい時のスクリプト
(★プレイヤーの動きを止めたい時は自動、でもそこに選択肢が
出てきたら、並列に変更、終わったら決定に変更
★これで1個のイベント内で全部完了!いわゆる
「もう1度聞きたかったら話しかけてね」までがIN!)
const eventId = 1; // トリガーを変更したいイベントのID
const newTrigger = 2; // 新しいトリガーの値(0: 決定ボタン, 1: プレイヤーから接触, 2: イベントから接触, 3: 自動実行, 4: 並列処理)
const event = $gameMap.event(eventId);
event.event().pages[0].trigger = newTrigger;
ーーーーーーーーーーーーーーーーーーーーーーーーーーーー
★使用例★
プレイヤーの動きを止める(自動実行)
const eventId = 1;
const newTrigger = 3; // 自動実行
const event = $gameMap.event(eventId);
event.event().pages[0].trigger = newTrigger;
選択肢が出てきたら並列処理に変更
const eventId = 1;
const newTrigger = 4; // 並列処理
const event = $gameMap.event(eventId);
event.event().pages[0].trigger = newTrigger;
選択肢が終わったら決定ボタンに変更
const eventId = 1;
const newTrigger = 0; // 決定ボタン
const event = $gameMap.event(eventId);
event.event().pages[0].trigger = newTrigger;
ーーーーーーーーーーーーーーーーーーーーーーーーーーーー
◆説明◆
eventId はトリガーを変更したいイベントのID。
newTrigger は新しいトリガーの値。
0: 決定ボタン, 1: プレイヤーから接触, 2: イベントから接触, 3: 自動実行, 4: 並列処理。
$gameMap.event(eventId) で指定したイベントを取得する。
event.event().pages[0].trigger = newTrigger でイベントのトリガーを変更。
このスクリプトを使うことで、
1つのイベント内でトリガーを動的に変更し、
複数の処理を実行することが可能に!。
これにより、「もう一度聞きたかったら話しかけてね」
といったシナリオも実現可能だぞう!u・∞・uコピペして使ってみ!