instance_select_by_order(obj_or_instance_or_array_of_them, condition_string, condition_value, [numb_add]);
||The instances, objects, or combination of them|
||The condition for testing. The posible values can be:|
||The value to compare against the instance order|
||The number to add before comparing the instance order with the condition|
array) The array with the instances
This will return an array of instances filtered by the specified condition given by the number of the instance inside the array.
For more info about
obj_or_instance_or_array_of_them argument check
The internal process of selection is the following:
- First, all instances of obj_or_instance_or_array_of_them are
selected and numbered from
nis the number of total instances)
- Then, each instance number is compared using the
- If the condition_string can be
numb_addparameter is added to the number of the instance and then, compared using the condition and value.
- Then, an array containing all the matched instances is returned.
If you want to select all odd instances of the
obj_box in the room (numbered from the top to the bottom):
var arr = instance_select_sort( obj_box, set_y); arr = instance_select_numb( arr, "!mod", 2);
It is the same that saying all instances which
(n mod 2) != 0
You can also use
"%!" for the same result.
Suppose that you want to select obj_box the instances which
number (sorted from left to right in the room) is 1, 4, 7, 10, etc.
That is the same that all instances which
(n mod 3) + 1 == 0
So, the formula will be:
(n mod condition_value)+numb_add == 0
Then, you need to call:
var arr = instance_select_sort( obj_box, set_x); arr = instance_select_by_order( arr, "mod", 3, 1);
The last Example: if you want to select the firsts 16 obj_tree instances sorted from right to left
var arr = instance_select_sort( obj_tree, set_x, false); arr = instance_select_by_order( arr, "<", 16);
This will return an array with ALL the ids of the instances of the
obj_tree which number is below 16. (remember that the numbers starts from zero)