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 Open_Shifting_Float_and_Follow_Script  

Open_Shifting_Float_and_Follow_Script

Open Shifting Float and Follow Script, by Foolish Frost.lsl

Category: Pet
By : Foolish Frost
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Open_Shifting_Float_and_Follow_Script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Open_Shifting_Float_and_Follow_Scri_1.lsl
1
2 ////////////////////////////////////////////////////////////////////////
3 // Open Shifting Float and Follow Script, by Foolish Frost. //
4 // From Open Basic Follower/Facing Script, by Logan Bauer. //
5 ///////////////////////////////////////////////////////////////////////
6 // OFFSET is the position of your pet in relation to it's owner's position.
7 // For example, in the default setting below, "vector offset =<-1,0,1>;"
8 // I.E. (x,y,z), the -1 puts it 1m back behind owner, the 0 means don't have
9 // it stay left or right, and 1 means have it stay 1m above it's owner.
10 // So, if you wanted the script to make it follow directly in front of you,
11 // and to the left, then you would change it to "vector offset =<1,1,0>;"
12
13
14 // llFrand(float max)
15
16 vector offset =<-1.2,0,1>;
17 vector currentoffset =<0,0,0>;
18 float xshift =.2; //How far it roams forward and back.
19 float yshift =1.25; //How wide it roams left to right.
20 float bob =2; //multiplyer of the BobCycle listed below.
21 float shifttime =5; //average time it takes to shift to another XY position.
22 integer timeset=0; //Is the timer running?
23 float currentxshift =0; //current X shift position
24 float currentyshift =0; //current Y shift position
25 float currentyfacing =0; //currentyfacing storage
26 integer currentbob; //current state of the BobCycle
27 float bobbing =0; //bob storage
28 list BobCycle = [0.0, 0.08, 0.12, 0.14, 0.15, 0.14, 0.12, 0.08, 0.0, -0.08, -0.12, -0.14, -0.15, -0.14, -0.12, -0.08];
29
30
31 startup()
32 {
33 vector pos = llGetPos();
34 llSetStatus(STATUS_ROTATE_Z,TRUE);
36 key id = llGetOwner();
38 llSensorRepeat("",llGetOwner(),AGENT,200,2*PI,.5);
39 }
40
41 default
42 {
44 {
45 startup();
46
47
48 }
49
50 on_rez(integer start_param)
51 {
52 startup();
53 }
54
55 sensor(integer total_number)
56 {
57 vector pos = llDetectedPos(0);
58
59 bobbing = llList2Float(BobCycle, currentbob)*bob;
60
61 llSetTimerEvent(llFrand(shifttime));
62 currentoffset = <currentxshift, currentyshift, bobbing>;
63 llMoveToTarget(pos+(offset+currentoffset)*llDetectedRot(0),.3);
64 if(currentyshift>=0)
65 {
66 currentyfacing = currentyshift;
67 } else {
68 currentyfacing = currentyshift*-1;
69 }
70
71 llLookAt(pos+<0,0+(currentyfacing*.33),1+bobbing>, 1 , 2);
72
73 currentbob = currentbob +1;
74 if(currentbob == 16)
75 {
76 currentbob = 0;
77 }
78
79 if(timeset==0)
80 {
81 timeset = 1;
82 llSetTimerEvent(((llFrand(shifttime)+llFrand(shifttime)+llFrand(shifttime))/3)*2);
83 }
84
85
86 }
87
88 timer()
89 {
90 timeset = 0;
91 currentyshift = llFrand(yshift*2)-yshift;
92 currentxshift = llFrand(xshift*2)-xshift;
93 }
94 }// END //

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