ChoiceScript now includes an easy way to export your game to HTML, which, in turn allows us to make checkpoints and achievements available to all users of ChoiceScript.
When you follow our ChoiceScript introduction, you’ll run the “ChoiceScript server,” which will make your game available in your browser, locally, just on your machine.
When you view a ChoiceScript game in your browser via that server, you’ll find a new “Export to HTML” link at the bottom of the page:
When you click it, ChoiceScript will convert your entire game into a single HTML file, and then say:
Click here to download your compiled game.
When you click on that generated link, you’ll download an HTML file containing your game. You can double-click on it to play it immediately.
Even better, if your game includes an
*ifid command, the exported HTML file will autosave your progress in the user’s browser. (And, if you don’t have an
*ifid command, the exporter will generate one for you, which you can copy and paste into your
Read the documentation for the “Export to HTML” feature for additional details.
Once you’ve exported your game to HTML, you can that distribute that file to testers via email, Google Drive, Dropbox, or, best of all, as an attachment on our forum.
To upload HTML, drag your HTML file into your post. Like this!
My_First_ChoiceScript_Game.html (462.5 KB)
Players can download the attachment and double-click on it to play your game. (Try refreshing your browser tab, or closing and reopening it. You’ll keep all of your progress!)
While I was in there, adding links, I added in links to Quicktest and Randomtest, making it easy for you to find and run the tests just by clicking the links.
You probably saw the thread about this back in October, and, now, it’s finally here.
To save a checkpoint, you’d use:
Then, later, you’d give players the option to restore to a previous checkpoint, like this:
*choice #Continue to the next chapter. *finish #Restore to the previous checkpoint. *restore_checkpoint
*restore_checkpoint, the player will “travel back through time” to the moment that
*save_checkpointwas called. This includes re-enabling any
*disable_reuseoptions that the player may have used after saving the checkpoint.
(Previously, if you wanted to implement checkpoints yourself, you’d have to use a
*gosub_sceneto individually copy all of your stats to separate “backup” variables, and then use another subroutine to individually copy all of your stats from the backup to the main variables. This was tedious and error prone.)
We’ve also added a “Tricks with Checkpoints” section to the “Advanced ChoiceScript” guide, with these tips and tricks:
- Check whether *save_checkpoint has happened yet
- Run some code after restoring from a checkpoint
- Exclude some stats/temps from being restored
- Multiple checkpoint “slots”
- Restore to the last checkpoint at any time from the stats screen
- Player-named save slots
Note that if you’re testing your game in the ChoiceScript server, when you refresh your browser tab, the entire game will reset from the beginning, losing all progress, including checkpoints and achievements, but when you export to HTML, all of that stuff will be saved.
You can now define achievements using the
*achievement command at the start of
startup.txt, activate achievements using the
*achieve command, and check which achievements the user has earned using the
Check out our new documentation page on “Achievements in ChoiceScript” for additional details.
ChoiceScript has had this achievements feature for many years, but we treated it as a “private” ChoiceScript feature, available only to authors publishing via Hosted Games, Choice of Games, or Heart’s Choice, because there was no good way to save any of the achievements that the player unlocked; whenever you’d close or refresh the browser tab, you’d lose all of your achievements.
But the “Export to HTML” feature now provides a way for any ChoiceScript author, even an unpublished author, to offer achievements that won’t disappear.