Warcraft III resources & community, 2003–2006 · archived

ColorStringToColorInteger

not rated
Submitted by PepparConversion0 downloads
Converts the color string cs into a color integer.

Source

function ColorStringToColorInteger takes string cs returns integer
    local string charMapL = "0123456789abcdef"
    local string charMapU = "0123456789ABCDEF"
    local string c
    local integer array cia
    local integer i = 0
    local integer d
    if cs == null or cs == "" then
        return 0
    endif
    loop
        exitwhen i == 8
        set c = SubString(cs, i, i + 1)
        set d = 0
        loop
            exitwhen d == 15 or SubString(charMapL, d, d + 1) == c or SubString(charMapU, d, d + 1) == c
            set d = d + 1
        endloop
        set cia[i] = d
        set i = i + 1
    endloop
    return cia[0] * 0x10000000 + cia[1] * 0x1000000 + cia[2] * 0x10 + cia[3] + cia[4] * 0x1000 + cia[5] * 0x100 + cia[6] * 0x100000 + cia[7] * 0x10000
endfunction

Comments

0

No comments.