Join us in Phaze Demesnes or follow us:

Home   Show All
Category: Contributor: Creator
Door Ultra_Deluxe_Door_Script  

Ultra_Deluxe_Door_Script

Ultra Deluxe Door Script.lsl

Category: Door
By : Ezhar Fairlight
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life + OpenSim

the Zip file

Download all files for Ultra_Deluxe_Door_Script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Ultra_Deluxe_Door_Script_1.lsl
1 // deluxe door script by Ezhar Fairlight
2 // features: one prim, no building skills required, automatic closing, workaround for rotation drift,
3 // doesn't mess up when moved, adjustable direction (inwards/outwards) and sound volume, HHGG quotes!
4 // updated for SL 1.4
5
6 // just rez a cube primitive and put this script inside - it will shape and texture itself into a door
7
8 // ********** SETTINGS HERE ************
9 float TIMER = 30.0; // automatically close the door after this many seconds,
10 // set to 0 to disable automatic closing
11
12 integer DIRECTION = -1; // direction door opens in. Either 1 (outwards) or -1 (inwards);
13
14 float VOLUME = 0.8; // sound volume, 1.0 loudest, 0.0 to disable sound
15 // ********** END OF SETTINGS **********
16
17
18 key SOUND_OPEN = "cb340647-9680-dd5e-49c0-86edfa01b3ac";
19 key SOUND_CLOSE = "e7ff1054-003d-d134-66be-207573f2b535";
20
21 vector gPos; // door position (objects move a tiny amount
22 // away from their position each time they are rotated,
23 // thus we need to workaround this by resetting
24 // the position after rotating)
25
26 door(integer open) {
27 if (open) {
28 llTriggerSound(SOUND_OPEN, VOLUME);
29 llSetRot(llEuler2Rot(<0, 0, -DIRECTION * PI_BY_TWO>) * llGetRot());
30 } else { // close
31 llSetRot(llEuler2Rot(<0, 0, DIRECTION * PI_BY_TWO>) * llGetRot());
32 llTriggerSound(SOUND_CLOSE, VOLUME);
33 }
34 }
35
36
37 default { // first time startup
38 state_entry() {
39 if (llGetTexture(0) == "89556747-24cb-43ed-920b-47caed15465f") { // is default texture, set it up
40 llSetPos(llGetPos() + <0, 0, 3.325 / 2 - 0.25>);
41 llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX,0, <0.375, 0.875, 0>, 0.0,<0, 0, 0>, <1, 1, 0>, <0, 0, 0>,
42 PRIM_SIZE, <0.2, 4, 3.325>,
43 PRIM_TEXTURE, 0, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <2.000000, 0.060000, 0.000000>, <0.500015, 0.469985, 0.000000>, 1.570840,
44 PRIM_TEXTURE, 1, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <-2.000000, 1.000000, 0.000000>, <0.500015, 0.000000, 0.000000>, 0.000000,
45 PRIM_TEXTURE, 2, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <0.100000, 1.000000, 0.000000>, <0.599994, 0.000000, 0.000000>, 0.000000,
46 PRIM_TEXTURE, 3, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <2.000000, 1.000000, 0.000000>, <0.500015, 0.000000, 0.000000>, 0.000000,
47 PRIM_TEXTURE, 4, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <2.000000, 0.080000, 0.000000>, <0.500015, 0.550005, 0.000000>, 1.570840,
48 PRIM_TEXTURE, 5, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <0.100000, 1.000000, 0.000000>, <0.449995, 0.000000, 0.000000>, 0.000000,
49 PRIM_TEXTURE, 6, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <0.100000, 1.000000, 0.000000>, <0.449995, 0.000000, 0.000000>, 0.000000]
50 );
51 llSetObjectName("Door Deluxe");
52 llSay(0, "Thank you for making a simple door very happy.");
53 }
54 gPos = llGetPos(); // remember where we're supposed to be
55 door(TRUE);
56 state closed;
57 }
58 }
59
60 state closed { // door is closed
61 on_rez(integer start_param) {
62 gPos = llGetPos();
63 }
64
65 state_entry() {
66 door(FALSE);
67 }
68
69 touch_start(integer total_number) {
70 state open;
71 }
72
73 moving_end() { // done moving me around, store new position
74 gPos = llGetPos();
75 }
76 }
77
78 state open { // door is open
79 on_rez(integer start_param) {
80 gPos = llGetPos();
81 state closed;
82 }
83
84 state_entry() {
85 llSetTimerEvent(TIMER);
86 llSetPos(gPos); // rotation drift workaround
87 door(TRUE);
88 }
89
91 state closed;
92 }
93
94 timer() { // auto-close
95 state closed;
96 }
97
98 moving_start() { // close when being moved
99 state closed;
100 }
101
102 state_exit() {
104 }
105 }// END //