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 OwnerLockedDoor  

OwnerLockedDoor

OwnerLockedDoor

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

the Zip file

Download all files for OwnerLockedDoor
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. OwnerLockedDoor_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
18 integer DOOR_OPEN = 1;
19 integer DOOR_CLOSE = 2;
20
21 vector originalPos;
22
23 door(integer what)
24 {
25 rotation rot;
26 rotation delta;
27 vector eul;
28
30
31 if( what == DOOR_OPEN )
32 {
33 llTriggerSound("doorOpen", 1);
34 eul = <0, 0, 90*DIRECTION>; //90 degrees around the z-axis, in Euler form
35
36 } else if( what == DOOR_CLOSE)
37 {
38 llTriggerSound("doorClose", 1);
39 eul = <0, 0, 90*-DIRECTION>; //90 degrees around the z-axis, in Euler form
40 }
41
42 eul *= DEG_TO_RAD; //convert to radians rotation
43 rot = llGetRot();
44 delta = llEuler2Rot(eul);
45 rot = delta * rot;
46 llSetRot(rot);
47 }
48
49
50 default
51 {
52 on_rez(integer start_param)
53 {
55 }
56
58 {
59 originalPos = llGetPos();
60 }
61
62 touch_start(integer total_number)
63 {
64 key who = llDetectedKey(0);
65 if( who==llGetOwner() )
66 {
67 llSay(0,"Hello " + llDetectedName(0) );
68 door(DOOR_OPEN);
69 state open_state;
70 }
71 else
72 {
73 llSay(0,llDetectedName(0) + " is at the door." );
74 llTriggerSound("doorbell", 0.8);
75 }
76 }
77
78 moving_end()
79 {
80 originalPos = llGetPos();
81 }
82 }
83
84 state open_state
85 {
87 {
88 llSetTimerEvent(TIMER_CLOSE);
89 }
90
92 {
93 door(DOOR_CLOSE);
94 llSetPos(originalPos);
95 state default;
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.