[script] hue player color

[script] hue player color

Postby bonifarz » 11 Dec 2013, 15:32

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 107 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.
Last edited by bonifarz on 12 Dec 2013, 08:53, edited 1 time in total.
User avatar
bonifarz
 
Posts: 379
Joined: 09 Apr 2012, 12:16
Location: switzerland

Re: [script] hue player color

Postby Calinou » 11 Dec 2013, 21:45

Warning: quin may kick your ass if he sees you with a script like that. It's a waste of bandwidth.
User avatar
Calinou
 
Posts: 164
Joined: 22 Jan 2010, 21:43
Location: France

Re: [script] hue player color

Postby qreeves » 12 Dec 2013, 03:01

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.
Quinton "quin" Reeves | Lead Developer, Red Eclipse | http://redeclipse.net/ | http://www.facebook.com/redeclipse.net
User avatar
qreeves
 
Posts: 1292
Joined: 17 Mar 2011, 03:46
Location: Queensland, Australia

Re: [script] hue player color

Postby bonifarz » 12 Dec 2013, 08:48

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?).
User avatar
bonifarz
 
Posts: 379
Joined: 09 Apr 2012, 12:16
Location: switzerland

Who is online

Users browsing this forum: No registered users and 1 guest