vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- String related routines |
2 | -- |
||
3 | |||
4 | function Gatherer_split(str, sep) |
||
5 | -- type: (Text, Text) -> List[Text] |
||
6 | -- This *wonderful* language has no split function. |
||
7 | -- And this *wonderful* lua implementation has neither match nor gmatch. |
||
8 | local sep, fields = sep or ",", {} |
||
9 | local pattern = string.format("([^%s]+)", sep) |
||
10 | gsub(str, pattern, function(c) tinsert(fields, c) end) |
||
11 | return fields |
||
12 | end |
||
13 | |||
14 | |||
15 | local function hexColor(color) |
||
16 | -- type: (Color) -> HexColor |
||
17 | local hexColor = {}; |
||
18 | for _, component in color do |
||
19 | tinsert(hexColor, format('%x', component)) |
||
20 | end |
||
21 | return table.concat(hexColor) |
||
22 | end |
||
23 | |||
24 | |||
25 | function Gatherer_coloredText(str, color) |
||
26 | return '|cff'..hexColor(color)..str..'|r' |
||
27 | end |