Writing ChoiceScript Games in Visual Studio Code

I’m working on a game for Choice of Games using their ChoiceScript programming language. You write it using an editor that deals with plain text files. To make that job easier for me, I wrote a ChoiceScript extension for Visual Studio Code, a popular text editor.

The TL;DR if you already know you want to write ChoiceScript in VS Code: install the extension from inside VS Code or from the marketplace. If you want to add spellchecking, use the Spell Right extension that I modified to work with ChoiceScript by downloading the .vsix file from GitHub and installing it.

Why Would I Want to Use This Extension?

VS Code is Microsoft’s free text editor that a lot of people use to write computer programs. It has a lot of nice features that help you write computer code. ChoiceScript is aimed at writers without a lot of programming experience, but underneath it’s still a programming language, and a programming text editor like VS Code combined with a ChoiceScript-specific extension can help you write your game more quickly and with fewer errors.

Here’s an example of my extension in action.

Animated gif of the ChoiceScript extension automatically suggesting commands, variables, and handling indentions.

There’s a lot going on in that animation. As I typed a ChoiceScript command like *if, the extension suggested commands that matched what I’d typed so far. You can select the command you want in the drop-down list and hit Enter to auto-complete the command. After that, when I started typing trait and hit Tab, the extension knew I wanted to add in a previously-defined variable. It suggested trait_outgoing, which was the one I wanted, so I only had to hit Enter to finish typing it. It also put a red squiggly mark under the entire *if line until I added something underneath it. That’s because the extension knows that, in ChoiceScript, an *if has to have at least one indented line below it, or else it’s an error.

For me, its error catching is one of the extension’s most helpful features. It can detect common ChoiceScript errors and give you information about what’s wrong.

Error and the associated error message explaining what's wrong.

You can find every place in your game where you used a variable. Need to rename that variable across your entire game? No problem!

Searching for where a ChoiceScript variable appears in your entire game.

The extension will also outline your current game file. You can see every label, choice, and option to get a feel for how your game is structured. You can jump to any element in the outline by clicking on it.

Outline of a ChoiceScript game.

Where Do I Get This Marvelous Toy?

Start by downloading and installing VS Code, if you don’t already have it.

Once VS Code’s installed, run it. Bring up the Extensions view by clicking on the Extensions icon in the left bar:

VS Code Extensions view icon.

In the Extensions view, search for the ChoiceScript extension by clearing the search bar at the top of the view and typing “ChoiceScript Language”, then pressing Enter. That should bring up the ChoiceScript extension. Once you’ve found the extension, click the “Install” button on the extension’s description page.

What Else Do I Need?

VS Code doesn’t include a spell checker by default, and the standard spell checking extensions don’t play nice with ChoiceScript. I modified the Spell Right extension to work with ChoiceScript. You have to install my modified extension by downloading the .vsix file from GitHub. Once you’ve downloaded it, install it by following these instructions.