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
Bird llLookAtBird  

llLookAtBird

A simple Bird follower script using llLookAt and llMoveToTarget

Category: Bird
By : Dahlia Trimble
Created: 2015-02-24 Edited: 2015-02-24
Worlds: Second Life

the Zip file

Download all files for llLookAtBird
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Find anyone.lsl
Get file # 2. Find owner.lsl
1 // llLookAt code original by Dahlia Trimble 02/8/2015
2 // mods by Ferd Frederix 02-24-2015
3
4
5 vector gOffset = <-2.0, 0.0, 0>;
6 integer gRunning = FALSE;
7 float gMoveSpeed = 5.0;
8 key gTargetKey = NULL_KEY;
9
10 MoveToAndLookAt()
11 {
12
13 float x = llFrand(1) - 1; // not too close - must be less than gOffset .z
14 float y = llFrand(3) - 1.5; // l-r
15 float z = llFrand(2); // up/down, lets not go too low or we bumnp the avi
16
17 vector newgOffset = gOffset + <x,y,z>; // Our new place to move to
18
19 list details = llGetObjectDetails(gTargetKey, [OBJECT_POS, OBJECT_ROT" title="View Definition" class="tooltip">OBJECT_ROT]);
20
21
22 vector pos = llList2Vector(details, 0);
23
24 if(pos == ZERO_VECTOR)
25 {
26 return;
27 }
28
29 rotation rot = llList2Rot(details, 1);
30
31 vector movePos = pos + newgOffset * rot;
32
33 float dist = llVecDist(movePos,llGetPos());
34
35 float tau = dist / (llFrand(5)+1); // D / 1-5 = from 1 to 6 meters/sec
36 if(tau < 0.5) tau = 0.5;
37
38 float turn = llFrand(2) + .2; // from .2 to 2.2 turns/sec
39
40 llLookAt(pos + <x,y,z>, turn, 0.1);
41 llMoveToTarget(movePos, tau);
42 }
43
44 default
45 {
47 {
48
50 integer j = 1;
51 for (j; j < i; j++)
52 {
53 llSetLinkPrimitiveParamsFast(j,[PRIM_PHYSICS_SHAPE_TYPE,PRIM_PHYSICS_SHAPE_NONE]);
54 }
55
57
58 gTargetKey = llGetOwner();
60 MoveToAndLookAt();
61 }
62
63 timer()
64 {
65 MoveToAndLookAt();
66 }
67
68 }

llLookAtBird

A simple Bird follower script using llLookAt and llMoveToTarget

Category: Bird
By : Dahlia Trimble
Created: 2015-02-24 Edited: 2015-02-24
Worlds: Second Life

1 // llLookAt code original by Dahlia Trimble 02/8/2015
2 // mods by Ferd Frederix 02-24-2015
3 // More mods by Ferd for finding anyone and staying in front.
4
5 vector gOffset = <2.0, 0.0, 0>;
6 key gTargetKey = NULL_KEY;
7
8 MoveToAndLookAt()
9 {
10
11 float x = llFrand(1) - 1; // not too close - must be less than gOffset .z
12 float y = llFrand(3) - 1.5; // l-r
13 float z = llFrand(2); // up/down, lets not go too low or we bumnp the avi
14
15 vector newgOffset = gOffset + <x,y,z>; // Our new place to move to
16
17 list avatars = llGetAgentList(AGENT_LIST_REGION,[]);
18 integer N = llGetListLength(avatars);
19
20 // anybody home?
21 if(! N)
22 return;
23
24 integer i;
25 list avatarList;
26
27 for (i=0; i< N; i++) {
28 gTargetKey = llList2Key(avatars,i);
29 if(! osIsNpc(gTargetKey)) {
30 list where = llGetObjectDetails(gTargetKey,[OBJECT_POS]);
31 avatarList += llVecDist(llGetPos(),llList2Vector(where,0));
32 avatarList += gTargetKey;
33 }
34 }
35
36 avatarList = llListSort(avatarList, 2,TRUE);
37 gTargetKey = llList2Key(avatarList,1);
38
39 list details = llGetObjectDetails(gTargetKey, [OBJECT_POS, OBJECT_ROT" title="View Definition" class="tooltip">OBJECT_ROT]);
40
41
42 vector pos = llList2Vector(details, 0);
43
44 if(pos == ZERO_VECTOR)
45 {
46 return;
47 }
48
49 rotation rot = llList2Rot(details, 1);
50
51 vector movePos = pos + newgOffset * rot;
52
53 float dist = llVecDist(movePos,llGetPos());
54
55 float tau = dist / (llFrand(5)+1); // D / 1-5 = from 1 to 6 meters/sec
56 if(tau < 0.5) tau = 0.5;
57
58 float turn = llFrand(2) + .2; // from .2 to 2.2 turns/sec
59
60 llLookAt(pos + <x,y,z>, turn, 0.1);
61 llMoveToTarget(movePos, tau);
62 }
63
64 default
65 {
67 {
68
70 integer j;
71 for (j=1; j < i; j++)
72 {
73 llSetLinkPrimitiveParamsFast(j,[PRIM_PHYSICS_SHAPE_TYPE,PRIM_PHYSICS_SHAPE_NONE]);
74 }
75
77
78 gTargetKey = llGetOwner();
80 MoveToAndLookAt();
81 }
82
83 timer()
84 {
85 MoveToAndLookAt();
86 }
87
88 }

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