-
Notifications
You must be signed in to change notification settings - Fork 1
/
[SC] door2 Setup 0.4 (multi).lsl
204 lines (170 loc) · 5.5 KB
/
[SC] door2 Setup 0.4 (multi).lsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/*This is a setup script for brittylicious's door2 0.6 script
How to use:
1. place this script in the door your want to set up
2. click on the door and a menu will pop up
3. make sure the door is in the position you want(either opened or close)
4. then select the option from the menu(set door close/ set door open)
5. when you done just select done from the menu and now place the door2 0.6 script int the door
6. copy and paste the set up from the chat to the door2 0.6 script and save
if you have any door which are in more than one part:
just add the prefix 'dr_' to the child part of the door
the script will auto detect it
you can change the prefix from the script variables
when you click done it will show you the params for the linked part too
more inf or or want to contribute to it,see the github repo @
https://github.com/ShanaPearson/SC-door2-0.6-setup
*/
//===================================Variables=====================================
string closePos;
string closeRot;
string openPos;
string openRot;
rotation initRot;
vector initPos;
integer i;
integer j;
integer var;
integer length;
integer cnt;
string prefix= "dr_"; //*** PREFIX IS HERE ****
list linkName =[];
list link=[];
list linkClose;
list linkOpen;
list alpha=["","b","c","d","e","f","g","h","i"];
list linkInit=[];
//====================================================================================
find_link()
{
integer prims = llGetNumberOfPrims();
integer index;
while(prims--)
{
string name = llGetLinkName(index);
if(llGetSubString(name, 0, 2) == prefix)
{
link = link + index;
linkName=linkName+name;
}
index++;
}
cnt = llGetListLength(link);
llOwnerSay("Number of linked parts found:" +(string)cnt);
llSay(0,"Number of linked parts found:" +(string)cnt);
}
dump()
{
if(link!=[])
{
llOwnerSay("\nvector close_position = " + closePos + ";"
+ "\nrotation close_rotation = " + closeRot + ";"
+ "\n\nvector open_position = " + openPos + ";"
+ "\nrotation open_rotation = " + openRot + ";"
+"\n"
);
i=0;
length = llGetListLength(linkName);
var=0;
j=0;
while (i < length)
{
j=i+var;
// llOwnerSay("I: "+(string)i+"\n J: "+(string)j );
llOwnerSay("\nstring link"+llList2String(alpha, i)+"_name =\""+llList2String(linkName, i)+"\";"
+"\nvector link"+llList2String(alpha, i)+"_close_position = "+llList2String(linkClose, j)+";"
+"\nrotation link"+llList2String(alpha, i)+"_close_rotation ="+llList2String(linkClose, j+1)+";"
+"\nvector link"+llList2String(alpha, i)+"_open_position ="+llList2String(linkOpen, j)+";"
+"\nrotation link"+llList2String(alpha, i)+"_open_rotation ="+llList2String(linkOpen, j+1)+";"
);
++i;
var=var+1;
}
}
else
{ llOwnerSay("\nvector close_position = " + closePos + ";"
+ "\nrotation close_rotation = " + closeRot + ";"
+ "\n\nvector open_position = " + openPos + ";"
+ "\nrotation open_rotation = " + openRot + ";"
);}
}
reset()
{
closePos="";
closeRot="";
openPos="";
openRot="";
linkName =[];
link =[];
linkClose = [];
linkOpen = [];
cnt=0;
llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POS_LOCAL, initPos, PRIM_ROT_LOCAL, initRot]);
find_link();
}
list buttons = ["Set Open", "Set Close", "Reset","Done"];
string dialogInfo = "\nPlease make a choice.";
key ToucherID;
integer dialogChannel;
integer listenHandle;
default
{
state_entry()
{
initRot= llGetLocalRot();
initPos= llGetLocalPos();
dialogChannel = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );
reset();
llOwnerSay("Setup init...");
}
touch_start(integer num_detected)
{
ToucherID = llDetectedKey(0);
listenHandle = llListen(dialogChannel, "", ToucherID, "");
llDialog(ToucherID, dialogInfo, buttons, dialogChannel);
}
listen(integer channel, string name, key id, string message)
{
if (message == "Set Open")
{
openPos = (string)llGetLocalPos();
openRot = (string)llGetLocalRot();
if(link!=[])
{
i=0;
length = llGetListLength(link);
do
linkOpen = linkOpen + llGetLinkPrimitiveParams(llList2Integer(link, i),[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);
while(++i < length);
}
llOwnerSay("Opened set");
}
if (message == "Set Close")
{
closePos = (string)llGetLocalPos();
closeRot = (string)llGetLocalRot();
if(link!=[])
{
i=0;
length = llGetListLength(link);
do
linkClose = linkClose + llGetLinkPrimitiveParams(llList2Integer(link, i),[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);
while(++i < length);
}
llOwnerSay("Closed set");
}
if (message == "Done")
{
if( openPos=="" || openRot == "" || closePos == "" || closeRot == "" )
{llOwnerSay("Door has not been set up correctly");}
else
{
dump();
llRemoveInventory(llGetScriptName());
}
}
if (message == "Reset")
{
reset();
}
}
}