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 SecondaryDoor  

SecondaryDoor

SecondaryDoor

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

the Zip file

Download all files for SecondaryDoor
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. SecondaryDoor_1.lsl
1 // From the book:
2 //
3 // Scripting Recipes for Second Life
4 // by Jeff Heaton (Encog Dod in SL)
5 // ISBN: 160439000
6 X// Copyright 2007 by Heaton Research, Inc.
7 //
8 // This script may be freely copied and modified so long as this header
9 // remains unmodified.
10 //
11 // For more information about this book visit the following web site:
12 //
13 // http://www.heatonresearch.com/articles/series/22/
14
15 float TIMER_CLOSE = 5.0;
16 integer DIRECTION = -1; // direction door opens in. Either 1 (outwards) or -1 (inwards);
17 // end of configuration
18
19 integer DOOR_OPEN = 1;
20 integer DOOR_CLOSE = 2;
21
22 vector originalPos;
23 string lastCode;
24
25 // simple function to open or close the door
26 // this works by rotating the door
27 door(integer what)
28 {
29 rotation rot;
30 rotation delta;
31 vector eul;
32
34
35 if( what == DOOR_OPEN )
36 {
37 llTriggerSound("doorOpen", 1);
38 eul = <0, 0, 90*DIRECTION>; //90 degrees around the z-axis, in Euler form
39
40 } else if( what == DOOR_CLOSE)
41 {
42 llTriggerSound("doorClose", 1);
43 eul = <0, 0, 90*-DIRECTION>; //90 degrees around the z-axis, in Euler form
44 }
45
46 eul *= DEG_TO_RAD; //convert to radians rotation
47 rot = llGetRot();
48 delta = llEuler2Rot(eul);
49 rot = delta * rot;
50 llSetRot(rot);
51 }
52
53
54 default
55 {
56 on_rez(integer start_param)
57 {
59 }
60
62 {
63 originalPos = llGetPos();
64 llSetText(llGetObjectName(),<0,0,0>,1.0);
65 llListen(72, "", NULL_KEY, "");
66 }
67
68 touch_start(integer total_number)
69 {
70 lastCode = (string)llRound(llFrand(1000000.));
71 list l = [llGetObjectName(),llDetectedName(0),lastCode];
72 string str = llList2CSV(l);
73 llSay(72,str);
74 }
75
76 moving_end()
77 {
78 originalPos = llGetPos();
79 }
80
81 listen(integer channel, string name, key id, string message)
82 {
83 if( message==lastCode )
84 {
85 door(DOOR_OPEN);
86 state open_state;
87 }
88 }
89 }
90
91 state open_state
92 {
94 {
95 llSetTimerEvent(TIMER_CLOSE);
96 }
97
98 timer()
99 {
100 door(DOOR_CLOSE);
101 llSetPos(originalPos);
102 state default;
103 }
104
106 {
107 door(DOOR_CLOSE);
108 state default;
109 }
110 }

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