Miki_Tellurium

luautils

Nov 8th, 2025 (edited)
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | Gaming | 0 0
  1. --- Simple utils to assist Lua programming v1.0
  2. luautils = {}
  3.  
  4. -- Print text whit custom color
  5. function luautils.printColored(text, color)
  6.     local ogColor = term.getTextColor()
  7.     if color then
  8.         term.setTextColor(color)
  9.     end
  10.     print(text)
  11.     term.setTextColor(ogColor)
  12. end
  13.  
  14. --- Return true if the table contains the specified key
  15. function luautils.containsKey(tbl, key)
  16.     for k, _ in pairs(tbl) do
  17.         if k == key then
  18.             return true
  19.         end
  20.     end
  21.     return false
  22. end
  23.  
  24. --- Return true if the table contains the specified value
  25. function luautils.containsValue(tbl, value)
  26.     for _, v in pairs(tbl) do
  27.         if v == value then
  28.             return true
  29.         end
  30.     end
  31.     return false
  32. end
Advertisement
Add Comment
Please, Sign In to add comment