diff options
-rw-r--r-- | src/map/script.c | 17 |
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?"), |