-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnPose Click to Attach.lsl
78 lines (65 loc) · 2.85 KB
/
nPose Click to Attach.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
/*
IMPORTANT NOTES:
-----------------
TEMP ATTACH ITEMS WILL BE DELETED ONCE REZZED INWORLD. PLEASE TAKE CARE TO USE ONLY ITEMS WITH COPY PERMISSIONS.
Any items intended to be temp attached to anyone other than the build owner must have transfer permissions.
This script will get it's attach point from the description of the object.
-----------------
nPose will talk to this script on the nPose build's chat channel, even after attached to another AV besides the nPose build owner.
Make a BTN notecard with the following contents to rez and temp attach "Male Create Glasses":
PROP|Male Create Glasses|<-1.0,0,1.5>|<0,0,0>
Make another BTN notecard with the folloing contents to detach "Male Create Glasses":
LINKMSG|-6002|Male Create Glasses=detach|%AVKEY%
*/
key userKey;
integer attachPoint;
integer listenChannel;
default
{
touch_start(integer total_number)
{
userKey = llDetectedKey(0);
attachPoint = (integer)llGetObjectDesc();
llRequestPermissions(userKey, PERMISSION_ATTACH);
}
run_time_permissions(integer vBitPermissions){
if ((vBitPermissions & PERMISSION_ATTACH) && llGetPermissionsKey() == userKey){
if (!llGetAttached() && attachPoint > 0){
llAttachToAvatarTemp(attachPoint);
userKey = "";
}
}else{
llRegionSayTo(userKey, 0, "Permission was not granted.");
}
}
listen( integer channel, string name, key id, string message) {
if (channel == listenChannel){
list tempList1 = llParseString2List(message, ["|"], []);
if (llList2String(tempList1, 0) == "pong"){
//someone has sent out a ping (request for parentID. Only the nPose core sends "Pong", grab the parentID.
// parentID = id;
return;
}
list tempList = llParseString2List(llList2String(tempList1, 2), ["/"], []);
string varItem = llList2String(llParseString2List(llList2String(tempList, 0), ["="], []), 0);
string varCmd = llList2String(llParseString2List(llList2String(tempList, 0), ["="], []), 1);
attachPoint = (integer)llList2String(tempList, 1);
userKey = (key)llList2String(tempList1, 3);
if ((llList2String(tempList1, 1) == "-6002")
&& ((llGetAttached()) && (varCmd == "detach") && (llGetObjectName() == varItem) && (llGetPermissionsKey() == userKey))){
llDetachFromAvatar();
}
}
}
on_rez(integer rez){
listenChannel = (integer)((0x00FFFFFF & (rez >> 8)) + 0x7F000000);
integer listen_handle = llListen(listenChannel, "","", "");
}
changed(integer change){
if (change & CHANGED_OWNER){
if (llGetAttached()){
llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
}
}
}
}