Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function handleColors(text, processColor)
- local Process = {
- None = 0,
- Colors = 1,
- Strip = 2,
- }
- if (processColor == Process.None) then return text end
- local colors = {
- ["{D"] = "\\e[30;1m", ["{R"] = "\\e[31;1m", ["{G"] = "\\e[32;1m", ["{Y"] = "\\e[33;1m",
- ["{B"] = "\\e[34;1m", ["{M"] = "\\e[35;1m", ["{C"] = "\\e[36;1m", ["{W"] = "\\e[37;1m",
- ["{d"] = "\\e[30m", ["{r"] = "\\e[31m", ["{g"] = "\\e[32m", ["{y"] = "\\e[33m",
- ["{b"] = "\\e[34m", ["{m"] = "\\e[35m", ["{c"] = "\\e[36m", ["{w"] = "\\e[37m",
- ["{x"] = "\\e[0m",
- }
- local colorKeys = {}
- for k,v in pairs(colors) do
- table.insert(colorKeys,k)
- if (processColor == Process.Colors) then
- text = text:gsub(k,v)
- elseif (processColor == Process.Strip) then
- text = text:gsub(k,"")
- end
- end
- while (text:match("{?")) do
- if (processColor == Process.Colors) then
- text = text:gsub("{?",colorKeys[math.random[#colorKeys]],1)
- elseif (processColor == Process.Strip) then
- text = text:gsub("{?","")
- end
- end
- text = text:gsub("{|","{")
- return text
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement