summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmistry <Equinox1991@gmail.com>2015-09-06 19:40:03 +0800
committerHaru <haru@dotalux.com>2015-12-20 20:44:27 +0100
commit6a0093b170719092e6c0f11b889353cd70b38313 (patch)
treecf02d7d61916414c4450c64a07e0616162c21bc8
parent851e97a20701bf2800491690838f654a9a6638e6 (diff)
downloadhercules-6a0093b170719092e6c0f11b889353cd70b38313.tar.gz
hercules-6a0093b170719092e6c0f11b889353cd70b38313.tar.bz2
hercules-6a0093b170719092e6c0f11b889353cd70b38313.tar.xz
hercules-6a0093b170719092e6c0f11b889353cd70b38313.zip
*explode return array size.
http://herc.ws/board/topic/7489-explode-to-push-arraysize/ Closes #700 as merged Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r--doc/script_commands.txt6
-rw-r--r--src/map/script.c2
2 files changed, 6 insertions, 2 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 2dd4fa575..852a003b7 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -8007,17 +8007,19 @@ Breaks a string up into substrings based on the specified delimiter.
Substrings will be stored within the specified string array. Only the 1st
char of the delimiter parameter will be used. If an empty string is passed
as a delimiter, the string will be placed in the array in its original
-form, without any changes.
+form, without any changes. Return the number of elements written to
+<dest_array>.
Example:
- explode(.@my_array$, "Explode:Test:1965:red:PIE", ":");
+ .@num_elements = explode(.@my_array$, "Explode:Test:1965:red:PIE", ":");
//.@my_array$ contents will be...
//.@my_array$[0]: "Explode"
//.@my_array$[1]: "Test"
//.@my_array$[2]: "1965"
//.@my_array$[3]: "red"
//.@my_array$[4]: "PIE"
+ //.@num_elements: 5
---------------------------------------
diff --git a/src/map/script.c b/src/map/script.c
index f438de3ab..fedfc895c 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -14967,6 +14967,8 @@ BUILDIN(explode)
script->set_reg(st, sd, reference_uid(id, start + k), name, (void*)temp, reference_getref(data));
aFree(temp);
+
+ script_pushint(st, k + 1);
return true;
}