{"id":15137982,"url":"https://github.com/yarnspinnertool/yarnspinner-rust","last_synced_at":"2025-04-04T10:07:50.771Z","repository":{"id":153473054,"uuid":"604814226","full_name":"YarnSpinnerTool/YarnSpinner-Rust","owner":"YarnSpinnerTool","description":"The friendly tool for writing game dialogue in Rust","archived":false,"fork":false,"pushed_at":"2024-08-04T20:55:33.000Z","size":5543,"stargazers_count":173,"open_issues_count":23,"forks_count":15,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-10-29T17:36:11.015Z","etag":null,"topics":["bevy","dialog","game-development","rust"],"latest_commit_sha":null,"homepage":"https://janhohenheim.itch.io/yarnspinner-rust-demo","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YarnSpinnerTool.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["janhohenheim","mafii"]}},"created_at":"2023-02-21T21:04:57.000Z","updated_at":"2024-10-28T03:10:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"3ab3488d-cbe8-4e61-8166-3d18ef8a362b","html_url":"https://github.com/YarnSpinnerTool/YarnSpinner-Rust","commit_stats":{"total_commits":1482,"total_committers":13,"mean_commits":114.0,"dds":"0.14912280701754388","last_synced_commit":"8918900c9ec0470203ac4ad9bbb19e5f9acb07ea"},"previous_names":["yarnspinnertool/yarnspinner-rust"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YarnSpinnerTool%2FYarnSpinner-Rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YarnSpinnerTool%2FYarnSpinner-Rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YarnSpinnerTool%2FYarnSpinner-Rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YarnSpinnerTool%2FYarnSpinner-Rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YarnSpinnerTool","download_url":"https://codeload.github.com/YarnSpinnerTool/YarnSpinner-Rust/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157282,"owners_count":20893220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bevy","dialog","game-development","rust"],"created_at":"2024-09-26T07:04:06.726Z","updated_at":"2025-04-04T10:07:50.760Z","avatar_url":"https://github.com/YarnSpinnerTool.png","language":"Rust","funding_links":["https://github.com/sponsors/janhohenheim","https://github.com/sponsors/mafii"],"categories":[],"sub_categories":[],"readme":"# Yarn Spinner for Rust\n\n[![Crates.io](https://img.shields.io/crates/v/bevy_yarnspinner.svg)](https://crates.io/crates/bevy_yarnspinner)\n[![Docs](https://docs.rs/bevy_yarnspinner/badge.svg)](https://docs.rs/bevy_yarnspinner/latest/bevy_yarnspinner/)\n[![Discord](https://img.shields.io/discord/754171172693868585.svg?label=\u0026logo=discord\u0026logoColor=ffffff\u0026color=7389D8\u0026labelColor=6A7EC2)](https://discord.gg/yarnspinner)\n\u003e **Note:**\n\u003e Yarn Spinner for Rust is a work-in-progress project. We don't currently offer any official support for it. We encourage you to\n\u003e file [issues](https://github.com/YarnSpinnerTool/YarnSpinner-Rust/issues/new) if you have them, and to join the official [Yarn Spinner Discord](https://discord.gg/yarnspinner) to discuss the\n\u003e project!\n\nThe Rust port of Yarn Spinner, the friendly tool for writing game dialogue. Read more on [docs.yarnspinner.dev](https://docs.yarnspinner.dev/using-yarnspinner-with-rust/overview) or check out\nthe [live demo](https://janhohenheim.itch.io/yarnspinner-rust-demo), which was written using the [Bevy engine](https://bevyengine.org/).\nThis project offers first class support for Bevy and assumes you are using it. If you are not, check out\nthe [relevant section of the book](https://yarnspinnertool.github.io/YarnSpinner-Rust/working_without_bevy)\n\n[![Yarn Spinner for Rust Demo](https://img.itch.zone/aW1hZ2UvMjExMjc5NC8xMjQ0MjEwNy5wbmc=/original/LpAOnR.png)](https://janhohenheim.itch.io/yarn-slinger-demo)\n\n## Quickstart\n\nTaken straight from our [examples](https://github.com/YarnSpinnerTool/YarnSpinner-Rust/tree/main/examples/bevy_yarnspinner):\n\nFirst, let's add our dependencies:\n\n```bash\ncargo add bevy bevy_yarnspinner bevy_yarnspinner_example_dialogue_view\n```\n\nNow, the `main.rs`:\n\n```rust,no_run\nuse bevy::prelude::*;\nuse bevy_yarnspinner::prelude::*;\nuse bevy_yarnspinner_example_dialogue_view::prelude::*;\n\nfn main() {\n    let mut app = App::new();\n    app.add_plugins((\n        DefaultPlugins,\n        // Register the Yarn Spinner plugin using its default settings, which will look for Yarn files in the \"dialogue\" folder.\n        // If this app should support Wasm or Android, we cannot load files without specifying them, so use the following instead.\n        // YarnSpinnerPlugin::with_yarn_source(YarnFileSource::file(\"dialogue/hello_world.yarn\")),\n        YarnSpinnerPlugin::new(),\n        // Initialize the bundled example UI\n        ExampleYarnSpinnerDialogueViewPlugin::new(),\n    ))\n        .add_systems(Startup, setup_camera)\n        .add_systems(\n            Update,\n            // Spawn the dialogue runner once the Yarn project has finished compiling\n            spawn_dialogue_runner.run_if(resource_added::\u003cYarnProject\u003e),\n        )\n        .run();\n}\n\nfn setup_camera(mut commands: Commands) {\n    commands.spawn(Camera2d::default());\n}\n\nfn spawn_dialogue_runner(mut commands: Commands, project: Res\u003cYarnProject\u003e) {\n    // Create a dialogue runner from the project.\n    let mut dialogue_runner = project.create_dialogue_runner();\n    // Immediately start showing the dialogue to the player\n    dialogue_runner.start_node(\"HelloWorld\");\n    commands.spawn(dialogue_runner);\n}\n```\n\nAnd finally, the `assets/dialogue/hello_world.yarn`:\n\n```text\ntitle: HelloWorld\n---\nHello World! To continue the dialogue, click with your mouse, press the space bar or the enter key.\nThese are options. You can select one by clicking on it or pressing the corresponding number on your keyboard.\n-\u003e Some cool option\n-\u003e Some other cool option\nNow we'll jump to another node!\n\u003c\u003cjump AnotherNode\u003e\u003e\n\n===\n\ntitle: AnotherNode\n---\nNow, a character will talk. Notice how the upper left corner of the dialogue will show their name.\nHohenheim: Hi, I'm Jan Hohenheim, creator of Yarn Spinner for Rust. I hope you enjoy using it!\nLet's set a condition. Do you prefer dogs or cats?\n-\u003e Dogs\n    \u003c\u003cset $animal = \"dog\"\u003e\u003e\n-\u003e Cats\n    \u003c\u003cset $animal = \"cats\"\u003e\u003e\n-\u003e Turtles\n    I, uuuh... okay, why not.\n    \u003c\u003cset $animal = \"turtles\"\u003e\u003e\nNow let's print the result of the condition. Your preference is...\n(Drum roll)\n\u003c\u003cif $animal == \"dog\"\u003e\u003e\nDogs! Arf Arf!\n\u003c\u003celseif $animal == \"cats\"\u003e\u003e\nCats! (Can't say I agree, but you do you)\n\u003c\u003celse\u003e\u003e\nTurtles! Solid choice.\n\u003c\u003cendif\u003e\u003e\nEt voilà! That was all. Thanks for checking out Yarn Spinner for Rust! Continuing from the last node will exit the dialogue.\n===\n```\n\n## Version Table\n\n| Bevy        | Yarn Spinner for Rust | \n|-------------|-----------------------|\n| 0.16.0-rc   | 0.5.0-rc              |\n| 0.15        | 0.4                   |\n| 0.14        | 0.3                   |\n| 0.13        | 0.2                   |\n| 0.12        | 0.1                   |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyarnspinnertool%2Fyarnspinner-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyarnspinnertool%2Fyarnspinner-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyarnspinnertool%2Fyarnspinner-rust/lists"}