Strings hold phrases of text in them, and are declared with either the "str" or "string" keyword.
string name; // This creates a string variable named name name = "Mud"; // This sets name to the string value "Mud"
Strings can be joined together, with the "+" operator. This operation is called concatenation.
str a = "Fiendish"; str b = "Grapefruit"; Log(a + " " + b);
Integers can be converted into strings through casting:
int hp = 5; int max_hp = 32; Log("HP: " + string(hp) + " / " + string(max_hp));
Likewise, strings can be converted into integers.
int x = int("5 apples"); int y = int("9 oranges"); int sum = x + y;
From older versions, there is also the val(s) function, which is the same as casting into int. Note that both val and int casting will cleverly attempt to convert to a number, even if the string is not entirely numeric. If there is a number at the beginning of the string, it will use that numeric part. If the conversion completely fails, it returns 0.
Is a string a fixed number of characters?
vec: No. There's limits in some situations.. log and exit() probably have limits of 4k. But general string ops are virtually unlimited.
Gayo: Nyahaha. I set up a loop to double the size of a string with every iteration and got to several hundred megs of memory usage before giving up.
Because the memory is dynamically allocated to the string at runtime, you have very few bounds worries.