VS Code plugin for ChoiceScript development
A VS Code plugin for ChoiceScript, a language for writing choose-your-own-path text games.
Install from the VSCode extension marketplace.
Open your ChoiceScript folder, often named mygame
, and the language server will index the entire project.
Note that, since ChoiceScript files are just text files, the extension treats all .txt
files as ChoiceScript files. To avoid that, only enable the extension for workspaces that contain your ChoiceScript game.
To run the game, press the Run Game button on the left side of the bottom status bar.
The game will open in a separate tab in Visual Studio Code. To restart the game, close that tab and then press the Run Game button again. The game will update with any changes you’ve made to your files.
You can test your game using ChoiceScript’s Randomtest and Quicktest utilities. Randomtest plays your game repeatedly to find bugs, making random selections at each choice. Quicktest methodically tests each #option in every choice.
To run the tests, right-click on one of your game files and select the test you want from the context menu.
Quicktest results will appear in the Output window at the bottom of VS Code. If Quicktest finds an error, the extension will add an annotation to the line with the error.
Randomtest requires more steps. When you run Randomtest, the extension will prompt you for how many times to run randomtest, whether to show the game’s text, and more. To skip that step, you can set default Randomtest settings in the extension’s settings.
If you run Randomtest without it printing the game’s text, the results will appear in the Output window. If it prints the game’s text, the results will open in a separate editor window that you can save. However, Randomtest can produce larger files than VS Code will allow the extension to open. In that case, it will save the results to a text file in your workspace. You can then open the file yourself.
You can take snapshots of your stats and save them to .csv
files that Excel and other spreadsheet programs can read. Start by defining what variables to save by putting the following comment in your startup.txt
file:
*comment savestatsetup [stat1] [stat2] [stat3] ...
Replace [stat1]
and the rest with a list of the variables you want to save. Put a space between each variable’s name.
Then, whenever you want to take a snapshot of the variables’ values, add the following comment:
*comment savestats
The results will be saved to a file called mygame-stats.csv
.
For more information about what you can do with information about your stats, please see this Choice of Games forum post.
When running RandomTest and printing the text, the resulting file can be very large. The extension allows you to capture the text from just a portion of your game by adding special comments to it. The line
*comment text off
will turn off text printing entirely.
*comment text on
will turn it back on.
Because of how ChoiceScript parses text, the comments must be surrounded by blank lines:
This will be shown.
*comment text off
This will be hidden.
*comment text on
This will also be shown.
To use the style snippets that turn ...
into an ellipsis and --
into an em-dash, enable snippet tab completion. Then type three periods and hit tab to turn them into an ellipsis.
For writing ChoiceScript games, VS Code’s auto-word suggestions can be annoying. To turn it off for ChoiceScript:
F1
to open the command palettePreferences: Configure Language Specific Settings...
and run that commandsettings.json
file that VS Code opens
{
"[choicescript]": {
"editor.quickSuggestions": {
"other": false,
"comments": false,
"strings": false
}
}
}
The ChoiceScript *image
command displays remote and local image. For the extension to show your local images when you run your game, put those image files either in the same directory as your scene files (such as startup.txt
) or in the directory above it.
choice_
is now properly flagged as an error.*save_checkpoint
and *restore_checkpoint
now don’t give an error when they don’t include a slot’s name.*save_checkpoint
and *restore_checkpoint
now autocomplete properly.choice_just_restored_checkpoint
and choice_saved_checkpoint
are now properly treated as built-in variables.*image
commands that refer to non-existent files are now flagged.*kindle_search
, *product
, *save_checkpoint
, and *restore_checkpoint
commands are now parsed.mygame
directory).*comment text off
and *comment text on
.*param
and array variables.*ifid
command.#options
and their associated *if
s.@{var dashed-word adjective|}
as potentially missing parentheses.*if var < -2
), which aren’t allowed.This update brings big new features: the ability to run your game in a browser for live-testing, and a way to run ChoiceScript Quicktest and Randomtest utilities from VS Code without having to download ChoiceScript.