Advertisement
visiongaming43

colorLib

Jun 11th, 2022
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. ACCEPTABLE_COLORS = {
  2. "colors.white",
  3. "colors.orange",
  4. "colors.magenta",
  5. "colors.lightBlue",
  6. "colors.yellow",
  7. "colors.lime",
  8. "colors.pink",
  9. "colors.gray",
  10. "colors.lightGray",
  11. "colors.cyan",
  12. "colors.purple",
  13. "colors.blue",
  14. "colors.brown",
  15. "colors.green",
  16. "colors.red",
  17. "colors.black"
  18. }
  19.  
  20. local expect = require("cc.expect")
  21. local exp, field, range = expect.expect, expect.field, expect.range
  22.  
  23. function printColor(text, color)
  24. exp(1, text, "string")
  25. exp(1, color, "string")
  26. for index, value in ipairs(ACCEPTABLE_COLORS) do
  27. if (color == value) then break end
  28. if (color ~= value and index == #ACCEPTABLE_COLORS) then
  29. print(text)
  30. end
  31. end
  32. term.setTextColor(color)
  33. print(text)
  34. term.setTextColor("colors.white")
  35. end
  36.  
  37. return { printColor = printColor }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement