diff --git a/README.md b/README.md index 4cc82d5..4a19503 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ For help with syntax, see [this documentation](/docs/SYNTAX.md) ## Install -This is not really out of development, but to run it, clone the repo, go into /server/ and use cargo run story.zip to run a file called story.zip, relative to your current location. +This is not really out of development, but to run it, clone the repo, go into /server/ and use cargo run story.zip to run a file called story.zip, absolute or relative file location. ## Technical Details @@ -103,14 +103,11 @@ Move a character with @CHARACTER to fr > fr means front-right for instance. ## TODO -- Variables - /about.json -- If/Else if/Else -- PAN -- INPUT - tokeniser check for lack of END - Fix no closing brace edge case - Support single quotes for strings +- backslashes in strings - Brace index getter check for closing - Proper Error messages centralised??? diff --git a/client/start.sh b/client/start.sh new file mode 100755 index 0000000..a4b5f33 --- /dev/null +++ b/client/start.sh @@ -0,0 +1,4 @@ +killall happening-server +RUST_LOG=debug +happening-server $XDG_DATA_HOME/happening/stories/$1 & +cargo run . diff --git a/docs/SYNTAX.md b/docs/SYNTAX.md index 39721a5..083eb3a 100644 --- a/docs/SYNTAX.md +++ b/docs/SYNTAX.md @@ -15,22 +15,57 @@ This is done in the about.json file, ``` ## Characters - See [Character documentation](/docs/CHARACTER.md) for more info Referencing a character using the @, @NARRATOR is reserved for the Narrator.
-Customisation is done with @CHARACTER change \ into \
+Customisation is done with @CHARACTER change \ \
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).
+The interpreter can assume the data type so this doesn't need to be specified.
+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 @@ -41,18 +76,20 @@ Variables are referenced with the \$, only integers will be supported.
Condition based: ``` -if (condition) { +if condition { } -elif (condition) { +elif condition { // Only gets checked if the if and all previous elif statements failed } -else +else // Always passes if all previous if and elif statements failed } ``` +> [!NOTE] +> See [conditions](##conditions) Choice based: @@ -69,15 +106,35 @@ 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 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 ``` @@ -89,3 +146,4 @@ GOTO label ## Ending `END` to exit out of the story + diff --git a/stories/test/about.json b/stories/test/about.json new file mode 100644 index 0000000..65f3ce7 --- /dev/null +++ b/stories/test/about.json @@ -0,0 +1,4 @@ +{ + "title": "Once upon a Test", + "description": "This story is for testing purposes" +} diff --git a/stories/test/characters.json b/stories/test/characters.json new file mode 100644 index 0000000..62f85f5 --- /dev/null +++ b/stories/test/characters.json @@ -0,0 +1,27 @@ +{ + "tim": { + "name": "Timothy Sharpshooter", + "gender": "Male", + "skin_color": [0,0,0], + "eye_color": [0,0,0], + "hair_color": [0,0,0], + "pronoun_subject": "He", + "pronoun_object": "Him", + "pronoun_deppos": "His", + "pronoun_indpos": "His", + "pronoun_reflex": "Himself", + "head_shape": "normal-male", + "hair_style": "", + "torso_shape": "", + "arm_shape": "", + "leg_shape": "", + "clothing": { + "top": "", + "bottom": "", + "shoes": "", + "hat": "", + "gloves": "", + "neck": "" + } + } +} diff --git a/stories/test/story.ha b/stories/test/story.ha new file mode 100644 index 0000000..2c7237f --- /dev/null +++ b/stories/test/story.ha @@ -0,0 +1,27 @@ +$name = input +@tim says "hello" +@tim says $name +$x = 3 +$x + 1 +if $x == 4 { + @tim says "5" +} +elif $x < 5 { + + @tim says "<5" +} +else { + @tim says "whar" +} +label: +$choice_string = choice "choice numero uno" { + @tim says "super sad" +} +or "choice numero duo" { + @tim says "super unsad" +} +or "choice numero tres" { + @tim says "hola mi amigos" + goto label +} +END