Files

150 lines
2.9 KiB
Markdown

# 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\> \<feature name\><br/>
Move a character with @CHARACTER to fr
Outputting can be done with @CHARACTER says "string", see more at (outputs)[##outputs]
> [!NOTE]
> fr means front-right for instance.
## Variables
Currently only strings and integers are supported as variable types (booleans are planned).<br/>
The interpreter can assume the data type so this doesn't need to be specified.<br/>
To assign new variables (or overwrite existing ones):
```
$x = 1
$an_integer = 3
$y = "hello"
$a_string = "world"
```
> [!NOTE]
> Variable names can be as long as you want and can contain any characters except whitespaces
To modify existing variables:
```
$x + 1 // Adds 1 to an integer x
$x - 1 // Subtracts 1 from an integer x
$y + " world" // Appends " world" to the end of a string y
```
Other uses:
```
$x = choice "choice 1" { // Assigns to x the choice made by the client
...
$x = input // Assigns to x the string input made by the client
```
## Outputs
```
@CHARACTER says "this string
is multi-line
and ends with a"
$x = "hello world"
@CHARACTER says $x
$name = "deadvey"
@CHARACTER says "hello $name"
```
> [!NOTE]
> Strings only support double quotes now ("") and do not support having quotes within quotes.
## Variables
Variables are referenced with the \$, only integers will be supported.<br/>
## Selection
Condition based:
```
if condition {
}
elif condition { // Only gets checked if the if and all previous elif statements failed
}
else // Always passes if all previous if and elif statements failed
}
```
> [!NOTE]
> See [conditions](##conditions)
Choice based:
```
choice "choice 1" {
}
or "choice 2" {
}
or "choice 3" {
}
```
You can assign a variable to the result of a choice by doing the following:
```
$x = choice "choice 1" {
...
```
## Positioning
```
@CHARACTER to position
PAN position
```
## Conditions
A condition works works like this:
```
$x == "hello" // evaluates true only if x is "hello"
$x > 1 // evaulates true if x is an integer and is more than 1
$x < 1 // evaluates true if x is an integer and is less than 1
$x >= 1 // evaluates true if x is an integer and is more than or equal to 1
$x <= 1 // evaluates true if x is an integer and is less than or equal to 1
```
> [!NOTE]
> == can be used for integers or strings whereas the rest can only be used with integers
The order (variable operator value) is currently fixed and so must be layed out like this.
## Other
```
label:
GOTO label
```
## Ending
`END` to exit out of the story