-
Notifications
You must be signed in to change notification settings - Fork 2
/
[AV]osobject.lsl
240 lines (228 loc) · 6.86 KB
/
[AV]osobject.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/*
* [AV]object - Used in props for attaching, derezzing, etc.
* (OpenSim version)
* (OpenSim version which keeps rotation on attached props)
* Fix by Typhaine Artez (check typhfix in the code)
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright © the AVsitter Contributors (http://avsitter.github.io)
* AVsitter™ is a trademark. For trademark use policy see:
* https://avsitter.github.io/TRADEMARK.mediawiki
*
* Please consider supporting continued development of AVsitter and
* receive automatic updates and other benefits! All details and user
* instructions can be found at http://avsitter.github.io
*/
string version = "2.020";
integer comm_channel;
integer local_attach_channel = -2907539;
integer listen_handle;
integer prop_type;
integer prop_id;
integer prop_point;
integer experience_denied_reason;
key originalowner;
key parentkey;
key give_prop_warning_request;
vector prop_rotation; // typhfix: added to store rotation
unsit_all()
{
integer i = llGetNumberOfPrims();
while (llGetAgentSize(llGetLinkKey(i)) != ZERO_VECTOR)
{
llUnSit(llGetLinkKey(i));
i--;
}
}
integer verbose = 5;
Out(integer level, string out)
{
if (verbose >= level)
{
llOwnerSay(llGetScriptName() + "[" + version + "] " + out);
}
}
default
{
on_rez(integer start)
{
if (start)
{
state prop;
}
}
}
state prop
{
state_entry()
{
if (llGetLinkNumber() < 2)
{
if (llGetStartParameter() <= -10000000)
{
string start_param = (string)llGetStartParameter();
prop_type = (integer)llGetSubString(start_param, -1, -1);
prop_point = (integer)llGetSubString(start_param, -3, -2);
prop_id = (integer)llGetSubString(start_param, -5, -4);
comm_channel = (integer)llGetSubString(start_param, 0, -6);
listen_handle = llListen(comm_channel, "", "", "");
llSay(comm_channel, "REZ|" + (string)prop_id);
}
else
{
}
}
if (prop_type != 2 && prop_type != 1)
{
if (llGetInventoryType("[AV]sitA") == INVENTORY_NONE)
{
llSetClickAction(CLICK_ACTION_NONE);
}
}
else
{
llSetClickAction(CLICK_ACTION_TOUCH);
}
}
attach(key id)
{
if (comm_channel)
{
if (llGetAttached())
{
llListen(local_attach_channel, "", "", "");
llSay(comm_channel, "ATTACHED|" + (string)prop_id);
llSay(local_attach_channel, "LOCAT|" + (string)llGetAttached());
if (experience_denied_reason == 17)
{
if (llGetOwner() == originalowner)
{
list details;
if (llList2String(details, 3) == "17")
{
llSay(comm_channel, "NAG|" + llList2String(details, 0));
}
}
}
}
else
{
llSay(comm_channel, "DETACHED|" + (string)prop_id);
}
}
}
touch_start(integer touched)
{
if ((!llGetAttached()) && (prop_type == 2 || prop_type == 1))
{
llRequestPermissions(llDetectedKey(0), PERMISSION_ATTACH);
}
}
run_time_permissions(integer permissions)
{
if (permissions & PERMISSION_ATTACH)
{
if (llGetAttached())
{
llDetachFromAvatar();
}
else
{
llAttachToAvatarTemp(prop_point);
// typhfix: apply stored rotation
if (ZERO_VECTOR != prop_rotation) {
llSetLocalRot(llEuler2Rot(prop_rotation * DEG_TO_RAD));
}
}
}
else
{
llSay(comm_channel, "DEREZ|" + (string)prop_id);
llDie();
}
}
on_rez(integer start)
{
if (!llGetAttached())
{
state restart_prop;
}
}
listen(integer channel, string name, key id, string message)
{
list data = llParseString2List(message, ["|"], []);
string command = llList2String(data, 0);
if (llList2String(data, 0) == "LOCAT" && llGetOwnerKey(id) == llGetOwner() && llList2String(data, 1) == (string)llGetAttached())
{
llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
}
else if (command == "ATTACHTO" && prop_type == 1 && (key)llList2String(data, 2) == llGetKey())
{
if (llGetAgentSize((key)llList2String(data, 1)) == ZERO_VECTOR)
{
llSay(comm_channel, "DEREZ|" + (string)prop_id);
// typhfix: prevent an error on OpenSim 0.8.2 console
llSleep(0.5);
llDie();
}
else
{
// typhfix: store rotation from the message
prop_rotation = (vector)llList2String(data, 3);
llRequestPermissions(llList2Key(data, 1), PERMISSION_ATTACH);
}
}
else if (llGetSubString(command, 0, 3) == "REM_")
{
integer remove;
if (command == "REM_ALL")
{
remove = TRUE;
}
else if (command == "REM_INDEX" || (command == "REM_WORLD" && !llGetAttached()))
{
if (~llListFindList(data, [(string)prop_id]))
{
remove = TRUE;
}
}
else if (llGetAttached() && command == "REM_WORN" && (key)llList2String(data, 1) == llGetOwner())
{
remove = TRUE;
}
if (remove)
{
if (llGetAttached())
{
llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
}
else
{
if (llGetAgentSize(llGetLinkKey(llGetNumberOfPrims())) != ZERO_VECTOR)
{
unsit_all();
llSleep(1);
}
llSay(comm_channel, "DEREZ|" + (string)prop_id);
// typhfix: prevent an error on OpenSim 0.8.2 console
llSleep(0.5);
llDie();
}
}
}
else if (message == "PROPSEARCH" && !llGetAttached())
{
llSay(comm_channel, "SAVEPROP|" + (string)prop_id);
}
}
}
state restart_prop
{
state_entry()
{
state prop;
}
}