String

**Strings** are text values found in a StarCraft map. Every modifiable piece of text in a map is a string. Strings may include special control codes to change things like text alignment and colors.

## String usage

The following elements use strings.

* Map title and description
* Force names
* Locations (even if unnamed)
* The "Anywhere" location
* Custom switch names
* Custom unit names
* All text used in the Comment, Display Text Message, Leaderboard, Set Mission Objectives, Set Next Scenario, and Transmission trigger actions
* All text used in the Mission Objectives, Text Message, and Transmission mission briefing actions
* WAV sound paths

## String limits

StarEdit and StarForge both limit mappers to 1024 individual strings. StarEdit additionally limits all strings to 1024 bytes. (That is, 1024 characters including control codes.) SCMDraft 2 and both of the Uberation programs support an unlimited number of strings. However, the total size of all strings cannot exceed 65536 bytes.

Each character in a string (including control codes) takes up one byte of data. Each string has a two-byte offset value and a one-byte null terminator (which marks the end of the string). So the string "Hello", for example, takes up 8 bytes.

Some third-party map editors, such as SCMDraft 2, will automatically recycle strings that are exact duplicates of each other (whitespace and control codes included). So if someone uses the string "Hello" eight times, SCMDraft 2 will only create one string. (Other map editors would create eight identical and useless copies of that string.) This helps keep maps from reaching the string limit.

### Saving strings

There are ways to save on strings if you hit the limit.

* Set Forces to all share the same name (or leave them unnamed to use the default names).
* Remove names from Switches. You can write down their functions in a text file.
* Remove names from named units that are being used as death counters. You can write down their functions in a text file.
* Removing names from Locations will not save strings, but setting all Locations to the same name will. (This could cause problems with SCMDraft 2's Text Trigedit, however.)
* When displaying multiple variables at once via Display Text Message, do not have multiple variables on the same line. (If you do, then you need to create a string for every possible combination of both values.)

## Control codes

Strings can contain special *control characters* that trigger various formatting changes. The control characters' effects tend to differ depending on where the string is displayed. Generally, a control character's effect will last until the end of the line or the next control code. Some codes, however, will "overflow"; they will affect the entire line (overriding subsequent codes). In some cases (such as in Mission Objectives), they will affect *all* text that follows them, ignoring newlines.

Such characters are only direcrly available in third-party map editors (you can copy and paste the actual bytes into StarEdit if you have them), and the means through which they are added vary from editor to editor. StarForge provides mappers with clickable buttons; SCMDraft 2 allows mappers to type the character's hex code surrounded by angle brackets (e.x. `<0E>`). To maintain consistency, the SCMDraft 2 notation for control codes will be used in the lists below.

### List of control codes

**Global control codes**
These codes have the same effect regardless of where they are displayed.

**Title screen control codes**
The effects of certain controls on title screen text.

**Glue control codes**
The effects of certain controls on text in lobbies, mission briefings, menus, etc..

## Overlapping text in unit names

 File:Overlapping Unit Name.png
With clever use of string formatting, mappers can overlap text in unit names, giving such names a multicolored appearance. Unfortunately, color and overlapping are disabled in forces, and using overlapping in a map name makes games unjoinable.

Overlapped names tend to look like this:

```
[B]Name[F]Name[T][T][T][T][S][S]

```

...where "Name" is the unit name, "[B]" represents a backspace character (known as "Center Align" in SCMDraft 2), "[F]" represents a frontspace character (known as "Right Align" in SCMDraft 2), "[T]" represents a normal tab, and "[S]" represents a normal space. ("[B]", "[F]", etc., are not the actual characters used to achieve this effect. They are representations; different map editors use different characters.)

The amount of tabs needed to successfully overlap a name tends to vary depending on the name that is being overlapped. The following table contains general estimates. If they are not working, adding or removing a tab may fix any problems. Note that names longer than 12 characters do not always work, and names shorter than 4 characters sometimes become buggy.

 2-3 | 5

In cases where the technique isn't working, adding characters after the two trailing spaces may help to properly align the text, and using invisible characters (such as "W", "%", and "Q") in place of tabs may also help. You may notice that SCMDraft 2 and StarForge display control codes (like the backspace character) as tombstones (□); this is perfectly normal.