Smile

From Second Life Wiki
Jump to: navigation, search

Created by Kira Komarov.

I met Kaitlyn Starflare a moment ago and she asked me to create a script and provide an alternate version to the "Be happy" script which would make it more efficient and would also alternate between two subtle smiles. The script is expandable to potentially include more smiles, however this version works with the built in animations "express_smile" and "express_toothsmile".

//////////////////////////////////////////////////////////
// [K] Kira Komarov - 2011, License: GPLv3              //
// Please see: http://www.gnu.org/licenses/gpl.html     //
// for legal details, rights of fair usage and          //
// the disclaimer and warranty conditions.              //
//////////////////////////////////////////////////////////
 
integer o = -1;
 
set_timer_to_random_within_range()
{
    // set timer to a random in range [5.0, 15.0)
 
    llSetTimerEvent(5.0 + (integer)llFrand(10.0));
}
 
default
{
    state_entry()
    {
        key owner = llGetOwner();
        llRequestPermissions(owner, PERMISSION_TRIGGER_ANIMATION);
    }
 
    run_time_permissions(integer perm)
    {
        if(perm & PERMISSION_TRIGGER_ANIMATION)
            set_timer_to_random_within_range();
    }
 
    timer()
    {
        list smiles = ["express_smile", "express_toothsmile"];
 
        if(o = ~o)
        {
            llStartAnimation(llList2String(smiles, (integer)llFrand(2.0)));
            llSetTimerEvent(1.0);
            return;
        }
 
        integer index;
        while (index < llGetListLength(smiles))
        {
            llStopAnimation(llList2String(smiles, index));
            ++index;
        }
 
        set_timer_to_random_within_range();
    }
}

To use this script, simply drop it into one of your attachments that you are wearing and the script should take care of all the rest. Happy smiling!