ds_exists

Check to see if a data structure of a given type exists.

Syntax:

ds_exists(ind, type);


ArgumentDescription
ind The variable index to check for the data structure
type The type of data structure to check for (see the list of constants below)


Returns: Boolean


Description

With this function you can check to see if a data structure of the given type exists. You supply the "index" value (as held in a variable) and the ds "type", which can be any of the constants listed below, and the function will return true if the data structure exists and false otherwise.

ConstantDescription
ds_type_mapA map data structure
ds_type_listA list data structure
ds_type_stackA stack data structure
ds_type_gridA grid data structure
ds_type_queueA queue data structure
ds_type_priorityA priority data structure


Example:

if !ds_exists(ai_grid, ds_type_grid)
   {
   ai_grid = ds_grid_create(room_width / 32, room_height / 32);
   }

The above code checks the (previously initialised) variable "ai_grid" to see if it indexes a ds_grid type data structure, and if it does not then it creates one and stores its index in the variable.


Back: Data Structures
Next: ds_set_precision

© Copyright YoYo Games Ltd. 2018 All Rights Reserved