-
Notifications
You must be signed in to change notification settings - Fork 27
Strings
Strings are written like in Python: "string \"with quotes\""
.
To concatenate strings, the .format()
function must be used with {}
or {number}
placeholders, such as "You have {} money and {} damage %".format(eventPlayer.money, eventPlayer.damagePercent)
.
Successive strings are concatenated: "string1""string2"
will resolve to "string1string2"
. This is useful for macros like "Version: " MY_GAMEMODE_VERSION
.
The escape sequence \n is supported within strings. Strings are also multiline by default (no need for triple quotes), therefore a literal newline within a string will be compiled as a \n.
The escape sequences \xHH
(byte escape) and \uHHHH
(unicode escape) are also supported, where H
is an hexadecimal digit. For example, "\u3000"
will output a fullwidth space.
String entities, using the escape sequence \&
, can also be used to not have to look up unicode characters: "\&black_square;"
is the same as "■"
.
The escape sequences \t
, \r
, and \z
map respectively to a tab, a carriage return, and a zero-width space (U+200B).
String modifiers are placed just before the string, such as w"fullwidth string"
. There are currently 5 string modifiers:
- The
l
string modifier specifies a localized string (String
function in the workshop). Localized strings are not recommended as they are limited to a specific subset of predefined strings. They are only included for legacy gamemodes. - The
w
string modifier makes the string fullwidth. - The
b
string modifier forces, when possible, the use of the "big letters" font (Blizzard Global font). - The
p
string modifier makes the string plaintext, to prevent any modification of this string (such as the modification done by obfuscation). Use this modifier if you are comparing the string to an object casted to string (such asp"Zezombye" == "{0}".format(hostPlayer)
). - The
c
string modifier makes the string case-sensitive, using special latin characters that are not uppercased. It however shows diacritics above most letters, and only works with the latin alphabet.
Custom strings in workshop are limited to 128 characters. OverPy automatically splits a string if it is more than 128 characters. However, a string length cannot be more than 511 bytes (with UTF-8 encoding), even with concatenation.
Strings are also limited to 3 placeholders. OverPy automatically splits the string so that each placeholder is resolved. Therefore, you can use more than 3 different placeholders in one string.
OverPy:
- Overview
- General Usage
- General Syntax
- Rules and Events
- Functions
- Control Flow
- Strings
- Compiler Options
- Custom game settings
- Preprocessing
- Advanced Constructs
Various stuff:
Development:
- [Coming soon]