Bubble Gum

From Second Life Wiki
Jump to: navigation, search

Created by Kira Komarov.

ChangeLog

Changed state_entry to attach() for anton to void errors.

Introduction

I've been given a challenge to see how fast I can create a bubble gum effect with sounds and animation. I thought to share this one with everybody. To use it, just create a default prim and set it to a sphere shape. Set a texture if you want, a color and set the transparency to 45% or so to make it look like a gum bubble but don't change the size of the sphere prim. After that, attach the newly created sphere prim to your mouth attachment point and drop this script inside it. That's it. Have fun chewing and making bubbles. :-)

Code

//////////////////////////////////////////////////////////
// [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.              //
//////////////////////////////////////////////////////////
 
init() {
    llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
    llPreloadSound("ff0600f0-d8f4-20f6-52ec-a03bc520fee3");
    llSetPos(<0,0,0>);
    llSetScale(<0,0,0>);
}
 
default
{
    on_rez(integer num) {
        if(llGetAttached()) init();
    }
    state_entry() {
        if(llGetAttached()) init();
    }
    attach(key id)
    {
        init();
    }
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            llSetTimerEvent(5 + (integer)llFrand(14));
        }
    }
 
    timer() 
    {
        llSetTimerEvent(0.0);
        llStartAnimation("express_kiss");
        float itra;
        for(itra=0.004; itra<0.06; itra+=0.004) { 
            llSetScale(<itra,itra,itra>);
            llSetPos(llGetLocalPos()+<0.0007,0.0,0.0>);
 
        }
        llPlaySound("ff0600f0-d8f4-20f6-52ec-a03bc520fee3", 1.0);
        llStopAnimation("express_kiss");
        llSetScale(<0,0,0>);
        llSetPos(<0,0,0>);
        llSetTimerEvent(5 + (integer)llFrand(14));
    }
}