String register
String registers, sometimes referred to as s# or sreg for short, are a variation on standard registers that are used to contain a string that can be "embedded" in another text string which will be displayed in dialogue or messages. When embedded into a string, they are one of the four methods of producing dynamic text for the player (the others being registers, conditional strings, and gender strings).
Using string registers
String registers are used by inserting them ("embedding them") into a text string between braces ("{" and "}"). When the text is displayed to the player, the contents of the string register are substituted in place of the braces. Note that spaces and other text inside a string register is included literally, exactly as written.
String registers have fixed variable names, being identified by the letter "s" followed by a number starting from 0. The following text string:
You dare question the might of {s43}?! Prepare to die, {s5}!
contains two string registers, corresponding to ID numbers 5 and 43, which will have to be filled with content prior to being displayed to the player. These string registers can be assigned values by using the string register manipulation functions to assign values to s5 and s53; in this case, the most likely functions used would be str_store_string_faction_name for s43 and str_store_string_troop_name for s5.
Manipulating string registers
String registers can be manipulated with the various string register functions. The first parameter is always the ID of the string register to assign a value to. The second parameter, if included, is the ID of the object to extract the name from.
Function | Parameters | Notes |
---|---|---|
str_is_empty | register | Condition function. Returns 1 if the specified register is not in use (has been cleared or has never been assigned), 0 otherwise |
str_clear | register | Clears the contents of register — rarely necessary, but chiefly useful to clean up if you stored a very large amount of text in a register that is unlikely to be overwritten |
str_store_string | register, string | Stores the string or quick string string into register |
str_store_string_reg | register, register2 | Copies register2 over register |
str_store_troop_name | register, troop | Stores the name of the specified troop (e.g., Sarranid Mameluke) in register |
str_store_troop_name_plural | register, troop | Stores the plural name of the specified troop (e.g., Sarranid Mamelukes) in register |
str_store_troop_name_by_count | register, troop, number | Intelligently stores the single name of the specified troop if number is equal to 1, or the plural name otherwise, in register |
str_store_item_name | register, item | Stores the name of the specified item (e.g., Leather Gloves) in register |
str_store_party_name | register, party | Stores the world map name of the specified party (e.g., Bandits Awaiting Ransom) in register |
str_store_agent_name | register, agent | Stores the name of the specified agent (e.g., Nervous Man) in register |
str_store_faction_name | register, faction | Stores the name of the specified faction (e.g., Kingdom of Sarranids) in register |
str_store_quest_name | register, quest | Stores the name of the specified quest (e.g., Ransom Kidnapped Girl from Bandits) in register |
str_store_info_page_name | register, infopage | Stores the name of the info page infopage (e.g., Military Campaigns) into register |
str_store_date | register, hours | Adds the specified number of hours to the current game date and then stores the new name into register; set hours to 0 to use the current date |
str_store_troop_name_link | register, troop | Stores the hyperlinked troop name to the info page of the specified troop in register; intended only for info pages, and should be used only for unique troops (lords and heroes) |
str_store_party_name_link | register, party | As above, but for a party; intended only for info pages |
str_store_faction_name_link | register, faction | Stores the hyperlinked faction name that leads to the faction info page of the specified faction in register; intended only for info pages |
str_store_quest_name_link | register, quest | Stores the hyperlinked quest name that leads to the quest info page of the specified quest in register; intended only for info pages. If the quest no longer exists, the hyperlink will still exist but will do nothing when clicked. |
str_store_class_name | register, class | Warband: Unknown. Related to multiplayer? |
str_store_player_username | register, player | Warband: Stores the username of the player on the multiplayer server in register; undefined behaviour in single player mode |
str_store_server_password | register | Warband: Stores the unencrypted raw server password specified when the multiplayer server was created in register; undefined behaviour in single player mode |
str_store_server_name | register | Warband: Stores the name specified when the multiplayer server was created in register; undefined behaviour in single player mode |
str_store_welcome_message | register | Warband: Stores the welcome message specified when the multiplayer server was created in register; undefined behaviour in single player mode |
str_encode_url | register | Warband: Unknown. Stores an HTML-encoded link to the multiplayer server that can be posted online? |
Invalid functions:
str_store_item_name_plural | register, item | Should return the plural name for the item, but there are no plural names for items |
str_store_item_name_by_count | register, item, number | Should intelligently return the plural name for the item based on the number, but there are no plural names for items |