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"] = "\027[30;1m", ["{R"] = "\027[31;1m", ["{G"] = "\027[32;1m", ["{Y"] = "\027[33;1m",
- ["{B"] = "\027[34;1m", ["{M"] = "\027[35;1m", ["{C"] = "\027[36;1m", ["{W"] = "\027[37;1m",
- ["{d"] = "\027[30m", ["{r"] = "\027[31m", ["{g"] = "\027[32m", ["{y"] = "\027[33m",
- ["{b"] = "\027[34m", ["{m"] = "\027[35m", ["{c"] = "\027[36m", ["{w"] = "\027[37m",
- ["{x"] = "\027[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