summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgumi <mekolat@users.noreply.github.com>2017-05-31 12:12:43 -0400
committergumi <mekolat@users.noreply.github.com>2017-06-01 12:28:00 -0400
commit0f18b10b7702d53e8dac866ffafb31097dbea5cc (patch)
treeb60061f18245a7f62705130722120bb540166e4a /src
parent66101aaf34c55b6928974b78355eea0593de44d2 (diff)
downloadhercules-0f18b10b7702d53e8dac866ffafb31097dbea5cc.tar.gz
hercules-0f18b10b7702d53e8dac866ffafb31097dbea5cc.tar.bz2
hercules-0f18b10b7702d53e8dac866ffafb31097dbea5cc.tar.xz
hercules-0f18b10b7702d53e8dac866ffafb31097dbea5cc.zip
add buildin getarrayindex()
Diffstat (limited to 'src')
-rw-r--r--src/map/script.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c
index f83310187..075b980ca 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -7314,6 +7314,22 @@ int script_array_index_cmp(const void *a, const void *b)
return (*(const unsigned int *)a - *(const unsigned int *)b); // FIXME: Is the unsigned difference really intended here?
}
+BUILDIN(getarrayindex)
+{
+ struct script_data *data = script_getdata(st, 2);
+
+ if (!data_isreference(data) || reference_toconstant(data))
+ {
+ ShowError("script:getarrayindex: not a variable\n");
+ script->reportdata(data);
+ st->state = END;
+ return false;// not a variable
+ }
+
+ script_pushint(st, reference_getindex(data));
+ return true;
+}
+
/// Deletes count or all the elements in an array, from the starting index.
/// ex: deletearray arr[4],2;
///
@@ -23297,6 +23313,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(cleararray,"rvi"),
BUILDIN_DEF(copyarray,"rri"),
BUILDIN_DEF(getarraysize,"r"),
+ BUILDIN_DEF(getarrayindex,"r"),
BUILDIN_DEF(deletearray,"r?"),
BUILDIN_DEF(getelementofarray,"ri"),
BUILDIN_DEF(getitem,"vi?"),