From 281796ceaa29eb41ce67a31bb16b9c454ca3094e Mon Sep 17 00:00:00 2001 From: gurpreetsinghmatharoo Date: Mon, 29 Apr 2024 15:59:12 +0530 Subject: [PATCH] 1 --- .../Assets_And_Tags/asset_get_index.htm | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Manual/contents/GameMaker_Language/GML_Reference/Asset_Management/Assets_And_Tags/asset_get_index.htm b/Manual/contents/GameMaker_Language/GML_Reference/Asset_Management/Assets_And_Tags/asset_get_index.htm index 1bceabe35..a2c2f0fc4 100644 --- a/Manual/contents/GameMaker_Language/GML_Reference/Asset_Management/Assets_And_Tags/asset_get_index.htm +++ b/Manual/contents/GameMaker_Language/GML_Reference/Asset_Management/Assets_And_Tags/asset_get_index.htm @@ -4,9 +4,9 @@ asset_get_index - + - + @@ -15,12 +15,12 @@ -

asset_get_index

+

asset_get_index

This function gets the unique identifying index for a game asset from its name.

-

If the asset is not found, the function will return a value of -1, otherwise it will return the unique index id for the asset being checked. This id can then be used in other functions as you would any other index value, like the sprite_index or the path_index, for example. Please note that although this function can be used to reference assets from strings (see example below), you should always make sure that the asset exists before using it otherwise you may get errors that will crash your game.

+

If the asset is not found, the function will return a value of -1, otherwise it will return the unique index ID for the asset being checked. This ID can then be used in other functions as you would any other index value, like the sprite_index or the path_index, for example. Please note that although this function can be used to reference assets from strings (see example below), you should always make sure that the asset exists before using it otherwise you may get errors that will crash your game.

 

Syntax:

-

asset_get_index(name);

+

asset_get_index(name);

@@ -30,22 +30,24 @@

Syntax:

- +
nameStringString The name of the game asset to get the index of (a string).

 

Returns:

-

Asset (any asset type)

+

Asset (any asset type)

 

Example:

var obj = asset_get_index("obj_Enemy_" + string(global.Level));
- if obj > -1
+
+ if (object_exists(obj))
{
-     instance_create_layer(random(room_width), random(room_height), obj, "Enemy_Layer");
- }

-

The above code will get an object index from a string, and if that index exists, create an instance of the object in the game.

+     instance_create_layer(random(room_width), random(room_height), "Enemy_Layer", obj);
+ } +

+

The above code will get an object asset from a string, and if that asset exists, create an instance of the object in the game.

 

 

-
© Copyright YoYo Games Ltd. 2023 All Rights Reserved
+
© Copyright YoYo Games Ltd. 2024 All Rights Reserved