In epScript almost every Python 3 builtin is available with a py_ prefix - py_len, py_list, py_set, py_map, py_enumerate, py_range, py_str - and two of them are worth singling out.
| py_print(...) | Prints to the build log. It says nothing about the map and everything about what the compiler decided - compile-time debugging is essentially this one function. |
|---|---|
| py_open(경로, 모드) | Opens a file at compile time and hands back a Python file object. |
function onPluginStart() {
MPQAddWave("1.wav", py_open("C:/1.wav", "rb").read());
}| GetPlayerInfo(플레이어) | The map's own settings for that player - type, race, force. Map data, not runtime state. |
|---|---|
| UnitProperty(...) · GetPropertyIndex(p) | Builds a Create Unit with Properties record from script and gives you its number. |
| SCMD2Text(글자) | Turns ScmDraft's <03> escapes into the real control bytes, so editor text pastes in unchanged. |
| GetEUDNamespace() | The dictionary of everything registered with EUDRegisterObjectToNamespace - how a plugin and your script find each other. |
And of the name-to-index encoders $L, $S, $U and $T, only $T has a side effect.
$T is get-or-create: it returns the id when the text is already in the map string table and inserts a new entry when it is not. $T("Force 1") returns an existing id; a new phrase creates one. Repeating the same literal is free, but every distinct literal costs an STR entry - which is where “the map stopped compiling after I added more text” comes from.
Finally, when a dword you read often holds several packed values, you can generate your own reader. posread_epd is not a special function - it is made this way.
const posread_epd = readgen_epd(
0x1FFF1FFF, // 달라질 수 있는 비트 / the bits that can differ
list(0, py_eval('lambda x: x if x < 65536 else 0')),
list(0, py_eval('lambda y: y // 65536 if y >= 65536 else 0')),
);
const x, y = posread_epd(epd);For moving a block there is repmovsd_epd(dst, src, dwordCount), which beats a loop of reads and writes.
One data block instead of six arraysFinding what is making the map lag