Choice Engine 2
- Rust 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| Example.toml | ||
| README.md | ||
Choice Engine 2
Install
Set up repository
~/.cargo/config.toml:
[registries.sam_git]
index = "https://git.sam302.de/sam/_cargo-index.git"
[net]
git-fetch-with-cli = true
Install with Cargo
$ cargo add choice-engine --registry sam_git
Install manually
Cargo.toml:
[dependencies]
choice-engine = { version = "<VERSION>", registry = "sam_git" }
Quick start
use choice_engine::choice_engine;
use ::choice_engine::choice_engine::{StartupParameters, StateMachine};
fn main() {
// Startup parameters
let start_params: StartupParameters = StartupParameters {
file_location: String::from("dialog.toml"),
initial_timeline: 0
};
// Initialize a new state machine based on your start parameters.
let mut state_machine: StateMachine = choice_engine::init(&start_params).unwrap();
// This function returns the next dialog.
// Run this one time to begin and then every time the user makes a choice.
choice_engine::step(&mut state_machine);
}
Testing
| Description | Command |
|---|---|
| Run all tests without stdout when successful | cargo test |
| Run all tests with stdout | cargo test -- --no-capture |
| Print out timeline tree | cargo test read_and_parse_file -- --no-capture |