Page 1 of 1

[script] hue player color

PostPosted: 11 Dec 2013, 15:32
by bonifarz
Time to share another pretty useless script, which may be fun to use for some players out there offline.
A few times I have seen people with flickering player colors, not necessarily pleasant to the eye, maybe even annoying, but somehow an interesting idea.
So I experimented with a simple script that alters the player color using a smooth transition of fully saturated colors over the hue spectrum. I think I posted part of it earlier.

{l Code}: {l Select All Code}
// hue color scripts by bonifarz (@gmx.ch) - cc-by-sa

colorbak = $playercolour
huestep = 16   // Larger step sizes give faster but coarser color transitions.
huetime = 500  // Update interval in ms. Avoid spamishly small values.
h256 = 0       // initial hue fraction in [0:255]
h6 = 0         // initial hue segment  in [0:5]

enablehue = [
    echo "Hue player colors enabled. Note the variables /colorstep and /colortime."
    echo "Use /disablehue to restore your previous player color."
    colorbak = $playercolour
    iteratehue
]
setcomplete "enablehue" 1

disablehue = [
    clearsleep
    playercolour $colorbak
    echo "Hue player colors disabled."
]
setcomplete "disablehue" 1

iteratehue = [
    h256 = (+ $h256 $huestep)
    if (> $h256 255 ) [
        h256 = (- $h256 256)
        h6 = (+ $h6 1)
        if (> $h6 5) [
            h6 = (- $h6 6)
        ]
    ]
    playercolour (colorfromhue $h6 $h256)
    sleep $huetime [ iteratehue ]
]

colorfromhue = [ 
    // returns a saturated color for a given hue = $arg1*60° + $arg2/255*60°
    hi = $arg2
    hd = (- 255 $hi)
    case $arg1 0 [ // red to yellow
        result (+ 0xff0000 (* $hi 0x000100))
    ] 1 [          // yellow to green
        result (+ 0x00ff00 (* $hd 0x010000))
    ] 2 [          // green to cyan
        result (+ 0x00ff00 (* $hi 0x000001))
    ] 3 [          // cyan to blue
        result (+ 0x0000ff (* $hd 0x000100))
    ] 4 [          // blue to magenta
        result (+ 0x0000ff (* $hi 0x010000))
    ] 5 [          // magenta to red
        result (+ 0xff0000 (* $hd 0x000001))
    ]
]
huecolors.cfg
Same as above codebox
(1.62 KiB) Downloaded 343 times
After executing the script, you can turn it on and off using /enablehue and /disablehue, respectively. The time for a full color cycle is 6*255*huetime/huestep or about 48s for the default values. I don't really know how much this messes with traffic and server load, but a refresh time of half a second should be negligible.

Re: [script] hue player color

PostPosted: 11 Dec 2013, 21:45
by Calinou
Warning: quin may kick your ass if he sees you with a script like that. It's a waste of bandwidth.

Re: [script] hue player color

PostPosted: 12 Dec 2013, 03:01
by qreeves
Calinou {l Wrote}:Warning: quin may kick your ass if he sees you with a script like that. It's a waste of bandwidth.

Not to mention, annoying, as the OP recognises, haha. This script won't work with SVN servers either, setinfo is now rate-limited.

Re: [script] hue player color

PostPosted: 12 Dec 2013, 08:48
by bonifarz
I had no bad intentions here, and yes, I do consider flickering color an annoying waste. Thus the server side limit on SVN is very reasonable ( - still lacking a message string?).