Difference between revisions of "User:Dora Gustafson"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
{{LSL Header}} | |||
==The Talking Die script== | ==The Talking Die script== | ||
Place this script in a cube and you have a Die.<br> | Place this script in a cube and you have a Die.<br> |
Revision as of 08:17, 10 May 2008
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
The Talking Die script
Place this script in a cube and you have a Die.
The Die will say how many pips are on the upward face, after the Die 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>