String

From Staredit Network Wiki
Jump to: navigation, search

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.
01 Use object default.
Usually cyan.
09 Tab.
Does not appear in SCMDraft 2 previews.
0A Line break. 0B Invisible.
Overflows. Does not appear in SCMDraft 2 previews.
12 Right align.
Does not appear in SCMDraft 2 previews.
13 Center align.
Does not appear in SCMDraft 2 previews.
14 Invisible.
Overflows. Does not appear in SCMDraft 2 previews.


Title screen control codes
The effects of certain controls on title screen text.
02 Sky blue 03 Peach 04 White 05 Grey
Overflows.
06 Green 0D Sky blue 0E Sky blue


Glue control codes
The effects of certain controls on text in lobbies, mission briefings, menus, etc..
02 Sky blue 03 Green 04 Light Green 05 Grey
Overflows.
06 White 07 Red 0D Sky blue 0E Sky blue


In-game control codes
The effects of certain controls on text in Mission Objectives, unit names, etc..
02 Cyan 03 Yellow 04 White 05 Grey
Overflows.
06 Red 07 Green 08 Red (Player 1) 0E Blue (Player 2)
0F Teal (Player 3) 10 Purple (Player 4) 11 Orange (Player 5) 15 Brown (Player 6)
16 White (Player 7) 17 Yellow (Player 8) 18 Green (Player 9) 19 Bright Yellow (Player 10)
1A Cyan 1B Tan (Player 11) 1C Dark Cyan (Player 12) 1D Greygreen
1E Bluegrey 1F Turquoise

Overlapping text in unit names

An example, seen in-game.

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.

Characters in name Tabs required
11-12 1
9-10 2
7-8 3
4-6 4
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.