diff options
author | Ridley <ridley8819@gmail.com> | 2017-02-26 00:31:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-26 00:31:18 +0100 |
commit | 9a7a165d4dbad598907d3ecd54196e8f76c4f3f5 (patch) | |
tree | d4540b804d94d3338b90b3f44097721861fb13c9 /src | |
parent | abb3bc63cb48c7d8bd378bbe3e1c68da0f18d613 (diff) | |
parent | bde8199e4b83d838d560c3fa7bb66cde45d7ad90 (diff) | |
download | hercules-9a7a165d4dbad598907d3ecd54196e8f76c4f3f5.tar.gz hercules-9a7a165d4dbad598907d3ecd54196e8f76c4f3f5.tar.bz2 hercules-9a7a165d4dbad598907d3ecd54196e8f76c4f3f5.tar.xz hercules-9a7a165d4dbad598907d3ecd54196e8f76c4f3f5.zip |
Merge pull request #1588 from mekolat/chr2
add ascii manipulation buildins
Diffstat (limited to 'src')
-rw-r--r-- | src/map/script.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/map/script.c b/src/map/script.c index 38931bd11..ef63697a7 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -5197,7 +5197,7 @@ int script_load_translation(const char *file, uint8 lang_id) VECTOR_TRUNCATE(msgstr); continue; } - + if (strncasecmp(line, "msgid \"", 7) == 0) { VECTOR_TRUNCATE(msgid); for (i = 7; i < len - 2; i++) { @@ -15455,6 +15455,29 @@ BUILDIN(charat) { } //======================================================= +// chr <int> +//------------------------------------------------------- +BUILDIN(chr) +{ + char output[2]; + output[0] = script_getnum(st, 2); + output[1] = '\0'; + + script_pushstrcopy(st, output); + return true; +} + +//======================================================= +// ord <chr> +//------------------------------------------------------- +BUILDIN(ord) +{ + const char *chr = script_getstr(st, 2); + script_pushint(st, *chr); + return true; +} + +//======================================================= // setchar <string>, <char>, <index> //------------------------------------------------------- BUILDIN(setchar) @@ -21075,6 +21098,8 @@ void script_parse_builtin(void) { BUILDIN_DEF(getstrlen,"s"), //strlen [Valaris] BUILDIN_DEF(charisalpha,"si"), //isalpha [Valaris] BUILDIN_DEF(charat,"si"), + BUILDIN_DEF(chr,"i"), + BUILDIN_DEF(ord,"s"), BUILDIN_DEF(setchar,"ssi"), BUILDIN_DEF(insertchar,"ssi"), BUILDIN_DEF(delchar,"si"), |