Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arstgit/cmd-alive
Interactive fiction engine.
https://github.com/arstgit/cmd-alive
Last synced: about 10 hours ago
JSON representation
Interactive fiction engine.
- Host: GitHub
- URL: https://github.com/arstgit/cmd-alive
- Owner: arstgit
- License: mit
- Created: 2018-11-09T03:01:11.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-10T06:27:10.000Z (about 6 years ago)
- Last Synced: 2024-11-14T23:13:38.449Z (about 19 hours ago)
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cmd-alive
[![Build Status](https://travis-ci.org/derekchuank/cmd-alive.svg?branch=master)](https://travis-ci.org/derekchuank/cmd-alive)
[![npm version](https://badge.fury.io/js/cmd-alive.svg)](http://badge.fury.io/js/cmd-alive)## For Reader
Install.
```
npm install -g cmd-alive
```There is a demo in the package, you can try it.
```
alive
```
Sure, if you want to read other ficitions.```
alive [path to fiction directory]
```### Command
While reading you can type these commands.
* `help` - Show help information.
* `save` - Save your progress. Besides, `Ctrl-C` can also trigger it automatically. Progerss file is in your fiction directory with name `.cache`.
* `restart` - Deleted your saved profile, and start over.
* `print` - Print your track, used for debug.## For Writer
Demo file is in `/example/shelter`. Every fiction contain two types of files.
`.ca` - Files extension with `.ca` is fiction script.Every fiction contain servel sections, each begain with a label name having the form `$...:`. Section must ending with choices would be selectd by reader. Two special label is indispensable: `start` and `end`.
`js` - Files extension with `.js` is control flow script. Every function name must be a label identity, so too return value. These is a global object `ctx` you can access in this file freely.
## Example
`.ca`:
```
$start:
A nice day.choices:
a. go to 2a.
b. go to A LOOP.$2a:
Then?
No choice.$loop:
You can't excape.$end:
Think you.
````.js`
```
function $start() {
if (ctx.cur === "b") {
return $loop;
}
if (ctx.cur == "a") {
return $2a;
}
return $start;
}function $2a() {
return $end;
}function $loop() {
return $start;
}
function $end() {
// dumb
}
```