array::filter()
Returns the elements of an array that a filter function keeps. BO3's decompiled scripts carry no docs for this one: the description is ours, from its name and use.
Signature
array::filter(&array, b_keep_keys, func_filter, arg1, arg2, arg3, arg4, arg5)
Needs #using the script that defines it (scripts/shared/array_shared.gsc).
Parameters
| Name | Details |
|---|---|
| array | (passed by reference: &) |
| b_keep_keys | |
| func_filter | |
| arg1 | |
| arg2 | |
| arg3 | |
| arg4 | |
| arg5 |
The decompiled scripts don't keep default values, so some of these may be optional: check the real uses below.
Real uses in BO3's scripts
Called 102 times in the decompiled scripts. A few, zombies first:
- scripts/zm/_zm_ai_margwa_elemental.gsc, line 2314
pointlist = array::filter(pointlist, 0, &function_794b06f); - scripts/zm/_zm_altbody_beast.gsc, line 760
a_kiosks = array::filter(a_kiosks, 0, &function_b7520b09); - scripts/zm/_zm_elemental_zombies.gsc, line 280
a_filtered_zombies = array::filter(a_zombies, 0, &function_b804eb62); - scripts/zm/_zm_weap_elemental_bow.gsc, line 96
var_852420bf = array::filter(var_852420bf, 0, &function_83f44f5, v_position); - scripts/zm/_zm_weap_elemental_bow_demongate.gsc, line 902
var_237d778f = array::filter(var_237d778f, 0, &zm_weap_elemental_bow::function_5aec3adc);
More in array::
- array::thread_all()Threads a function on every entity in an array, passing the same arguments.
- array::add()Adds an item to an array (no duplicates unless allowed) and returns the array.
- array::random()Returns a random element of an array.
- array::randomize()Returns the array in a random order (shuffled).
- array::run_all()Calls a function on every entity in an array (no thread).
- array::get_all_closest()Returns elements sorted by distance from an origin, optionally capped.
- array::remove_dead()Removes dead entities from an array.
- array::remove_undefined()Removes undefined entries from an array.
- array::contains()True if the array contains a value.
- array::exclude()Returns the array without the items in a second array (or one item).
- array::remove_index()Removes the element at an index and returns the array.
- array::delete_all()Deletes every entity in an array.
New to GSC?
Start with the basics, or paste a compile error to get the fix.
Built-in descriptions, parameters and examples come from Treyarch's BO3 mod tools docs. Usage links point at shiversoftdev/t7-source (decompiled BO3 scripts).