reskate.strings changes the game’s own text. The lines the game shows, in its menus and its store, come from ids such as ID_MENU_PLAY; a plugin gives an id a text of its own, and the game shows that text wherever it shows the id. It replaces text the game ships, and adds text for an id the game lacks. Use it for a translation, or for the names your mod’s own items and modes show.
set, set_many, exists and set_case_rules need the strings permission. hash needs none. Calling a function without its permission raises an error.
Ids and keys
A key is one of two things:- an id, such as
"ID_MENU_PLAY": 1 to 255 printable ASCII characters, without spaces, not starting with#; "#"and 1 to 8 hex digits, such as"#1a2b3c4d", for a text known only by its hash. A dump of the game’s text names those strings this way.hash(below) gives an id’s key in this form.
How texts are applied
- A text shows from the next ticks on. ReSkate stores 256 texts a tick, so a whole translation causes no hitch; a long one takes a few ticks to show in full.
- Texts are stored once the game’s text is loaded, and all of them again when the player changes the game’s language.
- When two plugins set the same id, the last to set it shows.
- A plugin holds at most 65,536 texts. Setting an id again replaces your own text and does not count twice.
- When your plugin stops, an id another plugin also set shows that plugin’s text again. Any other id keeps your text until the game restarts: the game’s text store has no way to take one out.
Setting text
reskate.strings.set(key, text)
Shows text wherever the game shows the id’s text.
An id or a
#hash, as above.Why not:
"a plugin sets at most 65536 strings", "the game's text store differs from the supported build", or "unavailable here" on a dedicated server.reskate.strings.set: an id is printable ASCII, without spaces or reskate.strings.set: a text is at most 511 characters (UTF-16 units).
Needs the
strings permission.reskate.strings.set_many(texts)
Sets many texts at once, from a table of keys and texts. Keys that start with _ are left out, so a data file can carry notes.
{[key] = text, ...}. Every key a string, as above; every text a string. At most 65,536 pairs.reskate.strings.set_many: "ID_MENU_PLAY": a text is a string.
Needs the
strings permission.Reading
reskate.strings.exists(key)
Whether the game has text for a key: its own, or a plugin’s already stored.
Needs the
strings permission.reskate.strings.hash(id)
The id’s #hash key: "#" and 8 lowercase hex digits. Use it to match an id to a dump of the game’s text that names strings by hash. It only computes, and needs no permission.
Casing
reskate.strings.set_case_rules(rules)
Some of the game’s text is capitalized by the game itself, such as an upper-case heading. Its own rules know no language, so a Turkish i becomes I. With "tr", i becomes İ (U+0130) in upper case, and I becomes ı (U+0131) in lower case, the rules of Turkish and Azerbaijani.
Why not:
"the game's text casing differs from the supported build", or "unavailable here" on a dedicated server."", or your plugin stopping, gives up only your own request. Any other value raises an error.
Needs the
strings permission.