Difference between revisions of "User:Dora Gustafson"

From Second Life Wiki
Jump to navigation Jump to search
(The Talking Die script)
 
(The Talking Die)
Line 1: Line 1:
/////
==The Talking Die script==
//  The talking Die script, studio Dora, Dora Gustafson 2008
Place this script in a cube and you have a Die.<br>
//  v1.20 Basics
The Die will say how many pips are up after it is tossed.
/////
<lsl>
//  Place this script in a cube and you have a Die.
/////
//  The Die will say how many pips are up after it is tossed.
//  The talking Die script, studio Dora, Dora Gustafson 2008
//  Free ware! feel free to utilize this script
//  v1.20 Basics
//    and texture, partially or as a whole
/////
//  Please give credit to the creator: Dora Gustafson
//  Place this script in a cube and you have a Die.
//  You can do that by keeping this header unchanged
//  The Die will say how many pips are up after it is tossed.
/////
//  Free ware! feel free to utilize this script
list pr;
//    and texture, partially or as a whole
string dieTexture = "b88d3ced-e298-83d7-7da6-e130a337b6ac"; // terning 2x6 SD.png
//  Please give credit to the creator: Dora Gustafson
string pips_up()
//  You can do that by keeping this header unchanged
{
/////
    vector u = llRot2Fwd( llGetRot() );
 
    vector v = llRot2Left( llGetRot() );
list pr;
    vector w = llRot2Up( llGetRot() );
string dieTexture = "b88d3ced-e298-83d7-7da6-e130a337b6ac"; // terning 2x6 SD.png
    // Vectors associated with die pip numbers
 
    list pips_list = [ u.z, 1, -u.z, 6, v.z, 2, -v.z, 5, w.z, 3, -w.z, 4 ];
string pips_up()
    // sort for the one with the biggest Z (vertical up) component,
{
    // the associated pip number is upward
    vector u = llRot2Fwd( llGetRot() );
    return llList2String( llListSort( pips_list, 2, FALSE ), 1 );
    vector v = llRot2Left( llGetRot() );
}
    vector w = llRot2Up( llGetRot() );
default
 
{
    // Vectors associated with die pip numbers
    state_entry()
    list pips_list = [ u.z, 1, -u.z, 6, v.z, 2, -v.z, 5, w.z, 3, -w.z, 4 ];
    {
    // sort for the one with the biggest Z (vertical up) component,
        llSetPrimitiveParams([
    // the associated pip number is upward
        PRIM_TEXTURE, 0, dieTexture, < 0.5, 0.333, 0.0>, < 0.75, -0.333, 0.0>, 0.0,
    return llList2String( llListSort( pips_list, 2, FALSE ), 1 );
        PRIM_TEXTURE, 1, dieTexture, < 0.5, 0.333, 0.0>, < -0.75, 0.0, 0.0>, 0.0,
}
        PRIM_TEXTURE, 2, dieTexture, < 0.5, 0.333, 0.0>, < 0.75, 0.333, 0.0>, 0.0,
 
        PRIM_TEXTURE, 3, dieTexture, < 0.5, 0.333, 0.0>, < 0.75, 0.0, 0.0>, 0.0,
default
        PRIM_TEXTURE, 4, dieTexture, < 0.5, 0.333, 0.0>, < -0.75, 0.333, 0.0>, 0.0,
{
        PRIM_TEXTURE, 5, dieTexture, < 0.5, 0.333, 0.0>, < -0.75, -0.333, 0.0>, 0.0 ]);
    state_entry()
        llSetStatus( STATUS_PHYSICS, TRUE );
    {
        llSetBuoyancy( 0.5 );
        llSetPrimitiveParams([
    }
        PRIM_TEXTURE, 0, dieTexture, < 0.5, 0.333, 0.0>, < 0.75, -0.333, 0.0>, 0.0,
    collision_start(integer n)
        PRIM_TEXTURE, 1, dieTexture, < 0.5, 0.333, 0.0>, < -0.75, 0.0, 0.0>, 0.0,
    {
        PRIM_TEXTURE, 2, dieTexture, < 0.5, 0.333, 0.0>, < 0.75, 0.333, 0.0>, 0.0,
        llSetTimerEvent( 2.0 );
        PRIM_TEXTURE, 3, dieTexture, < 0.5, 0.333, 0.0>, < 0.75, 0.0, 0.0>, 0.0,
        pr = llGetPrimitiveParams([PRIM_POSITION, PRIM_ROTATION ]);
        PRIM_TEXTURE, 4, dieTexture, < 0.5, 0.333, 0.0>, < -0.75, 0.333, 0.0>, 0.0,
    }
        PRIM_TEXTURE, 5, dieTexture, < 0.5, 0.333, 0.0>, < -0.75, -0.333, 0.0>, 0.0 ]);
    land_collision_start(vector v)  
        llSetStatus( STATUS_PHYSICS, TRUE );
    {
        llSetBuoyancy( 0.5 );
        llSetTimerEvent( 2.0 );
    }
        pr = llGetPrimitiveParams([PRIM_POSITION, PRIM_ROTATION ]);
 
    }
    collision_start(integer n)
    timer()
    {
    {
        llSetTimerEvent( 2.0 );
        list prnu = llGetPrimitiveParams([PRIM_POSITION, PRIM_ROTATION ]);
        pr = llGetPrimitiveParams([PRIM_POSITION, PRIM_ROTATION ]);
        if ( pr == prnu )
    }
        {
 
            llSetTimerEvent( 0.0 );
    land_collision_start(vector v)  
            llWhisper( PUBLIC_CHANNEL, pips_up() + " pips" );
    {
        }
        llSetTimerEvent( 2.0 );
        else pr = prnu;
        pr = llGetPrimitiveParams([PRIM_POSITION, PRIM_ROTATION ]);
    }
    }
}
 
    timer()
    {
        list prnu = llGetPrimitiveParams([PRIM_POSITION, PRIM_ROTATION ]);
        if ( pr == prnu )
        {
            llSetTimerEvent( 0.0 );
            llWhisper( PUBLIC_CHANNEL, pips_up() + " pips" );
        }
        else pr = prnu;
    }
}</lsl>
----
[https://wiki.secondlife.com/wiki/Category:LSL_Library Script Library]

Revision as of 08:04, 10 May 2008

The Talking Die script

Place this script in a cube and you have a Die.
The Die will say how many pips are up after it is tossed. <lsl> ///// // The talking Die script, studio Dora, Dora Gustafson 2008 // v1.20 Basics ///// // Place this script in a cube and you have a Die. // The Die will say how many pips are up after it is tossed. // Free ware! feel free to utilize this script // and texture, partially or as a whole // Please give credit to the creator: Dora Gustafson // You can do that by keeping this header unchanged /////

list pr; string dieTexture = "b88d3ced-e298-83d7-7da6-e130a337b6ac"; // terning 2x6 SD.png

string pips_up() {

   vector u = llRot2Fwd( llGetRot() );
   vector v = llRot2Left( llGetRot() );
   vector w = llRot2Up( llGetRot() );
   // Vectors associated with die pip numbers
   list pips_list = [ u.z, 1, -u.z, 6, v.z, 2, -v.z, 5, w.z, 3, -w.z, 4 ];
   // sort for the one with the biggest Z (vertical up) component,
   // the associated pip number is upward
   return llList2String( llListSort( pips_list, 2, FALSE ), 1 );

}

default {

   state_entry()
   {
       llSetPrimitiveParams([
       PRIM_TEXTURE, 0, dieTexture, < 0.5, 0.333, 0.0>, < 0.75, -0.333, 0.0>, 0.0,
       PRIM_TEXTURE, 1, dieTexture, < 0.5, 0.333, 0.0>, < -0.75, 0.0, 0.0>, 0.0,
       PRIM_TEXTURE, 2, dieTexture, < 0.5, 0.333, 0.0>, < 0.75, 0.333, 0.0>, 0.0,
       PRIM_TEXTURE, 3, dieTexture, < 0.5, 0.333, 0.0>, < 0.75, 0.0, 0.0>, 0.0,
       PRIM_TEXTURE, 4, dieTexture, < 0.5, 0.333, 0.0>, < -0.75, 0.333, 0.0>, 0.0,
       PRIM_TEXTURE, 5, dieTexture, < 0.5, 0.333, 0.0>, < -0.75, -0.333, 0.0>, 0.0 ]);
       llSetStatus( STATUS_PHYSICS, TRUE );
       llSetBuoyancy( 0.5 );
   }
   collision_start(integer n)
   {
       llSetTimerEvent( 2.0 );
       pr = llGetPrimitiveParams([PRIM_POSITION, PRIM_ROTATION ]);
   }
   land_collision_start(vector v) 
   {
       llSetTimerEvent( 2.0 );
       pr = llGetPrimitiveParams([PRIM_POSITION, PRIM_ROTATION ]);
   }
   timer()
   {
       list prnu = llGetPrimitiveParams([PRIM_POSITION, PRIM_ROTATION ]);
       if ( pr == prnu )
       {
           llSetTimerEvent( 0.0 );
           llWhisper( PUBLIC_CHANNEL, pips_up() + " pips" );
       }
       else pr = prnu;
   }

}</lsl>


Script Library