此函数的工作方式与函数 script_execute 类似,但允许您以 数组 的形式传递函数 / 脚本所需的参数。
您还可以向函数传递两个可选参数,以指定要从中获取参数的数组的偏移量,以及要从数组中使用的参数数量 (这必须是 array_length - 偏移量的最大值)。
script_execute_ext(scr, [array_args], [offset], [num_args]);
参数 | 类型 | 描述 |
---|---|---|
scr | Script Asset or Script Function | 要调用的函数/脚本 |
array_args | Array | 可选 包含函数 / 脚本参数的数组。如果函数 / 脚本不带参数,则可以省略。 |
[offset] | Real | 可选 参数数组的偏移量 |
[num_args] | Real | 可选 要使用的参数数(从偏移量开始) |
Any (Will depend on the return value from the function/script being called)
script_execute_ext(move_inst, move_array, floor(random(4)), 1);
上面的示例代码将使用 script_execute_ext 调用给定函数,提供四个参数的数组,但随机仅使用其中一个参数。