Difference between revisions of "GameText"

From SkyCorp Global
(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...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Public Static Methods ==
+
[[File:TextEditorScreenshot.png|thumb|
 +
An example of text key/value pairs from the text editor.
 +
]]
  
=== static Map getMap(string mapName) ===
+
Game Text is a key-value dictionary that stores much of the game's textKeys are all uppercase, containing no spaces, but do contain underscores.
Gets map object from map name (string)Returns null if map with that name can not be found.  
 
  
== Public Methods ==
+
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
  
=== boolean addItem([[Entity]] entity, int roomID) ===
+
Generally, Game Text values should not include a trailing paragraph (\n\n) as that is added via the withParagraph parameter.
Attempt adding entity to roomID.
 
  
More performant to use entity's
+
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 startupIt 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 ==
Called during drop item, could also be used to drop new items/loot/etc
 
 
 
=== boolean deleteItem([[Entity]] entity) ===
 
Attempt removing an item from anywhere in the map
 
 
 
Called from pickupCould also be used to destroy an item in a room.
 
 
 
=== string getRoomName(int roomID) ===
 
Gets name of room.  If no such room, returns "INVALID ROOM"
 
 
 
=== [[Entity]] getNamedEntityInRoom(string entityName, int roomID) ===
 
If the map has the named entity in the given roomID, return it.  Else null.
 
 
 
=== [[Entity]] getEntityInRoomByType(class entityClass, int roomID) ===
 
TODO - not yet hooked up, need to figure out how to best pass class information between AS3/LUA.
 
 
 
=== void setTagBoolean(int roomID, string tag, boolean enabled) ===
 
Sets a tag for a room which can be useful for classifying rooms or applying special properties.
 
  
This version will set the tag to be either True or False (this system could be expanded in future to allow for string or other object storage inside tags)
+
=== static string parseText(string unparsedText) ===
 +
Parses text and returns the result.  See ''[[Text Variables]]''.
  
Tags are used in a number of game locations to keep track of types of places.  For instance, in the strip club, it is used to tag rooms where the patrons can see the player.
+
=== static boolean hasText(string textKey) ===
 +
Does specified text key exist in any loaded dictionary?
  
Parameters:
+
=== static void printText(string textKey, [boolean withParagraph=true]) ===
* roomID: room to change
+
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
* tag: tag name to change
 
* enabled: what to set tag state to (true/false(false is same as unset)
 
  
=== boolean getTagBoolean(int roomID, string tag) ===
+
=== static string getText(string textKey, [boolean withParagraph=true]) ===
Gets a boolean tag for a certain room.  False if room or tag does not exist, or is set to false.  True if it exists and is set to true.
+
Gets parsed text from either game text or game text private
  
=== int getRoomIDOfEntity([[Entity]] entity) ===
+
=== static string getTextRaw(string textKey) ===
Which room is a particular entity in?  If not found, then 0
+
Gets UNPARSED raw text from text stores.
  
=== string getName() ===
+
=== static void setTextOverride(string textKey, string value) ===
Name of the map
+
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

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!