Strings are a plain sequence of alphanumerical characters -
letters, numbers or symbols - which can be used for messages, onscreen menus
or text panels.
They are defined this way:
STRING* name = "characters";
global string pointer with the given name and initializes it to the content characters between
double quotation marks. If the character content is spread
over several lines, line feeds are automatically inserted.
that in lite-C pointers are generally defined with a '*', so the green * is
required for lite-C, but must be omitted in C-Script.
The string alone, once defined, is not yet visible at the screen. To make
it visible, use a TEXT object. Text objects can
also used for defining initialized string arrays in
a similar way as variable arrays.
within a string must be preceded by a '\': \n -
Line feed; \\ - Backslash; \" -
Strings are similar to character sequences (char* or char)
in C / C++, but have the advantage to be easier to handle for beginners because
they don't need to be allocated, and
their length is automatically adapted.
Character contents in C-Script have a maximum length of 10000 characters;
there is no limit in lite-C.
The string length can't be changed in C-Script, but can be changed in lite-C
with str_cpy or str_cat.
Characters typed in the script - as in myfunction("Test!"); -
are a char array and not a STRING. This does normally not matter because
most engine functions accept char* as well as STRING* arguments,
but it does matter in special cases, like overloaded functions in lite-C
that depend on the types of the arguments.
The STRING struct is defined in include\atypes.h. For accessing single chars of a string, use f.i. (my_string.chars)[n] to get the n-th character of the string my_string.
STRING* player_name = "Player1";
STRING* welcome_str = "Welcome to the new game!\n\nEnjoy!";
STRING* empty_str = "";
STRING* name = "#n";
a global string pointer initialized to n
spaces. Use this for defining long empty strings.
If you want to start a string with a '#', use two
'#' characters (such as "##123").
STRING* sElements = "#100";
Variables, pointers, structs, functions