Advertisement
Enstroe

BB_Utility

Jan 24th, 2022
965
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. ------------------------------------------------------
  2. -- # Title : Base Butler - General Utility Functions
  3. ------------------------------------------------------
  4.  
  5. -- Splits a string by a delimiter, defaults to whitespace
  6. function Split(s, delimiter)
  7.     local result = {};
  8.  
  9.     if (delimiter == nil) then -- default to whitespace
  10.         delimiter = " "
  11.     end    
  12.    
  13.     for match in (s..delimiter):gmatch("(.-)"..delimiter) do
  14.         table.insert(result, match);
  15.     end
  16.  
  17.     return result;
  18. end
  19.  
  20.  
  21. -- Returns the count of a table
  22. function Count(table)
  23.     local count = 0
  24.    
  25.     for _ in pairs(table) do
  26.         count = count + 1
  27.     end
  28.    
  29.     return count
  30. end
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement