Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Door Drawer_Script  

Drawer_Script

Drawer Script.lsl

Category: Door
By : Anonymous
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Drawer_Script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Drawer_Script_1.lsl
1
2
3 //Drawer Script
4 //===quote===
5 //You will want to put something like this in all three drawer parts. Touching any of the three parts will trigger all the drawer parts to open/close.
6
7 //For each drawer, you need to change the drawer_num to a different number.
8 //EG: it should be set to 1 for all three pieces of the 1st drawer, 2 for all pieces of the 2nd drawer, etc...
9
10 //Put a copy of this script into each of the drawer prims.
11
12 //Link the 3 drawer prims in with all the other bookcase prims making sure the base prim of the bookcase is selected last. Unless you have other special prims in the bookcase that require a certain link order, only the base prim matters as to what order it's linked in as this determines what the +X axis of the entire object is.
13 //=== end quote ===
14
15 integer drawer_num = 2; // this is the top drawer - all componenets
16 // of a drawer should use the same number.
17 // EG: change to 2 for all 2nd drawer prims
18 float slide_dist = 0.5; // distance in meters drawer should open
19 integer is_open = FALSE; // assume drawer starts out closed
20 string close_message = "CLOSE DRAWER"; // Close message to send to other prims
21 string open_message = "OPEN DRAWER"; // Open message to send to other prims
22
23 default
24 {
25
27 {
28 } // end of state_entry state
29
30 touch_start(integer nullvar)
31 {
32 if( is_open )
33 { // it's open, so close it
34 is_open = FALSE;
35 llMessageLinked(LINK_ALL_OTHERS, drawer_num, close_message, NULL_KEY);
36 llSetPos(<-slide_dist, 0.0, 0.0> + llGetLocalPos());
37 }
38 else
39 { // it's closed so open it
40 is_open = TRUE;
41 llMessageLinked(LINK_ALL_OTHERS, drawer_num, open_message, NULL_KEY);
42 llSetPos(<slide_dist, 0.0, 0.0> + llGetLocalPos());
43 }
44 } // end of touch_start state
45
46 link_message(integer sender_num, integer num, string str, key id)
47 {
48 if( num == drawer_num )
49 {
50 if( str == open_message )
51 { // we are bing asked to open
52 if( ! is_open )
53 { // if closed, then open. Otherwise do nothing
54 llSetPos(<slide_dist, 0.0, 0.0> + llGetLocalPos());
55 is_open = TRUE;
56 }
57 }
58
59 if( str == close_message )
60 { // we are bing asked to close
61 if( is_open )
62 { // if open then close. Otherwise do nothing
63 llSetPos(<-slide_dist, 0.0, 0.0> + llGetLocalPos());
64 is_open = FALSE;
65 }
66 }
67 }
68 } // end of link_message state
69 }// END //

Back to the Best Free Tools in Second Life and OpenSim.