Legacy GM Sprite identifying

zendraw

Member
so i figured the only way to identify a specific sprite in the resourse tree wuld be with sprite_get_name()
but how do i return that string into a real value which then i wuld use to assign that sprite to an object? in the manual is suggested sprite_get_index() but such a function doesnt exist.

is there another way or how can i get the real value from this string?

this is a problem becouse i still add/remove sprites from the resourse trees and the saved maps i use, use the old values.
 

obscene

Member
Just simply sprite_index will return the index.

sprite_index=spr_whatever_you_named_it

asset_get_index will convert a string to an index.
 

zendraw

Member
so sprite_index can be assignet to a string also? never knew that,
edit: ive just tryed it, assignin the sprite to sprite_get_name();
didnt change anything in the loading script, its still sprite_index=spr; and it worked.
 
R

renex

Guest
asset_get_index() will convert an asset name into a resource index. You can also use asset_get_type() to identify the type of resource represented by that name.
 

zendraw

Member
yes, actually it didnt work without converting the string with asset_get_index(); didnt test it throuly
but now ive added it and tested it and it works jsut fine.

so basically
spr=sprite_get_name();//save
spr=asset_get_index(ds_grid_get(grid, x, y, i));//load
 
Top