bladeink/
lib.rs

1//! This is a Rust port of inkle's [Ink](https://github.com/inkle/ink), a scripting language for writing interactive narratives.
2//! `bladeink` is fully compatible with the reference version and supports all
3//! its language features.
4//!
5//! To learn more about the Ink language, you can check [the official documentation](https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md).
6//!
7//! Here is a quick example that uses basic features to play an Ink story using
8//! the `bladeink` crate.
9//!
10//! ```
11//! # use bladeink::{story::Story, story_error::StoryError};
12//! # fn main() -> Result<(), StoryError> {
13//! # let json_string = r##"{"inkVersion":21, "root":["done",null],"listDefs":{}}"##;
14//! # let read_input = |_:&_| 0;
15//! // story is the entry point of the `bladeink` lib.
16//! // json_string is a string with all the contents of the .ink.json file.
17//! let mut story = Story::new(json_string)?;
18//!
19//! loop {
20//!     while story.can_continue() {
21//!         let line = story.cont()?;
22//!
23//!         println!("{}", line);
24//!     }
25//!
26//!     let choices = story.get_current_choices();
27//!     if !choices.is_empty() {
28//!         // read_input is a method that you should implement
29//!         // to get the choice selected by the user.
30//!         let choice_idx:usize = read_input(&choices);
31//!         // set the option selected by the user
32//!         story.choose_choice_index(choice_idx)?;
33//!     } else {
34//!         break;
35//!     }
36//! }
37//! # Ok(())
38//! # }
39//! ```
40//!
41//! The `bladeink` library supports all the **Ink** language features, including
42//! threads, multi-flows, variable set/get from code, variable observing,
43//! external functions, tags on choices, etc. Examples of uses of all these
44//! features will be added to this documentation in the future, but meanwhile,
45//! all the examples can be found in the `lib/tests` folder in the source code
46//! of this crate.
47
48mod callstack;
49pub mod choice;
50mod choice_point;
51mod container;
52mod control_command;
53mod divert;
54mod flow;
55mod glue;
56mod ink_list;
57mod ink_list_item;
58mod json;
59mod list_definition;
60mod list_definitions_origin;
61mod native_function_call;
62mod object;
63mod path;
64mod pointer;
65mod push_pop;
66mod search_result;
67mod state_patch;
68pub mod story;
69pub mod story_error;
70mod story_state;
71mod tag;
72mod value;
73pub mod value_type;
74mod variable_assigment;
75mod variable_reference;
76mod variables_state;
77mod void;