Greeting Card

From Second Life Wiki
Jump to navigation Jump to search

Greeting Card

--BETLOG Hax UTC+10: 20091004 0012 [SLT: 20091003 0712]


The prims are dimpled, root 0.0-0.5 and child 0.5-1.0
The child prim is cut 0.375-0.875
Texture repeats are adjusted accordingly
You'll figure out which way to orient the prims when you link and touch it.

//==============================================================
// BETLOG Hax
// UTC+10: 20091003 2019 [SLT: 20091003 0319]
// For eKitten Magic
//==============================================================
//        **** LICENCE START ****
// http://creativecommons.org/licenses/by-sa/3.0/
//             Attribution licence:
// You must:
//    -Include this unaltered licence information.
//    -Supply my original script with your modified version.
//    -Retain the original scripts' SL permissions. [+c/+m/+t]
// Or:
//    -Link to the wiki URL from which you copied this script.
//          https://wiki.secondlife.com/wiki/Greeting_Card
//    -Document: "Uses parts of <scriptname> by BETLOG Hax"
//        **** LICENCE END ****
//----------------------------------
// SHARED CONFIGURATION
//----------------------------------
// CONFIGURATION
string          gSound          = "";//optional, one in contents will work too
float           gVolume         = 1.0;
//
string          gAnim           = "";//optional, one in contents will work too
//
float           gAngle          = 160.0;
//----------------------------------
// CORE CODE
integer         gOpen;
//----------------------------------
f_toggle()
{   if(gOpen)
    {   if(gSound!="")
            llLoopSound(gSound,gVolume);
        if(gAnim!="")
            llStartAnimation(gAnim);
    }
    else
    {   llStopSound();
        if(gAnim!="")
            llStopAnimation(gAnim);
    }
    llSetLinkPrimitiveParams(2,[PRIM_ROTATION
        ,llEuler2Rot(<gAngle*(float)gOpen, 0.0, 0.0>*DEG_TO_RAD)/llGetLocalRot()
    ]);
}
//=========================================================================
default
{   on_rez(integer param) 
    {   llResetScript();
    }
    state_entry()
    {   if(gSound=="")
        {   string sound = llGetInventoryName(INVENTORY_SOUND,0);
            if(sound!="")
            {   gSound=sound;
                llPreloadSound(gSound);
            }
        }
        if(gAnim=="")
        {   string anim = llGetInventoryName(INVENTORY_ANIMATION,0);
            if(anim!="")
            {   gAnim=anim;
                llPreloadSound(gAnim);
            }
        }
        f_toggle();
    }
    touch_start(integer total_number)
    {   gOpen=!gOpen;
        f_toggle();
    }
}
//=========================================================================