Nestharus
o-o
- Reaction score
- 83
Someone else wrote this before and we argued that it wouldn't be useful for save/load, but with the above 2 scripts, I figured it would be useful. His was a bit different, including global constants. Mine uses pure locals for more dynamism.
It is better to color using BigInt digits directly, but since EncryptNumber returns a string this is now ok I suppose ;p.
Demo
[ljass]call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,ColorCodeString("1 n N !", "40e0d0", "ff69b4", "00AA00", "ffff00",0))[/ljass]
It is better to color using BigInt digits directly, but since EncryptNumber returns a string this is now ok I suppose ;p.
JASS:
library ColorCodeString
function ColorCodeString takes string s, string numColor, string lowerColor, string upperColor, string specColor, integer start returns string
local string ns = ""
local string c
local integer m = StringLength(s)
local integer i = start
local boolean l
loop
exitwhen m == i
set c = SubString(s,i,i+1)
if (c!=" ") then
set l=StringCase(c,false)==c
//special or number
if (c==StringCase(c,true) and l) then
//number
if ("0"==c or 0!=S2I(c)) then
set ns=ns+"|cff"+numColor+c
//special
else
set ns=ns+"|cff"+specColor+c
endif
//lowercase
elseif (l) then
set ns=ns+"|cff"+lowerColor+c
//uppercase
else
set ns=ns+"|cff"+upperColor+c
endif
else
set ns=ns+" "
endif
set i = i + 1
endloop
return ns
endfunction
endlibrary
Demo
[ljass]call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,ColorCodeString("1 n N !", "40e0d0", "ff69b4", "00AA00", "ffff00",0))[/ljass]