Description

This script was tested and works on OpenSim version 0.7.4!

This is a small script which changes the color of all the primitives in a linkset depending on the mood expressed by smileys on the main chat. This might be a feature you want in objects such as wings or haloos and similar apparel. To use this script, drop it in an object and then type one of the smileys in the list below:

list emotions = [ ":|", ":/", "-.-", ">:(", "~.~", ":(", ":D", "T.T", "Y.Y" ];

in the local chat.

For example, if you were to type a sentence in the main chat: i am jealous! ~.~, then all the primitives this script is in will be changed to green. You can always modify the "emotions" list above to change the smileys to the ones you use most. Here are the mappings:

white -> first smiley in the emotions list
grey -> second smiley in the emotions list
black -> third smiley in the emotions list 
red -> ...
green -> ...
blue -> ...
yellow -> ...
cyan -> ...
magenta -> last smiley in the emotions list

Code

mood_color_changer.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
// ------------------- CONFIGURATION ------------------ //
// The list of colors, must have the same number of
// colors as the emotions list below. If multiple 
// smileys map to to the same color, just add the same
// color again to this list.
list colorV = [ <1, 1, 1>, <.5, .5, .5>, <.0, .0, .0>, <1, .0, .0>, <.0, 1, .0>, <.0, .0, 1>, <1, 1, .0>, <.0, 1, 1>, <1, .0, 1> ];
// The list of emotions, must have the same number of 
// emotions as the list of colors above. You can add as
// many emotions as you like based on what smileys you use
list emotions = [ ":|", ":/", "-.-", ">:(", "~.~", ":(", ":D", "T.T", "Y.Y" ];
 
//////////////////////////////////////////////////////////
// --------------------- INTERNALS -------------------- //
integer comHandle = 0;
 
init() {
    comHandle = llListen(0, "", llGetOwner(), "");
}
 
default
{
    state_entry() {
        init();
    }
 
    on_rez(integer num) {
        init();
    }
 
    listen(integer chan, string name, key id, string mes) {
        list text = llParseString2List(mes, [" "], [""]);
        integer itra;
        for(itra=0; itra<llGetListLength(text); ++itra) {
            if(~llListFindList(emotions, (list)llList2String(text, itra))) {
                comHandle = llListFindList(emotions, (list)llList2String(text, itra));
                jump found;
            }
        }
        return;
@found;
        for(itra=0; itra<=llGetNumberOfPrims(); ++itra) {
            float alpha = llList2Float(llGetLinkPrimitiveParams(itra, [PRIM_COLOR, ALL_SIDES]), 1);
            llSetLinkPrimitiveParamsFast(itra, [PRIM_COLOR, ALL_SIDES, llList2Vector(colorV, comHandle), alpha]);
        }
    }
}