# Godot (GDScript)

Copy `addons/yumina` into your project. It's plain GDScript for Godot 4: no plugins to enable, no C#. (Godot .NET projects can use the [C# SDK](./dotnet) instead.)

```gdscript
var yumina := Yumina.new()
yumina.client_id = "ym_…"
yumina.language = "en"
add_child(yumina)

if not yumina.is_signed_in():
    var link := await yumina.start_qr_sign_in()        # or: await yumina.sign_in_with_browser()
    draw_qr(link.qr.rows)                               # rows[r][c] == "1" is a dark square
    code_label.text = "%s  %s" % [link.verification_uri, link.user_code]
    await yumina.wait_qr_sign_in(link)

var mira := yumina.character("mira", Yumina.card_hub(card_id))   # or Yumina.card_inline(card)
var turn := await mira.say("Morning! Anything warm?", {
    "inputs": {"hearts": 3, "weather": "foggy"},
    "period": "spring-3",
    "on_text": func(line): bubble.text = line,          # streams, clean
})
if turn.has("error"):
    push_warning(turn.error.message)
elif turn.action and turn.action.status == "accepted" and turn.action.id == "give_item":
    var ok := inventory.add(turn.action.params.item)
    mira.report(turn, ok, "the player got it" if ok else "backpack full")
```

`turn.choices` holds three replies in the player's voice; `mira.end_conversation()` when the player walks away.

**Save and load:** store `yumina.memory_head` in your save (or connect `memory_changed`), and call `yumina.load_memory(head)` when a save is loaded.

The refresh token is kept in `user://yumina_account.cfg`, encrypted with this machine's id. Errors come back as `{"error": {"message", "code"}}` instead of exceptions; the codes are in the [HTTP reference](./http#errors).
