diff options
Diffstat (limited to '')
-rw-r--r-- | onefang's leash holder and 1ring support.lsl | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/onefang's leash holder and 1ring support.lsl b/onefang's leash holder and 1ring support.lsl new file mode 100644 index 0000000..e9a11e0 --- /dev/null +++ b/onefang's leash holder and 1ring support.lsl | |||
@@ -0,0 +1,94 @@ | |||
1 | |||
2 | integer mychannel = -8888; | ||
3 | integer particle_chan = -270510; | ||
4 | string listenfor; | ||
5 | string response; | ||
6 | string detach; | ||
7 | |||
8 | key masterid; | ||
9 | key handle; | ||
10 | key them = NULL_KEY; | ||
11 | string URL = ""; | ||
12 | key RequestID; | ||
13 | |||
14 | default | ||
15 | { | ||
16 | state_entry() | ||
17 | { | ||
18 | masterid = llGetOwner(); | ||
19 | handle = llGetKey(); | ||
20 | listenfor = (string)masterid + "handle"; | ||
21 | response = (string)masterid + "handle ok"; | ||
22 | detach = (string)masterid + "handle detached"; | ||
23 | llListen(mychannel, "", NULL_KEY, listenfor); | ||
24 | llSay(mychannel, response); | ||
25 | } | ||
26 | |||
27 | attach(key id) | ||
28 | { | ||
29 | if (NULL_KEY == id) | ||
30 | llSay(mychannel, detach); | ||
31 | } | ||
32 | |||
33 | listen(integer channel, string name, key id, string message) | ||
34 | { | ||
35 | llSay(mychannel, response); | ||
36 | llSay(particle_chan, handle + "#" + masterid); | ||
37 | if (NULL_KEY == them) | ||
38 | them = llGetOwnerKey(id); | ||
39 | } | ||
40 | |||
41 | dataserver(key id, string data) | ||
42 | { | ||
43 | list input = llParseStringKeepNulls(data, ["|"], []); | ||
44 | string domain = llList2String(input, 0); | ||
45 | if ("URL" == domain) | ||
46 | URL = llList2String(input, 1); | ||
47 | } | ||
48 | |||
49 | http_response(key id, integer status, list metaData, string body) | ||
50 | { | ||
51 | if (id == RequestID) | ||
52 | { | ||
53 | RequestID = NULL_KEY; | ||
54 | if (status != 200) | ||
55 | llOwnerSay("HTTP error code " + status + "\n" + body); | ||
56 | } | ||
57 | else if (id == NULL_KEY) | ||
58 | llOwnerSay("Too many HTTP requests too fast!"); | ||
59 | } | ||
60 | |||
61 | on_rez(integer param) | ||
62 | { | ||
63 | llResetScript(); | ||
64 | } | ||
65 | |||
66 | touch_start(integer total_number) | ||
67 | { | ||
68 | llSay(particle_chan, handle + "#" + masterid); | ||
69 | } | ||
70 | |||
71 | changed(integer change) | ||
72 | { | ||
73 | if ("" != URL) | ||
74 | { | ||
75 | if (change & CHANGED_REGION) | ||
76 | { | ||
77 | RequestID = llHTTPRequest(URL, | ||
78 | [HTTP_METHOD, "POST", HTTP_VERBOSE_THROTTLE, FALSE, HTTP_BODY_MAXLENGTH, 16384], | ||
79 | llEscapeURL("REGION|" + llGetRegionName() + "|" + (string)llGetPos())); | ||
80 | llOwnerSay("Changed region to " + llGetRegionName() + " - " + (string)llGetPos() | ||
81 | + "\n Requesting that " + osKey2Name(them) + " join me."); | ||
82 | } | ||
83 | else if (change & CHANGED_TELEPORT) | ||
84 | { | ||
85 | llSleep(1.0); | ||
86 | RequestID = llHTTPRequest(URL, | ||
87 | [HTTP_METHOD, "POST", HTTP_VERBOSE_THROTTLE, FALSE, HTTP_BODY_MAXLENGTH, 16384], | ||
88 | llEscapeURL("TELEPORT|" + llGetRegionName() + "|" + (string)llGetPos())); | ||
89 | llOwnerSay("Teleported to " + llGetRegionName() + " - " + (string)llGetPos() | ||
90 | + "\n Requesting that " + osKey2Name(them) + " join me."); | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | } | ||