Dark Forest Program

I wanted to get into a new programming language in 2019, and play with words with my 5-year-old. So I built a program that interprets a folder of text files as a semi-interactive story on the command line, in Rust.

The program "types" out the story as if someone were controlling the terminal, one letter at a time, with some jitter and pauses somewhat mimicking a person.

The program interprets any text within brackets ([]) to be macro commands.

Function Purpose Example
time Insert a pause, by seconds [time=3]
color Change the enclosed text's color [color=green|This is green]
title Output a title [title=A Tale of Two Cities]
input Take a reader's input and save it to a variable for output [input=your_name|What is your name?]
output Use an input [output=your_name]
input=path() A path input forks to a new text file in the story [input=path(redpill,bluepill)|Which path will you choose?]


Here is how a story could start:

[input=your_name|Enter your name:]

You enter a dark forest...

Dear [output=your_name],

You once asked me to share my wisdom with you.

So I will.

A fork in the road lies before you.

You may walk through the [color=green|mirror], or learn to [color=green|bike].

input=path(mirror,bike)|Which fork will you take?]


And this is about how it turns out: