SnippetColor Code String

Nestharus

o-o
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.

JASS:
``````
library ColorCodeString
function ColorCodeString takes string s, string numColor, string lowerColor, string upperColor, string specColor, integer start returns string
local string ns = &quot;&quot;
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!=&quot; &quot;) then
set l=StringCase(c,false)==c

//special or number
if (c==StringCase(c,true) and l) then
//number
if (&quot;0&quot;==c or 0!=S2I(c)) then
set ns=ns+&quot;|cff&quot;+numColor+c
//special
else
set ns=ns+&quot;|cff&quot;+specColor+c
endif
//lowercase
elseif (l) then
set ns=ns+&quot;|cff&quot;+lowerColor+c
//uppercase
else
set ns=ns+&quot;|cff&quot;+upperColor+c
endif
else
set ns=ns+&quot; &quot;
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]

tooltiperror

Super Moderator
No description, no implementation instructions, no demo map. Excellent.

luorax

Invasion in Duskwood
Most likely because it's a simple function.
This is supposed to colorize save codes.

However, I think if I'd have to input "|cff" too, it'd be much more readable (personal opinion). Also, an ARGB version would be also nice.

Nestharus

o-o
Well, I was thinking of renaming it ColorCodeString to apply color coding for the various types of characters = ).

Also, for me, passing in the hex values as strings is more readable.

If you want a hex version, write another function and submit it as its own resource that's like ColorCodeStringHex ; ).

tooltiperror

Super Moderator
Color String is a way too generic name. Give it a name with meaning, like [LJASS]ColorSaveLoadCode(String)[/LJASS].

Nestharus

o-o
I did ColorCodeString, referring to color codes for characters.

I can't change the thread name. I changed the resource name way before you posted what you did ;p.

General chit-chat
Help Users
• No one is chatting at the moment.

Members online

No members online now.