Skip to content

Repository files navigation

IFEngine Crates.io

IFEngine is a rust framework for writing interactive fiction. Other projects in this space include Twine and Inkle.

The goal is to enjoy an effortless writing experience, together with all the benefits of the Rust ecosystem.

Note: The firefox cache may cause the page to load forever after the first visit. Press ctrl-shift-r to fix this. If you know a fix, please let me know! story credit: https://antemaion.itch.io/saltwrack (Sorry I haven't asked permission yet as im just using it for testing this project is still just experimental!)

Why Rust?

it's cool i like it (todo).

Features

  • Story analysis: Travel your story through the API. Generate a graph!
  • Nice syntax: Weave together your story elements and code with intuitive macros.
  • Powerful state management: The full power of the rust language at your behest.
  • Navigable content: Stories link and compose together through elements like link, tunnel, and weave. Jump between them using Go to definition.
  • Immediate mode page execution coupled with persisted state enables writing generator-style functions to produce views.

Guide

  1. Initialize your project
mkdir -p ifproject
cd ifproject
  1. Download your frontend template
git clone git@github.com:Squirreljetpack/ifengine.git
mv ifengine/egui .
rm -rf ifengine

or with zsh-dl:

dl - https://github.com/Squirreljetpack/ifengine/tree/main/egui

Currently, your options are: egui .. and nothing else.

  1. Make a few changes

egui/Cargo.toml:

[package]
# change me
[dependencies]
# ifengineifengine = { path = "../ifengine" } # remove mestory = { path = "../story" }
# ...
  1. Create your library
cargo init --lib story
cd story
cargo add ifengine
# ifproject/# ├── egui# └── story# ├── Cargo.toml# └── src# └── lib.rs
  1. Write your story (See: example, elements)

story/src/lib.rs:

pubmod chap1;pubtypeGame = ifengine::Game<State>;pubfnnew() -> Game{
ifengine::Game!(chap1::p1)}// your game state#[derive(Debug,Default,Serialize,Deserialize,Clone)]pubstructState{pubname:String,}

story/src/chap1.rs:

#[allow(unused_imports)]use ifengine::{
elements::{ChoiceVariant::*,
choice,
click,
dp,
h,
choice,
mchoice,
p,},
utils::MaskExt,GO,
ifview,
link,};usecrate::{State};#[ifview]pubfnp1(s:&mutState){h!("LET ME TELL YOU WHY I GOT OUT OF BED THIS MORNING...")p!(link!("BEGIN", p3));}
  1. Launch!
cd egui
trunk serve

Docs

Note

To use this library, you write functions which produce Responses, eventually resolving to a View. The view corresponding to the current game state is retrieved by calling Game::view.

A view is a sequence of Objects which you can attach by calling the provided elements and macros within a function decorated by #[ifview].

Contributions

Ideas and contributions welcome. There is a rough todo as well.

About

Interactive fiction library and engine

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

Generated from emilk/eframe_template