Expand description
Lightweight, engine-agnostic dialogue runtime for Rust games.
Write branching dialogue in .bub scripts, compile them once, then drive
the dialogue from any game loop via a pull-based event API.
§Quick start
use bubbles::{compile, DialogueEvent, HashMapStorage, Runner};
let source = "title: Greet\n---\nHello!\n===\n";
let prog = compile(source).unwrap();
let mut runner = Runner::new(prog, HashMapStorage::new());
runner.start("Greet").unwrap();
assert!(matches!(
runner.next_event().unwrap(),
Some(DialogueEvent::NodeStarted(_))
));
assert!(matches!(
runner.next_event().unwrap(),
Some(DialogueEvent::Line { .. })
));
assert!(matches!(
runner.next_event().unwrap(),
Some(DialogueEvent::NodeComplete(_))
));
assert!(matches!(
runner.next_event().unwrap(),
Some(DialogueEvent::DialogueComplete)
));§Modules
| Module | Contents |
|---|---|
value | Value, VariableStorage, HashMapStorage |
compiler | compile, compile_many, validate, Program, VariableDecl |
runtime | Runner, DialogueEvent, LineProvider, RunnerSnapshot (serde) |
library | FunctionLibrary and built-in functions |
saliency | SaliencyStrategy, FirstAvailable, BestLeastRecentlyViewed, RandomAvailable (rand feature) |
Lint policy is defined once in Cargo.toml under [lints.rust] /
[lints.clippy]; we deliberately do not duplicate it here.
Re-exports§
pub use compiler::Program;pub use compiler::VariableDecl;pub use compiler::compile;pub use compiler::compile_many;pub use compiler::validate;pub use compiler::validate;pub use error::DialogueError;pub use error::Result;pub use library::FunctionLibrary;pub use runtime::DialogueEvent;pub use runtime::DialogueOption;pub use runtime::HashMapProvider;pub use runtime::LineProvider;pub use runtime::PassthroughProvider;pub use runtime::Runner;pub use saliency::RandomAvailable;pub use saliency::BestLeastRecentlyViewed;pub use saliency::Candidate;pub use saliency::FirstAvailable;pub use saliency::SaliencyStrategy;pub use value::HashMapStorage;pub use value::Value;pub use value::VariableStorage;
Modules§
- compiler
- Compilation pipeline: source text →
Program. - error
- Shared error and result types for the crate.
- library
FunctionLibrary— built-in functions and host-registration API.- runtime
- Runtime execution layer:
RunnerandDialogueEvent. - saliency
SaliencyStrategytrait and built-in implementations.- value
- Value model:
Valueenum,VariableStoragetrait, andHashMapStorage.