YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
13 stars 5 forks source link

asset_get_name function #2799

Open KormexGit opened 6 months ago

KormexGit commented 6 months ago

Is your feature request related to a problem?

I saw a comment on YoYoGames/GameMaker-Bugs#2808 that mentioned GM not having a asset_get_name() function, and realized I don't think there's a request for that yet, so figured I'd file one. This function wouldn't have been possible before, but with the ref changes, it should be possible now. Combined with the existing asset_get_type, this would streamline things like save systems.

Describe the solution you'd like

Add a new function, asset_get_name. This would function similar to existing functions like object_get_name, sprite_get_name, etc. but it would take any asset type. It would essentially be the true opposite to asset_get_index.

Describe alternatives you've considered

No response

Additional context

No response

backYard321 commented 6 months ago

Definitely! With the addition of YoYoGames/GameMaker-Bugs#2964 (asset_get_ids()), this would eliminate the need for functions like object_get_name(), sprite_get_name(), script_get_name(), etc, in many cases.

WangleLine commented 6 months ago

I agree, it would probably be nicer to deprecate all the specific asset type name fetchy functions and just have one that works for all asset types instead.

Totobal5 commented 6 months ago

yes please depecrate all the other and just make this one the default

FoxyOfJungle commented 5 months ago

I agree with everyone here.

yerumaku commented 4 months ago

At the moment, there is also a problem with getting the asset type - Asset.GMTextureGroup

There is no constant in the collection of constants for the texture group when trying to find out the asset type:

/* Default is Asset.GMTextureGroup */
show_message(asset_get_type("Default") == asset_unknown); // true
zzhamzz commented 2 months ago

Its currently very cumbersome to go from asset_index -> asset name.

You need to check if the asset exist, then what type of asset it is via asset_get_type, then call the appropriate *_get_name function.

This should all be rolled up into a native asset_get_name function.

GameDevTosh commented 2 weeks ago

We definitely need this.