The *create command is used to declare the permanent variables your game will use to reference and store its data, such as character statistics and other information pertinent to your game. Unlike most other ChoiceScript commands, the *create command can only be used in startup.txt. There is no real limit to the number of different variables you can *create in that file, but each must be uniquely named.
Although it is generally a good idea to design and plan your game in advance - especially such as the character statistics it will use - you may edit startup.txt at any time during the development process to add new variables to your game by adding (or inserting - the order in which they are listed is not important) new *create commands to your starting list.
However, not all game data needs to be created at the start of play and stored / updated throughout play. It is very common to use temporary variables for a limited, specific purpose in the game and which, unlike permanent variables, can be declared at any point in any scene .txt file using the *temp command.
In startup.txt, each *create command must occupy a line of its own, as shown below. Note that your list of *create commands must be placed in that file after the *title, *author and *scene_list commands, never before. See startup.txt for more information on the precise layout of that file.
*title My Little Adventure *author Anonymous *scene_list startup chapter1 *create name "Unknown" *create gold 0 *create backpack false
In this example, our startup.txt file has the game *title and *scene_list commands properly preceding the list of starting game variables that we intend to use in our game. Our two example scene starting files - startup and chapter1 - are also listed as required (and that list will grow as we create new scene files for our game and add them to this list in startup.txt).
The three permanent variables we are creating are called 'name', 'gold' and 'backpack' respectively and each of these is using a different data type, determined by the final piece of information entered on each *create line - a "string" value (to store "some text"), a numeric value (0 starting gold in this case), and a boolean value which can only ever be true or false (in this case, no, the player does not begin the game with a backpack and so the starting value has been set to false). See the article on data types for a more detailed explanation of each of the three data types.
Although your game will probably use far more than three variables, the rules remain the same -
- each *create command must be listed on its own line
- each variable name must be unique and should not contain spaces; under_scores_are_fine, however
- each variable name should be in lower case only, and must always at least start with a letter a-z, not any other character or a number (it may contain a number elsewhere, such as at the end, e.g. 'var6')
- each variable must be given a starting default value of either "some text", a number, or true / false
Changing variable values later on
See the *set command for details of how to later change the default starting value of any variable at any point in the game (e.g. when a player chooses their own name, finds some gold, or buys a backpack).
|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|