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
Underwater Swimming_Fish_Rezzer  

Swimming_Fish_Rezzer

fish rezzer.lsl

Category: Underwater
By : Anonymous
Created: 2011-08-11 Edited: 2011-08-11
Worlds: Second Life

the Zip file

Download all files for Swimming_Fish_Rezzer
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Swimming_Fish_Rezzer_1.lsl
Get file # 2. Swimming_Fish_Rezzer_2.lsl
1 // Author: anonymous
2
3 // THE AMAZING
4 // TERRA(tm) FISH-O-MATIC(tm) FISH GENERATOR!!
5
6
7 integer RADIUS_MAX = 9;
8 integer HEIGHT_MAX = 18;
9 float FREQ = 5; // how often to change target location
10
11 integer chanDlg;
12 integer chanFish = 10; // fish listen on this channel
13
14 integer numFish;
15 integer radius = 2; // radius around rezzer
16 integer height = 10; // max height of fish target -- meters relative to rezzer
17 integer lstn;
18
19 vector myPos;
20 vector target;
21
22
23 list fishTypes;
24
25 key owner;
26
27
28
29 vector chooseTarget()
30 {
31 myPos = llGetPos();
32 vector offset;
33 vector thisTarget;
34 offset.x = llFrand(2 * radius) - radius; // x/y offset can be negative
35 offset.y = llFrand(2 * radius) - radius;
36 offset.z = llFrand(height) + 0.5;
37 thisTarget = myPos + offset;
38 return thisTarget;
39 }
40
41
42 getFishTypes()
43 {
44 fishTypes = [];
45 integer i;
47 for (i = 0; i < numFish; i++)
48 {
49 fishTypes += [llGetInventoryName(INVENTORY_OBJECT,i)];
50 }
51 }
52
53 init()
54 {
55 chanDlg = (integer)(llFrand(10000)+1000); // random chat channel to avoid interference
56 owner = llGetOwner();
57 if(lstn)
58 {
59 llListenRemove(lstn);
60 lstn = 0;
61 }
62 lstn = llListen(chanDlg,"", owner, "");
63 myPos = llGetPos();
64 llOwnerSay("Click me to set the options.");
65 }
66
67 menu()
68 {
69 string txt = "SET UP THE FISHIES!\n\tMax height: "+(string)height+"m above rezzer\n\tHorizontal radius: "+(string)radius+"m";
70
71 list buttons = ["Radius -","Height -","DELETE","Radius +", "Height +"] + fishTypes;
72
73 llDialog(owner,txt,buttons,chanDlg);
74 }
75
76 rezFish(string name)
77 {
78 llOwnerSay("Rezzing 1 "+name+".");
79 llRezObject(name, chooseTarget(), ZERO_VECTOR, ZERO_ROTATION, 0);
80 llSetTimerEvent(FREQ);
81 }
82
83 killFish()
84 {
85 llOwnerSay("Deleting all nearby fish.");
86 llSay(chanFish,"die");
88 }
89
90
91
92 default
93 {
95 {
96 init();
97 }
98
99 on_rez(integer num)
100 {
102 }
103
105 {
106 getFishTypes();
107 integer i;
108 key agent = llDetectedKey(i);
109 if(agent == owner)
110 {
111 menu();
112 }
113 }
114
115 listen(integer channel, string name, key id, string message)
116 {
117 if(message == "DELETE")
118 {
119 killFish();
120 }
121 else if(message == "Radius +")
122 {
123 if(radius < RADIUS_MAX)
124 {
125 radius++;
126 }
127 else llOwnerSay("Radius is already at the maximum of "+(string)RADIUS_MAX+" meters.");
128 menu();
129
130 }
131 else if(message == "Radius -")
132 {
133 if(radius > 0)
134 {
135 radius--;
136 }
137 menu();
138 }
139 else if(message == "Height +")
140 {
141 if(height < HEIGHT_MAX)
142 {
143 height++;
144 }
145 else llOwnerSay("Height is already at the maximum of "+(string)HEIGHT_MAX+" meters.");
146 menu();
147 }
148 else if(message == "Height -")
149 {
150 if(height > 0)
151 {
152 height--;
153 }
154 menu();
155 }
156 else if(llGetInventoryType(message) >= INVENTORY_OBJECT) // returns -1 if object of that name doesn't exist
157 {
158 rezFish(message);
159 menu();
160 }
161 }
162
163 timer()
164 {
165 integer i;
166 for (i = 0; i < numFish; i++)
167 {
168 vector t = chooseTarget();
169 //target,<fish name>,<x>,<y>,<z>
170 llSay(chanFish,"target,"+llList2String(fishTypes,i)+","+(string)t.x+","+(string)t.y+","+(string)t.z); // tell fish where to swarm
171 }
172
173 }
174
175
176 }// END //

Swimming_Fish_Rezzer

Fish script

Category: Underwater
By : Anonymous
Created: 2011-08-11 Edited: 2011-08-11
Worlds: Second Life

1 // swimming swim script for use with the FISH-O-Matic
2
3 integer chanFish = 10; // fish listen on this channel
4 vector dest;
5
6 default
7 {
9 {
10 llListen(chanFish, "", "", "" );
11 }
12
13 listen(integer channel, string name, key id, string message)
14 {
15
16 list cmds = llParseString2List( message, [","], [""] );
17 string cmd = llList2String(cmds,0);
18 if(cmd == "die")
19 llDie();
20 else if(cmd == "target")
21 {
22 string name = llList2String(cmds,1);
23
24 if( name != llGetObjectName() )
25 return;
26
27 string X= llList2String(cmds,2);
28 string Y= llList2String(cmds,3);
29 string Z= llList2String(cmds,4);
30
31 dest = <(float) X,(float) Y,(float) Z>;
32
33 llSetTimerEvent(0.5); // swim every half second. The slower this is, the more fish-like
35 }
36 }
37
38 timer()
39 {
40 llLookAt(dest,0.5,0.2);
41 llMoveToTarget(dest,5); // go there in 5 seconds
42 }
43
44 on_rez(integer start_num)
45 {
47 }
48 }

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