SHARE
TWEET

Untitled

a guest May 20th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function handleColors(text, processColor)
  2.     local Process = {
  3.         None = 0,
  4.         Colors = 1,
  5.         Strip = 2,
  6.     }
  7.     if (processColor == Process.None) then return text end
  8.     local colors = {
  9.         ["{D"] = "\\e[30;1m", ["{R"] = "\\e[31;1m", ["{G"] = "\\e[32;1m", ["{Y"] = "\\e[33;1m",
  10.         ["{B"] = "\\e[34;1m", ["{M"] = "\\e[35;1m", ["{C"] = "\\e[36;1m", ["{W"] = "\\e[37;1m",
  11.         ["{d"] = "\\e[30m", ["{r"] = "\\e[31m", ["{g"] = "\\e[32m", ["{y"] = "\\e[33m",
  12.         ["{b"] = "\\e[34m", ["{m"] = "\\e[35m", ["{c"] = "\\e[36m", ["{w"] = "\\e[37m",
  13.         ["{x"] = "\\e[0m",
  14.     }
  15.     local colorKeys = {}
  16.     for k,v in pairs(colors) do
  17.         table.insert(colorKeys,k)
  18.         if (processColor == Process.Colors) then
  19.             text = text:gsub(k,v)
  20.         elseif (processColor == Process.Strip) then
  21.             text = text:gsub(k,"")
  22.         end
  23.     end
  24.     while (text:match("{?")) do
  25.         if (processColor == Process.Colors) then
  26.             text = text:gsub("{?",colorKeys[math.random[#colorKeys]],1)
  27.         elseif (processColor == Process.Strip) then
  28.             text = text:gsub("{?","")
  29.         end
  30.     end
  31.     text = text:gsub("{|","{")
  32.     return text
  33. end
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
 
Top