Technical preparations

Boilerplate

The easiest way would be to take the source code for an existing game and alter it. The Salet demo is a good option because it's kept up-to-date.

  1. Install node.js if you don't have it.
  2. Do a project copy using git clone somewhere or download the archive.
  3. Call npm install and wait until every dependency is installed. Shouldn't take much time.

Now you have a repository copy ready to start. You'll be working on your game in it.

Some things you should look at when you begin working:

  1. Open game/begin.coffee and change the salet.game_id to something else. UUID would be a good choice. It should be a unique string, so your game's saves wouldn't clash with saves from other games, see the Saving chapter.
  2. Salet itself and Salet games are written on CoffeeScript. To comment out a line, put a # symbol in start of it.
  3. The gulp serve command should show you a live preview of your game. You can edit the files and then your browser would update the game with the latest changes.

Now you're ready. To compile the game out of your sources, call:

gulp dist

and you'll get a dist folder with your game. A gulp zip command will automatically pack it into a .zip archive.

And start writing!

You can use services like codepen.io or jsfiddle.net to create, edit and share IF.

Just make a new document and include Marked, jQuery and Salet core in it. The latest Salet version is accessible on a NPM CDN.

About CoffeeScript

This wiki uses CoffeeScript interpreter to make Javascript code easier. You can learn the language from the CoffeeScript website.

A short text is denoted by quotes: "like this" and a long text is marked by three quotes """ like this """.

It is not required to use CoffeeScript, you can choose any language that works in the browser but CoffeeScript is easier than Javascript and all our examples use it.

Markdown

Salet formats all the game text using Markdown syntax.

Markdown and indentation

In Markdown, spaces are a big deal. If a line starts with many spaces, Markdown thinks it's a programming code.

But in CoffeeScript, spaces are a big deal too. The language uses indentation to figure out where the blocks and branches end.

CoffeeScript lets you write the text without any indentation but many people have a hard time figuring out the code like that because the indentation is "shaky".

So Salet automatically cuts the text indentation to the smallest indentation in this text, so you can write something like this:

room "prelude",
  dsc: """
    # A limerick

    [Read](./_writer_read)
  """,
  writers:
    read: """
    There was an Old Man who said, "Hush!  
    I perceive a young bird in this bush!"  
    When they said—"Is it small?"  
    He replied—"Not at all!  
    It is four times as big as the bush!"

    **(E. Lear)**
    """

The example above has the first text block indented to be visually "inside" the code and the second text block to be on the same level.

Salet doesn't do anything about trailing spaces.

Start the game from scratch

If you are starting from scratch, you should already know about webdev and NPM packages. In that case, just run this console command:

npm install --save salet

You can also use CoffeeScript, SASS, Gulp, or write it all however you like. Salet also requires jQuery library - CDN-provided or local.