SHARE
TWEET

ds_list_count GML

a guest Jun 23rd, 2016 7 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///ds_list_count(list,value)
  2. /*
  3. Returns the amount of times the provided value is inside a list
  4. */
  5.  
  6. //Import all passthroughs
  7. var List     = argument0;    //The list to check
  8. var CheckVal = argument1;    //The entry we're counting
  9.  
  10. var Count    = 0;            //How many times it appears (0 by default)
  11. var i        = 0;            //Current loop position in the list
  12.  
  13. //Check every entry in the entire list
  14. repeat ds_list_size(List)
  15.     {
  16.     //Find an entry in the list
  17.     var Entry = ds_list_find_value(List,i);
  18.    
  19.     //Is it the same as the one we're looking for?
  20.     if string(Entry) == string(CheckVal)
  21.         {
  22.         //Yes, increase count
  23.         Count++;
  24.         }
  25.    
  26.     //Move to next position
  27.     i++
  28.     }
  29.  
  30. //Return findings
  31. return Count
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top