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
Movement Random_Movement__Flight  

Random_Movement__Flight

Random_Movement__Flight

Category: Movement
By : Davy Maltz
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Random_Movement__Flight
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Random_Movement__Flight_1.lsl
1 float distanceallowance = 5; //How many meters to let the butterfly wander away from the owner.
2
3
4 FetchTarget()
5 {
6 num = llRound(llFrand(1));
7 if(num == 0) { num = 2;}
8 posneg = (integer)llList2String(mult,num);
9 targetdist = <llFrand(distanceallowance)*posneg,0,0>;
10 num = llRound(llFrand(1));
11 if(num == 0) { num = 2;}
12 posneg = (integer)llList2String(mult,num);
13 targetdist = <targetdist.x,llFrand(distanceallowance)*posneg,0>;
14 targetdist = <targetdist.x,targetdist.y,llFrand(distanceallowance)>;
15 oursize = llGetAgentSize(llGetOwner());
16 halfourheight = oursize.z / 2;
17 targetpos = <ownerpos.x,ownerpos.y,ownerpos.z - halfourheight> + targetdist;
18 if(targetpos.z < llGround(v))
19 {
20 targetpos.z = targetpos.z*-1;
21 }
22 target = llTarget(targetpos,1.0);
23 llMoveToTarget(targetpos,2.0);
24 }
25 vector v;
26 vector oursize;
27 float halfourheight;
28 integer onlyabove;
29 list mult = [1,-1];
30 integer num;
31 integer posneg;
32 vector targetdist;
33 integer target;
34 vector ownerpos;
35 vector targetpos;
36 default
37 {
38 on_rez(integer start_param)
39 {
41 }
43 {
44 llSetBuoyancy(1.0);
47 FetchTarget();
48 }
49 sensor(integer num_detected)
50 {
51 if(llVecDist(llGetPos(),targetpos) > distanceallowance)
52 {
53 FetchTarget();
54 }
55 if(ownerpos.z - llGround(v) <= 5)
56 {
57 onlyabove = TRUE;
58 }
59 if(ownerpos.z - llGround(v) > 5)
60 {
61 onlyabove = FALSE;
62 }
63 ownerpos = llDetectedPos(0);
64 llLookAt(targetpos,0.1,1.0);
65 }
66 collision_start(integer num_detected)
67 {
68 FetchTarget();
69 }
70 land_collision_start(vector pos)
71 {
72 FetchTarget();
73 }
74 at_target(integer tnum,vector targetpos,vector ourpos)
75 {
76 FetchTarget();
77 }
78 }

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