Return a list of assets

H

HGCD

Guest
Hey,
I've been trying to find a way to return a list of asset ids or strings for years now, I was wondering if anyone found a way to do this =)

I want to be able to create a system for making tools where I can get a list of all assets, filter them by type and then filter them by name, so I can make tools that auto-generate sprites that fit a certain naming convention (eg. 'spr_spellIcon_X')
I've scoured the manual pretty extensively and haven't found anything, is this just not something the engine can do?

Thanks =)
 

Arvel

Member
You can always go the classic route by turning off sandboxing and actually access those files and manipulate them manually.
 

obscene

Member
Here's a little excerpt from a console I made. Hopefully I didn't leave out anything pertinent. Among other features, typing "list sprites", "list objects", "list scripts" etc will fill a string into the variable return_message you can draw to screen.

Code:
if keyboard_check_pressed(vk_enter)
    {
    // Get string
    var str=keyboard_string;
  
    // Clear string and add to console
    keyboard_string="";

    // Default return message
    var return_message="-> OK";
    }
Code:
        switch (str)
            {         
            case "list sounds":
            return_message="-> Listing sounds...";
            var s=0;
            while (audio_exists(s))
                {
                return_message=string_insert("\n " + string(s) + " " +audio_get_name(s),return_message,string_length(return_message)+1);
                s+=1;
                }
            break;      
          
            case "list sprites":
            return_message="-> Listing sprites...";
            var s=0;
            while (sprite_exists(s))
                {
                return_message=string_insert("\n " + string(s) + " " +sprite_get_name(s),return_message,string_length(return_message)+1);
                s+=1;
                }
            break;              
          
            case "list objects":
            return_message="-> Listing objects...";
            var o=0;
            while (object_exists(o))
                {
                return_message=string_insert("\n " + string(o) + " " + object_get_name(o),return_message,string_length(return_message)+1);
                o+=1;
                }
            break;          
          
            case "list rooms":
            return_message="-> Listing rooms...";
            var r=0;
            while (room_exists(r))
                {
                return_message=string_insert("\n " + string(r) + " " + room_get_name(r),return_message,string_length(return_message)+1);
                r+=1;
                }
            break;
          
            case "list scripts":
            return_message="-> Listing scripts...";
            var s=0;
            while (script_exists(s))
                {
                return_message=string_insert("\n " + string(s) + " " + script_get_name(s),return_message,string_length(return_message)+1);
                s+=1;
                }
            break;  
            }
 
H

HGCD

Guest
Oh man, for some reason I was thinking that all assets were indexed together, I forgot it's per type. Thanks Obcene, totally solves my issue, appreciate the detailed response =)
 
Top