GameText

From SkyCorp Global
Jump to navigation Jump to search
An example of text key/value pairs from the text editor.

Game Text is a key-value dictionary that stores much of the game's text. Keys are all uppercase, containing no spaces, but do contain underscores.

There can be multiple dictionaries loaded, but it is expected that text keys are unique across all dictionaries, so multiple dictionaries are essentially one big dictionary. Currently there is one for private builds, one for public+privates builds, and an "override" dictionary which code can use to override dictionary values at run-time. In this way, AS3 or LUA code can change just about any string in the game. However, it is not recommended to change shared text in this way as multiple mods accessing the same text may conflict with each other, leading to unexpected results

Generally, Game Text values should not include a trailing paragraph (\n\n) as that is added via the withParagraph parameter.

In future, I would like to provide a mod type for UGC game text dictionaries. For now you can add your own via setTextOverride during startup. It is recommended that you set a keys like MOD_NAME_ACTION_NAME to prevent colliding with existing game text or other mods. If you use the same mod name as your mod wiki page, you can be assured of no conflicts.

Public Static Methods

static string parseText(string unparsedText)

Parses text and returns the result. See Text Variables.

static boolean hasText(string textKey)

Does specified text key exist in any loaded dictionary?

static void printText(string textKey, [boolean withParagraph=true])

Gets the text for textKey, parses the text using ParseText, then prints it to screen. If withParagraph is true or unset, then a paragraph is added

static string getText(string textKey, [boolean withParagraph=true])

Gets parsed text from either game text or game text private

static string getTextRaw(string textKey)

Gets UNPARSED raw text from text stores.

static void setTextOverride(string textKey, string value)

Allows a text key to be overridden with value. See notes in page header about proper usage!