forked from wiredbrother/BetaBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolor.lua
More file actions
39 lines (39 loc) · 949 Bytes
/
color.lua
File metadata and controls
39 lines (39 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
local cTable = {
_r = "white",
_0 = "black",
_1 = "dark_blue",
_2 = "dark_green",
_3 = "dark_aqua",
_4 = "dark_red",
_5 = "dark_purple",
_6 = "gold",
_7 = "gray",
_8 = "dark_gray",
_9 = "blue",
_a = "green",
_b = "aqua",
_c = "red",
_d = "light_purple",
_e = "yellow",
_f = "white"
}
format = function(sText)
local seperated = {}
sText = "&r"..sText
for k in string.gmatch(sText, "[^&]+") do
seperated[#seperated+1] = {"_"..string.sub(k, 1, 1), string.sub(k, 2)}
end
local outText = '["",'
local prev
for k, v in pairs(seperated) do
local color = cTable[v[1]] or prev
outText = outText..'{"text":"'..v[2]..'","color":"'..color..'"'
if v[1] == "_g" then
outText = outText..',"clickEvent":{"action":"run_command","value":"'..v[2]..'"}'
end
outText = outText..'},'
prev = color
end
outText = string.sub(outText, 1, -2)..']'
return outText
end