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
Rezzers multi_item_rezer  

multi_item_rezer

multi item rezer.lsl

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

the Zip file

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

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