Guest User

ds_list_count GML

a guest
Jun 23rd, 2016
24
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×