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 Blue_Bovine_Script  

Blue_Bovine_Script

The script

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

the Zip file

Download all files for Blue_Bovine_Script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Blue_Bovine_Script_1.lsl
1 // ALife by Strick Unknown; simplified Polyworld
2 list tape;
3 integer tn;
4 integer tp;
5 string prog;
6 integer pc;
7 integer chan;
8 integer minx;
9 integer maxx;
10 integer miny;
11 integer maxy;
12 vector f1; // closest friend
13 vector f2;
14 vector f3;
15 vector A; // accumulator for interp
16 object_move_to(vector position) {
17 vector last;
18 do {
19 last = llGetPos();
20 llSetPos(position);
21 } while((llVecDist(llGetPos(),position) > 0.001) && (llGetPos() != last));
22 }
23 critter_move_offset( vector off )
24 {
25 if(llVecMag(off)>1.0) { off= llVecNorm(off);} // move at most 1 meter
26 if(llVecMag(off)>0.1) {
27 llSay(0, "off= " + (string)off );
28 // turn in direction of motion
29 vector reference; // = llRot2Left( llGetRot() );
30 reference= <0, PI/2, 0>;
31 llSay(0, "reference= " + (string)reference );
32 rotation between;// = llRotBetween( llVecNorm(off), reference );
33 between= llRotBetween( reference, llVecNorm(off) );
34 llSay(0, "between= " + (string)between );
35 llSetRot( llEuler2Rot(<0,PI/2,0>) * between );
36
38 //llSetRot( (llEuler2Rot(<0,0,PI/2>) * between) * llEuler2Rot(<0,-PI/2,0>) );
39
40 }
41 vector p= llGetPos() + off;
42 if(minx<=p.x && p.x<maxx && miny<=p.y && p.y<maxy) {
43 float z = llGround(< 0.0, 0.0, 0.0 >);
44 llSay(0, "Moving to " + (string)p );
45 object_move_to( < p.x, p.y, z+2.0 > );
46 } else {
47 llSay(0, "Cant move offset " + (string)off );
48 }
49 }
50
51 vector Tget(integer i) {
52 return llList2Vector(tape, i);
53 }
54 Tput(integer i, vector v) {
55 tape= llListReplaceList( tape, [v], i, i );
56 }
57 run_prog()
58 {
59 // initialize tape with input values
60 vector rand= < llFrand(2.0)+-1.0, llFrand(2.0)+-1.0, 0 >;
61 tape = [ f1, f2, f3, rand, <0.,0.,0.>, <1.,0.,0.>, <0.,1.,0.>, <0.,0.,1.> ];
62 tn = llGetListLength(tape);
63 tp= 0;
64 A= < 0., 0., 0. >;
65
66 // interpret program prog
67 integer n= llStringLength(prog);
68 for ( pc= 0; pc < n; pc++ ) {
69 string c= llGetSubString( prog, pc, pc );
70 //llSay(0, "Program step " + (string)pc + " : " + c );
71 if(c=="<") { tp--; if(tp<0) { tp= tn+-1;} } // regress ptr
72 else if(c==">") { tp++; if(tp>=tn) { tp= 0;} } // advance ptr
73 else if(c=="!") { Tput(tp, A); } // store
74 else if(c=="^") { A= Tget(tp); } // recall
75 else if(c=="+") { A= A + Tget(tp); } // add
76 else if(c=="-") { A= -A; } // negate
77 else if(c=="*") { A= 2.0 * A; } // double
78 else if(c=="/") { A= 0.5 * A; } // half
79 else if(c==".") { A= < A * Tget(tp), 0.0, 0.0>; } // dot product
80 else if(c=="%") { A= A % Tget(tp); } // cross product
81 }
82 // Program finished, move by tape[tp]
83 vector off= Tget(tp);
84 critter_move_offset(off);
85 }
86 default
87 {
89 {
90 llSay(0, "Hello, Avatar!");
92 }
93
94 touch_start(integer total_number)
95 {
96 state run;
97 }
98 }
99 state run
100 {
102 {
103 list tmp= llParseString2List( llGetObjectDesc(), [";"], [ ] );
104 if( 6 <= llGetListLength(tmp) ) {
105 chan= (integer)llList2String(tmp, 0);
106 minx= (integer)llList2String(tmp, 1);
107 maxx= (integer)llList2String(tmp, 2);
108 miny= (integer)llList2String(tmp, 3);
109 maxy= (integer)llList2String(tmp, 4);
110 prog= llList2String(tmp, 5);
111 } else {
112 llSay(0, "Description has not 6 fields, failing");
113 state default;
114 }
115 llSay(0, "Running...");
117
118
119 f1= <999., 999., 999.>;
120 f2= f1;
121 f3= f1;
122 llSensor(llGetObjectName(), NULL_KEY, PASSIVE | SCRIPTED, 96, PI);
123 }
124 touch_start(integer total_number)
125 {
127 state default;
128 }
129 timer()
130 {
131 f1= <999., 999., 999.>;
132 f2= f1;
133 f3= f1;
134 llSensor(llGetObjectName(), NULL_KEY, PASSIVE | SCRIPTED, 96, PI);
135 }
136 sensor(integer total_number) // total_number is the number of avatars detected.
137 {
138 llSay(0, (string)total_number + " " + llGetObjectName() + " detected" );
139 integer i;
140 vector me= llGetPos();
141 float dist1= 999.;
142 float dist2= 999.;
143 float dist3= 999.;
144 for (i = 0; i < total_number; i++)
145 {
146 vector p= llDetectedPos(i)-me;
147 llSay(0, "Hello " + llDetectedName(i) + " offset " + (string)p );
148 float mydist= llVecMag(p);
149 // remember the 3 closest
150 if(mydist<dist1) {
151 f3=f2; dist3= dist2; f2=f1; dist2= dist1; f1=p; dist1= mydist;
152 } else if(mydist<dist2) {
153 f3=f2; dist3= dist2; f2=p; dist2= mydist;
154 } else if(mydist<dist3) {
155 f3= p; dist3= mydist;
156 }
157 }
158 llSay(0, "f1= " + (string)f1 );
159 llSay(0, "f2= " + (string)f2 );
160 run_prog();
161 }
162
163 // if nobody is within 10 meters, say so.
164 no_sensor() {
165 llSay(0, "Nobody is around.");
166 run_prog();
167 }
168 }

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