Skip to content

Example: Mood Meter ​

The smallest pack that uses every common part. It adds:

  • a variable mood (0 to 100, starts at 50) that the AI raises and lowers,
  • an entry that tells the AI what the number means,
  • a behavior that adds 10 when the player presses Cheer up,
  • an interface: a meter in the top right corner of the screen, with the button.

Download mood-meter.bundle.json

The File ​

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"
  }
}

The interface code, unescaped:

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>
  );
}

How the Parts Connect ​

  • The interface reads api.variables.mood and redraws whenever it changes.
  • The button calls api.executeAction("cheer_up"). That fires an action:fired event with actionId: "cheer_up", which the behavior's when matches. The behavior adds 10 to mood; max: 100 keeps it in range.
  • The AI sees the variable with its behaviorRules, and changes it in a reply with a directive such as [mood: +5]. See Variables & Directives.
  • The entry reads the current value through the {{mood}} macro, so the AI knows what the number means for this turn.

Try It ​

  1. Download the file and import it on Library → Bundles → Import Bundle.
  2. Open any card in Studio, press Resource market next to Add, open My Library and press Install on Mood Meter.
  3. In the dialog, leave Keep both screens selected and untick Have the assistant fit it to this card, then press Import.
  4. Press Play. The meter shows 50 in the top right corner. Press Cheer up and it shows 60; the playtest panel lists the change as "The player pressed a button".

Make It Your Own ​

Ask your AI to change it, with the single-file spec in context. Some directions:

  • Track one value per character: make mood a json variable keyed by character id, and draw one bar each.
  • Turn it into an App: add export const app = { id: "mood", icon: "💗", name: "Mood", variable: "mood", accent: "#ff6b8a" } and lay the default export out for a side panel instead of a corner.
  • Limit the button: add "cooldownTurns": 3 to the behavior.