例:Mood Meter
よく使う部品をすべて使った、いちばん小さなパックです。追加するものは次のとおりです。
- AI が上げ下げする変数
mood(0〜100、最初は 50) - その数値の意味を AI に伝えるエントリ
- プレイヤーが Cheer up を押すと 10 足すビヘイビア
- 画面:画面の右上の隅に出るメーターと、そのボタン
パックの中の文字(名前、エントリ、ボタンのラベル)は英語です。自分の言葉に書き換えてください。
mood-meter.bundle.json をダウンロード
ファイル
json
{
"bundleVersion": "3.0.0",
"name": "Mood Meter",
"description": "A small meter in the corner that shows how the main character feels about the player. The AI moves it as the story goes, and the player can press Cheer up.",
"tags": ["interface", "relationship"],
"createdAt": "2026-11-30T00:00:00.000Z",
"entries": [
{
"id": "mood-guide",
"name": "Mood meter guide",
"content": "The main character's mood toward {{user}} is {{mood}} out of 100. 0 to 29: cold and short. 30 to 69: ordinary. 70 to 100: warm and open. Let it shape how they speak.",
"role": "system",
"section": "system-presets",
"position": 0,
"enabled": true,
"alwaysSend": true,
"keywords": [],
"conditions": [],
"conditionLogic": "all"
}
],
"variables": [
{
"id": "mood",
"name": "Mood",
"type": "number",
"defaultValue": 50,
"min": 0,
"max": 100,
"description": "How the main character feels about the player",
"behaviorRules": "Raise by 3 to 10 when the player is kind, funny or helpful. Lower by 3 to 10 when the player is rude or cold. At most 10 per turn."
}
],
"rules": [],
"reactions": [
{
"id": "cheer-up",
"name": "Cheer up button",
"when": { "eventType": "action:fired", "match": { "actionId": { "operator": "eq", "value": "cheer_up" } } },
"conditions": [],
"conditionLogic": "all",
"then": [{ "type": "set", "path": "mood", "operation": "add", "value": 10 }],
"priority": 0,
"enabled": true
}
],
"audioTracks": [],
"rootComponent": {
"id": "mood-meter-ui",
"name": "Mood Meter",
"entryFile": "index.tsx",
"files": {
"index.tsx": "export default function MoodMeter() {\n const api = useYumina();\n const mood = Number(api.variables.mood ?? 50);\n const color = mood < 30 ? \"#6b8cff\" : mood < 70 ? \"#e0b44c\" : \"#ff6b8a\";\n return (\n <div style={{ position: \"fixed\", top: 64, right: 12, zIndex: 50, width: 168, padding: \"10px 12px\", borderRadius: 14, background: \"rgba(20,22,32,0.82)\", color: \"#fff\", fontSize: 13, fontFamily: \"system-ui, sans-serif\", boxShadow: \"0 6px 18px rgba(0,0,0,0.3)\" }}>\n <div style={{ display: \"flex\", justifyContent: \"space-between\" }}>\n <span>Mood</span>\n <b>{mood}</b>\n </div>\n <div style={{ height: 6, borderRadius: 3, background: \"rgba(255,255,255,0.15)\", margin: \"8px 0\" }}>\n <div style={{ width: mood + \"%\", height: \"100%\", borderRadius: 3, background: color, transition: \"width .4s\" }} />\n </div>\n <button type=\"button\" disabled={api.readOnly} onClick={() => api.executeAction(\"cheer_up\")}\n style={{ width: \"100%\", border: \"none\", borderRadius: 8, padding: \"6px 0\", cursor: \"pointer\", background: color, color: \"#1b1e2b\", fontWeight: 700 }}>\n Cheer up\n </button>\n </div>\n );\n}\n"
},
"updatedAt": "2026-11-30T00:00:00.000Z"
}
}画面のコード(エスケープを外したもの):
tsx
export default function MoodMeter() {
const api = useYumina();
const mood = Number(api.variables.mood ?? 50);
const color = mood < 30 ? "#6b8cff" : mood < 70 ? "#e0b44c" : "#ff6b8a";
return (
<div style={{ position: "fixed", top: 64, right: 12, zIndex: 50, width: 168, padding: "10px 12px", borderRadius: 14, background: "rgba(20,22,32,0.82)", color: "#fff", fontSize: 13, fontFamily: "system-ui, sans-serif", boxShadow: "0 6px 18px rgba(0,0,0,0.3)" }}>
<div style={{ display: "flex", justifyContent: "space-between" }}>
<span>Mood</span>
<b>{mood}</b>
</div>
<div style={{ height: 6, borderRadius: 3, background: "rgba(255,255,255,0.15)", margin: "8px 0" }}>
<div style={{ width: mood + "%", height: "100%", borderRadius: 3, background: color, transition: "width .4s" }} />
</div>
<button type="button" disabled={api.readOnly} onClick={() => api.executeAction("cheer_up")}
style={{ width: "100%", border: "none", borderRadius: 8, padding: "6px 0", cursor: "pointer", background: color, color: "#1b1e2b", fontWeight: 700 }}>
Cheer up
</button>
</div>
);
}部品のつながり
- 画面は
api.variables.moodを読み、値が変わるたびに描き直します。 - ボタンは
api.executeAction("cheer_up")を呼びます。これでactionId: "cheer_up"のaction:firedイベントが起き、ビヘイビアのwhenがそれに一致します。ビヘイビアはmoodに 10 を足し、max: 100で範囲内に収まります。 - AI は変数とその
behaviorRulesを見て、返答の中で[mood: +5]のようなディレクティブで値を変えます。変数とディレクティブ を参照してください。 - エントリは
{{mood}}マクロで今の値を読むので、AI はこのターンの数値の意味がわかります。
試してみる
- ファイルをダウンロードし、ライブラリ → バンドル → バンドルをインポート で取り込みます。
- Studio で好きなカードを開き、追加 の隣の リソースマーケット を押して マイライブラリ を開き、Mood Meter の インストール を押します。
- ダイアログでは 両方の画面を残す を選んだままにし、アシスタントにこのカードへ合わせてもらう のチェックを外してから、インポート を押します。
- プレイ を押します。右上の隅のメーターに 50 と出ます。Cheer up を押すと 60 になり、プレイテストのパネルにはこの変化が「プレイヤーがボタンを押した」と表示されます。
自分用に変える
シングルファイル spec をコンテキストに入れて、AI に変えてもらいましょう。たとえば次のような方向があります。
- キャラクターごとに値を持たせる:
moodをキャラクター ID をキーにしたjson変数にして、1 人ずつバーを描きます。 - App にする:
export const app = { id: "mood", icon: "💗", name: "Mood", variable: "mood", accent: "#ff6b8a" }を追加し、default export を隅ではなくサイドパネル向けのレイアウトにします。 - ボタンに制限をかける:ビヘイビアに
"cooldownTurns": 3を追加します。
