Snippet Color Code String

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.

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]
 

tooltiperror

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

luorax

Invasion in Duskwood
Reaction score
67
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
Reaction score
83
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
Reaction score
231
Color String is a way too generic name. Give it a name with meaning, like [LJASS]ColorSaveLoadCode(String)[/LJASS].
 

Nestharus

o-o
Reaction score
83
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.
  • jonas jonas:
    where did you go?
  • The Helper The Helper:
    Jefferson TX on a Paranormal Investigation of a haunted bed and breakfast - I got some friends that are paranormal investigators and they have an RV and do YouTubes
    +1
  • The Helper The Helper:
    It was a lot of fun. The RV was bad ass
  • jonas jonas:
    That sounds like fun!
    +1
  • The Helper The Helper:
    it was a blast!
  • The Helper The Helper:
    I am going to post the Youtube of the investigation in the forums when it is ready
    +1
  • jonas jonas:
    cool!
  • vypur85 vypur85:
    Sounds cool TH.
  • tom_mai78101 tom_mai78101:
    I was on a Legend of Zelda marathon...
  • tom_mai78101 tom_mai78101:
    Am still doing it now
    +1
  • jonas jonas:
    which one(s) are you playing?
  • jonas jonas:
    I played a little bit of the switch title two weeks ago and found it quite boring
  • The Helper The Helper:
    just got back from San Antonio this weekend had the best Buffalo Chicken Cheesesteak sandwhich in Universal City, TX - place was called Yous Guys freaking awesome! Hope everyone had a fantastic weekend!
    +1
  • The Helper The Helper:
    Happy Tuesday!
  • The Helper The Helper:
    We have been getting crazy numbers reported by the forum of people online the bots are going crazy on us I think it is AI training bots going at it at least that is what it looks like to me.
  • The Helper The Helper:
    Most legit traffic is tracked on multiple Analytics and we have Cloud Flare setup to block a ton of stuff but still there is large amount of bots that seem to escape detection and show up in the user list of the forum. I have been watching this bullshit for a year and still cannot figure it out it is drving me crazy lol.
    +1
  • Ghan Ghan:
    Beep boop
    +1
  • The Helper The Helper:
    hears robot sounds while 250 bots are on the forum lol
  • The Helper The Helper:
    Happy Saturday!
    +1
  • The Helper The Helper:
    and then it was Thursday...
    +2
  • tom_mai78101 tom_mai78101:
    And then Monday
    +1
  • The Helper The Helper:
    I got the day off today!
    +1
  • tom_mai78101 tom_mai78101:
    How...? (T-T)
  • The Helper The Helper:
    I took the day off. I work for myself so I can do that.
    +1
  • Varine Varine:
    Well I'm already over summer

    The Helper Discord

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top