https://github.com/plytonrexus/if-script
An extremely simple syntax for writing interactive fiction that can be embedded anywhere on the web.
https://github.com/plytonrexus/if-script
choice-syntax embedded hacktoberfest interactive-fiction syntax text-adventure-game
Last synced: about 1 month ago
JSON representation
An extremely simple syntax for writing interactive fiction that can be embedded anywhere on the web.
- Host: GitHub
- URL: https://github.com/plytonrexus/if-script
- Owner: PlytonRexus
- Created: 2020-06-23T20:24:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T02:52:41.000Z (over 2 years ago)
- Last Synced: 2025-05-18T19:11:20.829Z (5 months ago)
- Topics: choice-syntax, embedded, hacktoberfest, interactive-fiction, syntax, text-adventure-game
- Language: JavaScript
- Homepage: https://plytonrexus.github.io/if-script/
- Size: 3.48 MB
- Stars: 10
- Watchers: 1
- Forks: 2
- Open Issues: 45
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# IF-SCRIPT
A straightforward syntax for writing interactive fiction can be embedded in any website.Make interactive fiction with variables, timers, conditions, music and statistics. The story is parsed into plain HTML, CSS and JavaScript.
[Try it!](https://plytonrexus.github.io/if-script/)
You can use Markdown to format your story.
_[Markdown cheat-sheet](https://www.markdownguide.org/cheat-sheet/) for reference._### Dependencies
[Nearley](https://github.com/kach/nearley) for parsing.
[Showdown](https://github.com/showdownjs/showdown) for markdown rendering.A Regular Expression based parser is on the [if-script-regex](https://github.com/PlytonRexus/if-script/tree/if-script-regex) branch.
### [Embedding](#embedding)
Within the head tag, add the following.
```html
```
In your body, add the following scripts.
```html
IF.methods.loadStory(IF.story);
```*The indentation does not matter.*
### [Comments](#comments)
A comment is a text block that is not integrated into the final model of the story. Comments exist to help write cleaner stories, for example, by pointing out the purposes of certain portions of the story.
```
/* A
multi-line
comment */
```### [Variables](#variables)
Variables truly create dynamic stories. You can use variables to store many things like character names, inventory items, visited scenes, number of things and many others. You can then display the values of these variables anywhere like so:
```
Your name is ${name}.
```
Here, variable `name` was used to store the name of a character.
The variables can also be used in conditional logic to determine which [choices](#choice-syntax) and (in a future release) what paragraphs of a [section's](#section-syntax) text should be visible to the reader. You can find more about this under the [choices](#choice-syntax) heading.You can assign variables beforehand inside story [settings](#settings-syntax).
```
${name='Felicity'}
```*It is recommended (albeit not required) to keep the* `title`*variable set as the title of the story.*
### [Story Settings](#story-settings)
Story settings allow you to customise the overall experiance of the story. All of the settings are optional. The available settings are:
- `@startAt` decides the starting section of a story. (Default: 1)
- `@referrable` decides if the older sections remain visible once the reader moves to a new section. (Default: false)
- `@fullTimer` decides the amount of time alloted for completing a story. (Default: none)
```
settings>
@startAt
@referrable
@fullTimer@first section_number (optional)
@music link (optional)
@sections space_seperated_section_numbers
@name custom_name_for_scene
tt> Section Title
You are named five [[5]]You are named five [[scene:5]]
Choose 'Felicity' as your name ${__name} [[5]]
Type in your name here: __input ${__name} [[5]]
= var2` First is greater than or equal to second
- ` var1 <= var2` Second is greater than or equal to first
- ` var1 > var2` First is greater than second
- ` var1 < var2` Second is greater than first
```
ch>
${__if name == "" || namePower <= 0}
Type in your name here __input ${__name} [[5]]The power of your name goes up 10 units, and your health
is multiplied \${namePower} times.
${__namePower + 10} ${__health * namePower} [[5]]