![見出し画像](https://assets.st-note.com/production/uploads/images/82210328/rectangle_large_type_2_d46bc0c14c8a88df1f50829800acecbc.png?width=1200)
【ティラノビルダー】好感度が一番高いキャラクターのルートに分岐する方法
ティラノビルダーで好感度が一番高いキャラクターのルートに分岐する方法について解説します。
【参考記事】
上記の記事を参考にさせていただきました。
①変数の追加
![](https://assets.st-note.com/img/1715669121810-oFGOeurkQp.png?width=1200)
「プロジェクト」→「変数管理」をクリックし、変数管理画面を開きます。
![](https://assets.st-note.com/img/1715669350834-SYcntcNW8r.png?width=1200)
chara1_love
chara2_love
chara3_love
select
上記の変数を追加します。
初期値は、chara1_love~chara3_loveは0にします。
selectは空欄でOKです。
これで、変数の追加は完了です。
②ラベルコンポーネントの配置
![](https://assets.st-note.com/img/1715670033313-7sas80N6jn.png?width=1200)
chara1
chara2
chara3
上記のラベルコンポーネントを追加します。
③iscriptコンポーネントの配置
![](https://assets.st-note.com/img/1715670583818-QHWtrU67FO.png?width=1200)
iscriptコンポーネントを配置します。
![](https://assets.st-note.com/img/1715670611568-zsyatWE1vZ.png?width=1200)
下記のコードを貼り付けます。
switch (Math.max(f.chara1_love,f.chara2_love,f.chara3_love)){
case f.chara1_love:
f.select=1;
break;
case f.chara2_love:
f.select=2;
break;
case f.chara3_love:
f.select=3;
break;
}
【コードの解説】
![](https://assets.st-note.com/img/1715671803821-kSlNFJiNBO.png?width=1200)
chara1_love
chara2_love
chara3_love
select
赤字の部分は①で追加した上記の変数に対応しています。
④ジャンプコンポーネントの配置
![](https://assets.st-note.com/img/1715670988565-xqy4h6F3hI.png?width=1200)
ジャンプコンポーネントを配置し、各項目を設定します。
【ターゲット】chara1
【実行条件を指定する】チェックを入れる
【A】select
【B】定数を選択し、1と入力
【条件】AとBが同じ場合
【反映】各項目を設定した後、クリック
⑤ジャンプコンポーネントの配置
![](https://assets.st-note.com/img/1715671199657-ebAhuiK3uR.png?width=1200)
ジャンプコンポーネントを配置し、各項目を設定します。
【ターゲット】chara2
【実行条件を指定する】チェックを入れる
【A】select
【B】定数を選択し、2と入力
【条件】AとBが同じ場合
【反映】各項目を設定した後、クリック
⑥ジャンプコンポーネントの配置
![](https://assets.st-note.com/img/1715671305263-Wawd1Nvv5o.png?width=1200)
ジャンプコンポーネントを配置し、各項目を設定します。
【ターゲット】chara3
【実行条件を指定する】チェックを入れる
【A】select
【B】定数を選択し、3と入力
【条件】AとBが同じ場合
【反映】各項目を設定した後、クリック
⑦テキストコンポーネント・停止コンポーネントの配置
![](https://assets.st-note.com/img/1715678912540-IqX85aSgp2.png?width=1200)
![](https://assets.st-note.com/img/1715678924336-2pSW62sIS5.png?width=1200)
お好みで、テキストコンポーネント・停止コンポーネントを配置してください。
これで、好感度が一番高いキャラクターのルートに分岐する手順は完了です。
以上で解説を終わります。おつかれさまでした。
【参考】動作の確認
![](https://assets.st-note.com/img/1715680031564-facIGyUTMY.png?width=1200)
動作の確認のため、chara1_loveの初期値を10に変更します。
![](https://assets.st-note.com/img/1715680474990-lMWc7LrxUz.png?width=1200)
ラベルchara1に移動しました。
【参考】キャラクターが4人以上の場合のコード
キャラクターが4人の場合のコード
switch (Math.max(f.chara1_love,f.chara2_love,f.chara3_love,f.chara4_love)){
case f.chara1_love:
f.select=1;
break;
case f.chara2_love:
f.select=2;
break;
case f.chara3_love:
f.select=3;
break;
case f.chara4_love:
f.select=4;
break;
}
キャラクターが5人の場合のコード
switch (Math.max(f.chara1_love,f.chara2_love,f.chara3_love,f.chara4_love,f.chara5_love)){
case f.chara1_love:
f.select=1;
break;
case f.chara2_love:
f.select=2;
break;
case f.chara3_love:
f.select=3;
break;
case f.chara4_love:
f.select=4;
break;
case f.chara5_love:
f.select=5;
break;
}
キャラクターが6人の場合のコード
switch (Math.max(f.chara1_love,f.chara2_love,f.chara3_love,f.chara4_love,f.chara5_love,f.chara6_love)){
case f.chara1_love:
f.select=1;
break;
case f.chara2_love:
f.select=2;
break;
case f.chara3_love:
f.select=3;
break;
case f.chara4_love:
f.select=4;
break;
case f.chara5_love:
f.select=5;
break;
case f.chara6_love:
f.select=6;
break;
}