User:Scrivener07/Strings

From the Fallout4 CreationKit Wiki
< User:Scrivener07
Revision as of 18:04, 13 June 2019 by imported>Qazaaq (Changed note about localized strings.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In practice, Papyrus strings are case-insensitive due to the way the game engine's string pool operates for efficiency reasons. Most strings in the engine come from this same case-insensitive string pool, with a few exceptions. The pool works by caching a unique occurrence of a string whenever one is encountered by the game engine for the first time. The pool will reuse the cached version of a string for any following occurrences. This means the distinction between uppercase and lowercase may not exist.

For example, the strings "MyString" and "mYsTrInG" are technically equivalent. Which string is used depends on which version of the string is encountered by the game engine first. The game's load order has an influence on this, among other things. Following the example, if "mYsTrInG" is cached first then any following occurrence of "mystring" will always be "mYsTrInG".

This is potentially a problem for some Game Systems which require a case-sensitive string.

Workarounds[edit | edit source]

In general the workaround to creating a string with any preferred casing would be to use a pseudo uniqueness. For example the string "raider" is cached but you want "Raider". You can use a pseudo uniqueness by prefixing or suffixing the string with a space character (" "). Sticking with the example, the user would be none the wiser if you used "Raider " for UI purposes. This is not a suitable workaround for all cases. For other cases you should make your strings more unique if possible.

Notes[edit | edit source]

  • The game engine internally uses a data structure called BSFixedString for handling string data.
  • Localized strings, internally BGSLocalizedString, are also vulnerable to string pool limitations.
  • UI function calls to Scaleform are affected by this string casing limitation.
  • Initialization File related function calls are affected by this string casing limitation.