GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2020-04-30 09:29:57

Juju
Member
Registered: 2015-10-01
Posts: 44

tag_get_instance_ids

As a response to the request on the 2.3.0 Beta forum:

Expand/// @function tag_get_instance_ids(tags, includeChildren)
/// 
/// @param tags             Single asset tag string, or an array with various asset tags
/// @param includeChildren  Include children of objects with a tag
/// 
/// @return An array of all the instances that have the given tags assigned to their object asset

function tag_get_instance_ids(_tags, _include_children)
{
    var _array = [];
    var _count = 0;
    
    var _asset_ids = tag_get_asset_ids(_tags, asset_object);
    var _i = 0;
    repeat(array_length(_asset_ids))
    {
        var _object = _asset_ids[_i];
        with(_object)
        {
            //Skip children of tagged objects
            if ((object_index != _object) && !_include_children) continue;
            
            _array[_count] = id;
            ++_count;
        }
        
        ++_i;
    }
    
    return _array;
}

Offline

Board footer

Powered by FluxBB