documentation
This commit is contained in:
+561
-560
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
An interactive story telling software.
|
An interactive story telling software.
|
||||||
Read and write people's stories
|
Read and write people's stories
|
||||||
|
For help with making a story, see [this documentation](/docs/MAKING_A_STORY.md)
|
||||||
|
For help with syntax, see [this documentation](/docs/SYNTAX.md)
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
@@ -9,11 +11,7 @@ This is not really out of development, but to run it, clone the repo, go into /s
|
|||||||
|
|
||||||
## Technical Details
|
## Technical Details
|
||||||
|
|
||||||
### Back-end server -- Rust
|
### File layout
|
||||||
|
|
||||||
The server component of Happening will be written in Rust.<br/>
|
|
||||||
Parses the code and sends it via the API.<br/>
|
|
||||||
File layout:
|
|
||||||
|
|
||||||
- animations/
|
- animations/
|
||||||
- features/
|
- features/
|
||||||
@@ -30,13 +28,24 @@ File layout:
|
|||||||
- scenes/
|
- scenes/
|
||||||
- images/
|
- images/
|
||||||
|
|
||||||
The variables are stored as a hashmap, characters are objects.<br/>
|
### Back-end server -- Rust
|
||||||
|
|
||||||
|
The server component of Happening will be written in Rust.<br/>
|
||||||
|
Parses the code and sends it via the API.<br/>
|
||||||
|
File layout:
|
||||||
|
|
||||||
|
The variables are stored as a hashmap, characters are structs in a hashmap.<br/>
|
||||||
|
|
||||||
### API
|
### API
|
||||||
|
|
||||||
Using the network interface, port 20264.<br/>
|
Using the network interface, port 20264.<br/>
|
||||||
|
|
||||||
Characters are sent to the frontend and stored there when the character is created on the frontend.<br/>
|
Characters are sent to the frontend and stored there when the character is created on the frontend.<br/>
|
||||||
|
There are 4 endpoints.
|
||||||
|
|
||||||
|
#### /happening
|
||||||
|
|
||||||
|
GET Returns what is happening on the next cycle:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
@@ -47,35 +56,41 @@ content: String,
|
|||||||
|
|
||||||
character: String,
|
character: String,
|
||||||
|
|
||||||
|
choice: [String,String,String,...]
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
#### /character/\<character name\>
|
||||||
|
GET Returns the struct of the character, ideally this should only be gotten when a new character is made or a character changes a feature.
|
||||||
|
|
||||||
|
#### /choice
|
||||||
|
POST the choice as a JSON formatting number, eg 1 to choose choice index 1, returns "ack" as acknowledgment.
|
||||||
|
|
||||||
|
#### /input
|
||||||
|
POST not yet fully implemented on the syntax side but allows client to send a user input to the server as text. returns "ack" as acknowlegment.
|
||||||
|
|
||||||
### Frontend -- Python
|
### Frontend -- Python
|
||||||
|
|
||||||
Things the frontend can do:
|
Things the frontend should be able to:
|
||||||
|
|
||||||
- Output text
|
- Output text
|
||||||
- Display the character
|
- Display the character
|
||||||
- Move characters around
|
- Move characters around
|
||||||
- Display a choice to the user that gets sent back to the server
|
- Display a choice to the user that gets sent back to the server
|
||||||
|
|
||||||
### Syntax
|
### Files
|
||||||
|
|
||||||
#### Setup
|
For more info on these files see [Making a Story](/docs/MAKING_A_STORY.md)
|
||||||
|
|
||||||
This is done in the about.json file,
|
#### story.ha
|
||||||
|
|
||||||
```
|
This contains the code for the story, syntax for writing the code can be seen in [the syntax section](/docs/SYNTAX.md)
|
||||||
{
|
|
||||||
|
|
||||||
"title": "My Great Story",
|
#### about.json
|
||||||
|
|
||||||
"description": "please read!"
|
This file contains details about your story such as the title and description.
|
||||||
|
|
||||||
}
|
#### characters.json
|
||||||
```
|
|
||||||
|
|
||||||
#### Characters
|
|
||||||
|
|
||||||
See [Character documentation](/docs/CHARACTER.md) for more info
|
See [Character documentation](/docs/CHARACTER.md) for more info
|
||||||
Referencing a character using the @, @NARRATOR is reserved for the Narrator.<br/>
|
Referencing a character using the @, @NARRATOR is reserved for the Narrator.<br/>
|
||||||
@@ -85,72 +100,6 @@ Move a character with @CHARACTER to fr
|
|||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> fr means front-right for instance.
|
> fr means front-right for instance.
|
||||||
|
|
||||||
#### Outputs
|
|
||||||
|
|
||||||
```
|
|
||||||
@CHARACTER says "this string
|
|
||||||
is multi-line
|
|
||||||
and ends with a"
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Variables
|
|
||||||
|
|
||||||
Variables are referenced with the \$, only integers will be supported.<br/>
|
|
||||||
|
|
||||||
#### Selection
|
|
||||||
|
|
||||||
Condition based:
|
|
||||||
|
|
||||||
```
|
|
||||||
if (condition) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
elif (condition) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Choice based:
|
|
||||||
|
|
||||||
```
|
|
||||||
choice "choice 1" {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
or "choice 2" {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
or "choice 3" {
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Positioning
|
|
||||||
|
|
||||||
```
|
|
||||||
@CHARACTER to position
|
|
||||||
|
|
||||||
PAN to position
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Other
|
|
||||||
|
|
||||||
```
|
|
||||||
label:
|
|
||||||
|
|
||||||
GOTO label
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Ending
|
|
||||||
|
|
||||||
`END` to exit out of the story
|
|
||||||
|
|
||||||
## Implemented stuff
|
## Implemented stuff
|
||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
@@ -160,7 +109,7 @@ GOTO label
|
|||||||
| END | Yes |
|
| END | Yes |
|
||||||
| CHOICE/OR/OR | Yes |
|
| CHOICE/OR/OR | Yes |
|
||||||
| IF/ELSE IF/ELSE | No |
|
| IF/ELSE IF/ELSE | No |
|
||||||
| GOTO | No |
|
| GOTO | Yes |
|
||||||
| PAN | No |
|
| PAN | No |
|
||||||
|
|
||||||
### Character sub-commands
|
### Character sub-commands
|
||||||
@@ -178,6 +127,7 @@ GOTO label
|
|||||||
| ---------- | ----------- |
|
| ---------- | ----------- |
|
||||||
| Variables | No |
|
| Variables | No |
|
||||||
| about.json | No |
|
| about.json | No |
|
||||||
|
| INPUT | Partially |
|
||||||
|
|
||||||
## Error codes
|
## Error codes
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# Making a Story
|
||||||
|
|
||||||
|
## Setting up
|
||||||
|
|
||||||
|
You need these three files to make a story:
|
||||||
|
|
||||||
|
- about.json
|
||||||
|
|
||||||
|
- story.ha
|
||||||
|
|
||||||
|
- characters.json
|
||||||
|
|
||||||
|
## Filling out the files
|
||||||
|
|
||||||
|
Inside about.json should be the following content:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"title": "My Great Story",
|
||||||
|
"description": "please read!"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Change the title and description to whatever you would like.<br/>
|
||||||
|
Inside story.ha should be the code for your story, see [the documentation on coding](/docs/SYNTAX.md) for help with this.<br/>
|
||||||
|
Finally, inside characters.json should be a JSON formatted object containing all your characters. See [the documentation on characters](/docs/CHARACTERS.md) for help with this file.<br/>
|
||||||
|
|
||||||
|
## Making a story file
|
||||||
|
|
||||||
|
A story file is just a zip file of these files, so zip up story.ha, characters.json and about.json into a zip file (make sure these are in the root of the zip file).
|
||||||
|
|
||||||
|
## Playing your story
|
||||||
|
|
||||||
|
To play your story, simply run cargo run \<your zip file\>
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
# Syntax
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
This is done in the about.json file,
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
|
||||||
|
"title": "My Great Story",
|
||||||
|
|
||||||
|
"description": "please read!"
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Characters
|
||||||
|
|
||||||
|
See [Character documentation](/docs/CHARACTER.md) for more info
|
||||||
|
Referencing a character using the @, @NARRATOR is reserved for the Narrator.<br/>
|
||||||
|
Customisation is done with @CHARACTER change \<feature\> into \<feature name\><br/>
|
||||||
|
Move a character with @CHARACTER to fr
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> fr means front-right for instance.
|
||||||
|
|
||||||
|
## Outputs
|
||||||
|
|
||||||
|
```
|
||||||
|
@CHARACTER says "this string
|
||||||
|
is multi-line
|
||||||
|
and ends with a"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Variables
|
||||||
|
|
||||||
|
Variables are referenced with the \$, only integers will be supported.<br/>
|
||||||
|
|
||||||
|
## Selection
|
||||||
|
|
||||||
|
Condition based:
|
||||||
|
|
||||||
|
```
|
||||||
|
if (condition) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
elif (condition) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Choice based:
|
||||||
|
|
||||||
|
```
|
||||||
|
choice "choice 1" {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
or "choice 2" {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
or "choice 3" {
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Positioning
|
||||||
|
|
||||||
|
```
|
||||||
|
@CHARACTER to position
|
||||||
|
|
||||||
|
PAN to position
|
||||||
|
```
|
||||||
|
|
||||||
|
## Other
|
||||||
|
|
||||||
|
```
|
||||||
|
label:
|
||||||
|
|
||||||
|
GOTO label
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ending
|
||||||
|
|
||||||
|
`END` to exit out of the story
|
||||||
+2
-2
@@ -51,7 +51,7 @@ async fn main()
|
|||||||
error!("No filename specified");
|
error!("No filename specified");
|
||||||
exit(10);
|
exit(10);
|
||||||
});
|
});
|
||||||
let file = File::open(format!("../stories/{file_name}")) // Get the file
|
let file = File::open(file_name) // Get the file
|
||||||
.unwrap_or_exit("Failed to read file.", 11);
|
.unwrap_or_exit("Failed to read file.", 11);
|
||||||
let mut archive = ZipArchive::new(file) // Open the archive
|
let mut archive = ZipArchive::new(file) // Open the archive
|
||||||
.unwrap_or_exit("Failed to open archive", 12);
|
.unwrap_or_exit("Failed to open archive", 12);
|
||||||
@@ -93,7 +93,7 @@ async fn main()
|
|||||||
|
|
||||||
// setup the parsing stuff //
|
// setup the parsing stuff //
|
||||||
// Read the file and split it into tokens
|
// Read the file and split it into tokens
|
||||||
// file read from a zip file /story.ha
|
// file read relative to current directory
|
||||||
let mut story_file = archive.by_name("story.ha")
|
let mut story_file = archive.by_name("story.ha")
|
||||||
.unwrap_or_exit("Unable to read story file", 14);
|
.unwrap_or_exit("Unable to read story file", 14);
|
||||||
let mut file_contents = String::new();
|
let mut file_contents = String::new();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ pub fn token_parse(
|
|||||||
continue 'parse_loop
|
continue 'parse_loop
|
||||||
},
|
},
|
||||||
// Handle a character
|
// Handle a character
|
||||||
Some(tokenise::Token::Character(character_name)) =>
|
Some(tokenise::Token::Character(character_name)) => // TODO add support for narrator
|
||||||
{
|
{
|
||||||
index = match character_parse::character_parse(index+1,tokens,character_name.to_string(),characters,data_to_send)
|
index = match character_parse::character_parse(index+1,tokens,character_name.to_string(),characters,data_to_send)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user