Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Pet Follower  

Follower

A gadget that follows a target when rezzed by a controller. Useful in attack huds and rezzers

Category: Pet
By : Anonymous
Created: 2010-01-10 Edited: 2014-02-15
Worlds: Second Life

the Zip file

Download all files for Follower
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. follower.lsl
1
2 // follower
3
4 integer unichan = -123458; // this is the channel used by the controller and objects to sync
5
6 integer handle; // handle for the listen function
7 vector my_offset; // original offset, set at first activation
8 rotation my_orientation; // original rotation, set at first activation
9 integer my_num; // position in the chain of redundancy
10
11 default
12 {
14 {
16 }
17
19 {
20 my_num = (integer)llGetSubString(llGetScriptName(), -1, -1);
21 handle = llListen(unichan + my_num, "", "", "");
22 }
23
24 listen(integer chan, string name, key id, string mesg)
25 {
26 if(mesg == "k")
27 llDie();
28
29 integer index = llSubStringIndex(mesg, "*");
30 my_offset = llGetPos() + llGetRegionCorner() - (vector)llGetSubString(mesg, 0, index - 1);
31 my_orientation = llGetRot();
32 my_offset = my_offset / my_orientation;
33 state running;
34 }
35
37 {
38 llListenRemove(handle);
39 }
40 }
41
42 state running
43 {
45 {
46 state default;
47 }
48
50 {
51 handle = llListen(unichan + my_num, "", "", "");
52 }
53
54 listen(integer chan, string name, key id, string mesg)
55 {
56 if(mesg == "k")
57 llDie();
58 list info = llParseString2List(mesg, ["*"], []);
59 rotation rtarget = my_orientation * llEuler2Rot(<0,0,(float)((integer)llList2String(info, 1)) * DEG_TO_RAD>);
60 vector target = my_offset * rtarget + (vector)llList2String(info, 0) - llGetRegionCorner();
62 }
63
65 {
66 llListenRemove(handle);
67 }
68 }

Back to the Best Free Tools in Second Life and OpenSim.