tag_get_asset_ids

With this function you can get all the assets of a given type that have the given tags assigned to them. You supply either a single tag (as a string) or an array, where each item in the array is a tag (as a string), as well as the type of asset to check. the type of asset should be one of the following constants:

 

Constant Description
asset_object The given name refers to an object.
asset_sprite The given name refers to a sprite.
asset_sound The given name refers to a sound.
asset_room The given name refers to a room.
asset_tiles The given name refers to a tile set.
asset_path The given name refers to a path.
asset_script The given name refers to a script.
asset_font The given name refers to a font.
asset_timeline The given name refers to a time line.
asset_shader The given name refers to a shader.
asset_animationcurve The given name refers to an Animation Curve.
asset_sequence The given name refers to a Sequence.

 

The function will return an array, where each item in the array will be a single asset index value. If there are no assets of the type that have the given tag(s), an empty array will be returned.

 

Syntax:

tag_get_asset_ids(tags, asset_type);

Argument Description
tags A single asset tag string or an array with various asset tags.
asset_type An asset type constant (listed above)

 

Returns:

Array

 

Example:

var _paths = tag_get_asset_ids("enemy", asset_path);
var _num = irandom(array_length(_paths) - 1);
path_start(_paths[_num], 1, path_action_reverse, false);

The above code uses the tag "enemy" to find all the path assets with that tag, before choosing one at random and assigning it to the instance running the code.