Skip to content

Pregunta a una IA sobre esta página

Abrir en ChatGPT Abrir en Claude Ver como Markdown

Ejemplo: Mood Meter ​

El paquete más pequeño que usa todas las partes habituales. Añade:

  • una variable mood (de 0 a 100, empieza en 50) que la IA sube y baja,
  • una entrada que le dice a la IA qué significa el número,
  • un comportamiento que suma 10 cuando el jugador pulsa Cheer up,
  • una interfaz: un medidor en la esquina superior derecha de la pantalla, con el botón.

Los textos del paquete (el nombre, la entrada, la etiqueta del botón) están en inglés; cámbialos por los tuyos.

Descargar mood-meter.bundle.json

El archivo ​

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

El código de la interfaz, sin escapar:

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

Cómo se conectan las partes ​

  • La interfaz lee api.variables.mood y se vuelve a dibujar cada vez que cambia.
  • El botón llama a api.executeAction("cheer_up"). Eso dispara un evento action:fired con actionId: "cheer_up", que es lo que busca el when del comportamiento. El comportamiento suma 10 a mood; max: 100 lo mantiene dentro del rango.
  • La IA ve la variable con sus behaviorRules y la cambia en una respuesta con una directiva como [mood: +5]. Mira Variables y directivas.
  • La entrada lee el valor actual con la macro {{mood}}, así que la IA sabe qué significa el número en este turno.

Pruébalo ​

  1. Descarga el archivo e impórtalo en Biblioteca → Paquetes → Importar paquete.
  2. Abre cualquier carta en Studio, pulsa Mercado de recursos junto a Añadir, abre Mi biblioteca y pulsa Instalar en Mood Meter.
  3. En el diálogo, deja marcado Mantener las dos pantallas y desmarca Que el asistente la adapte a esta tarjeta; luego pulsa Importar.
  4. Pulsa Jugar. El medidor muestra 50 en la esquina superior derecha. Pulsa Cheer up y muestra 60; el panel de prueba muestra el cambio como "El jugador pulsó un botón".

Hazlo tuyo ​

Pide a tu IA que lo cambie, con la spec de archivo único en el contexto. Algunas ideas:

  • Guarda un valor por personaje: convierte mood en una variable json con una clave por ID de personaje y dibuja una barra para cada uno.
  • Conviértelo en una App: añade export const app = { id: "mood", icon: "💗", name: "Mood", variable: "mood", accent: "#ff6b8a" } y organiza el export por defecto para un panel lateral en lugar de una esquina.
  • Limita el botón: añade "cooldownTurns": 3 al comportamiento.