ChoiceScript Wiki

      This article is aimed at beginners to ChoiceScript. However, if you have not already done so then the best place to start would be with the very first article in this Introduction To ChoiceScript Game Development series of linked articles: A Basic Tutorial.

The "value" (content) of any variable -- either temporary or permanent, and of any of the three data types -- can be displayed in-game on the Stats Screen as well as within any scene.

Displaying numeric variables

Variables intending to be displayed should be preceded by the dollar $ symbol and with the variable name itself enclosed within {curly braces} like so. For example, to display the current value of the numeric variable called var we would simply use:


Which would display as:


Or whatever its current value actually is.

If intending to display a numeric value as actual dollars it is necessary to add an extra dollar $ symbol like so:


Which would then properly display as:


Displaying string variables

String variables (containing "some text") are also displayed using the dollar $ symbol and with the actual variable name enclosed in curly braces. For example:

Hello, ${first_name}!

If the variable first_name currently contained the value of "alex", the above example would display as:

Hello, alex!


If we want to make sure that the first_name variable is always displayed with a capital letter, we can add an exclamation mark just after the dollar $ symbol but before the curly braces, like so:

Hello, $!{first_name}!

Which would then properly display as:

Hello, Alex!

We can also capitalize the entire content of a string variable, using two exclamation marks, as follows:

Hello, $!!{first_name}!

Which would display as:

Hello, ALEX!

For permanent variables, we could of course simply define the string variable in startup.txt with capital letters as required, instead of using exclamation marks when actually displaying them in-game, but sometimes defining string variables all in "lower case" and displaying them as above allows for more flexible use of that variable.

Displaying boolean variables

Although there is unlikely to be an in-game need, you can in fact also display a boolean (true / false) data type, perhaps temporarily for such as testing / debugging purposes, using the exact same method. Doing so will display either true or false, as appropriate at that point in your scripting. Note, however, that using exclamation marks for capitalization does not work with non-string data types.

Extracting letters/numerals from variables

It is also possible to extract individual characters out of a variable.[1]

To display only a particular character in a variable, simply add the pound sign (#) and the number (1 if you want the first character, 2 for the second etc) to the variable name in the curly braces, as such:

*temp word "hello"
The word is ${word}, its first letter is ${word#1}, its second letter is ${word#2}.

Will display:

The word is hello, its first letter is h, its second letter is e.

To display the last letter or numeral of a variable when you don't know how long the variable might be, you can have ChoiceScript figure out the length of the word, as such:

*temp word "hello"
*temp word_length length(word)
*temp last_letter word#word_length
The word ${word} is ${word_length}, and so its last letter is ${last_letter}.

Will display:

The word hello is 5, and so its last letter is o.

To simply show the last letter, you can write instead:

*temp word "hello"
The word is ${word}, its last letter is ${word#length(word)}.

Which will display:

The word is hello, its last letter is o.

This works with all types of variables.


There is an alternate way of displaying variables, using the archaic command *print, but this command is deprecated and will most likely be removed at some point in the future. We strongly advise against using any deprecated commands.

Next Tutorial Article: Basic Scripting Techniques

Related articles