RedKnight91

ds_count

Sep 28th, 2019
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. ///@func ds_count(ds_type, ds_type, ...)
  2. ///@desc Counts the number of data structures of a given type and prints them to the Output console.
  3. /// You can specify more types at once
  4. /// Possible types: ds_type_map, ds_type_list, ds_type_stack, ds_type_queue, ds_type_grid, ds_type_priority
  5. ///
  6. ///@param ds_type1,
  7. ///@param ds_type2,
  8. ///@param ...
  9.  
  10. var _names = ["none", "ds_maps", "ds_lists", "ds_stacks", "ds_queues", "ds_grids", "ds_priorities"];
  11.  
  12. var _type, _i, _j, _count, _limit = 500, _result_str = "Found ";
  13.  
  14. //Get all required ds types to look for
  15. for (_i = 0; _i < argument_count; _i++)
  16. {
  17. _type = argument[_i];
  18. _count = 0;
  19.  
  20. //Iterate indices and try to find data structures
  21. //Carry on research if a ds_list was found at this index
  22. for (var _j = 0; _j < _count + _limit; _j++)
  23. _count += ds_exists(_j, _type);
  24.  
  25. _result_str += string(_names[_type]) + ": " + string(_count) + ", ";
  26. }
  27.  
  28. show_debug_message(_result_str);
Advertisement
Add Comment
Please, Sign In to add comment