GameText: Difference between revisions
(Created page with "== Public Static Methods == === static Map getMap(string mapName) === Gets map object from map name (string). Returns null if map with that name can not be found. == Publi...") |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[File:TextEditorScreenshot.png|thumb| | |||
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 | Gets parsed text from either game text or game text private | ||
=== | === static string getTextRaw(string textKey) === | ||
Gets UNPARSED raw text from text stores. | |||
=== string | === static void setTextOverride(string textKey, string value) === | ||
Allows a text key to be overridden with value. See notes in page header about proper usage! | |||
[[Category:LUA Class Reference]] | [[Category:LUA Class Reference]] |
Latest revision as of 21:36, 29 December 2017
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!