ChoiceScript Wiki

    The *script command allows for JavaScript to be used directly in a ChoiceScript game.

As ChoiceScript works on top of JavaScript there should be no errors if it is used correctly, however, the *script command and other JavaScript elements are beyond the scope of this wiki and ChoiceScript in general, and is not supported by Choice of Games, the ChoiceScript Development team, nor the ChoiceScript community. Additionally, as the *script command requires prior knowledge of JavaScript, unless you are already proficent in JavaScript, the *script command should be avoided.


A basic use of *script is as follows:

*temp terminale
*set terminale false
*label menu
[b]CSS Demo[/b]
 *if (terminale = false) #Change to Computer Terminal CSS
   *set terminale true
   *script changeDisplay("terminal")
   *goto menu
 *if (terminale) #Change to Story CSS
   *set terminale false
   *script changeDisplay("story")
   *goto menu

Then, in a javascript file (it is recommended that you declared another file in index.html and use that instead of one of the preexisting files to make updating and error checking easier):

function changeDisplay(type) {
var body = document.getElementById("body");
if (type == "terminal") { = "Courier New", "Lucida Console", "Arial"; = "#000000"; = "#5DFC0A";

if (type == "story") { = "Georgia","Times New Roman", "serif"; = "#F7F4F1"; = "rgba(0, 0, 0, 0.85)";

This will make a choice which switches the style of the page between what is normally is, and an old fashioned computer terminal, with a black background and green text.

In short, with *script, anything that JavaScript can do, ChoiceScript can also do, so long as you already know JavaScript.

More commands / functions
Choice *choice, *fake_choice, *disable_reuse, *hide_reuse, *allow_reuse, *selectable_if
Variable *create, *temp, *set, Arithmetic operators, *delete, *input_number, *input_text, *print, *rand
Conditional *if, *elseif, *else, Multireplace
Goto *label, *goto, *goto_scene, *goto_random_scene, *gosub, *gosub_scene, *finish
Formatting Bold text, Italic text, *image, *line_break, *page_break, *link, *stat_chart
Miscellaneous *comment, *scene_list, *title, *author, *achieve, *achievement, *check_achievements, *bug, *ending, *more_games, *share_this_game, *show_password, *script, Implicit Control Flow