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
Radar Radar_Controller_w_on_off_toggle  

Radar_Controller_w_on_off_toggle

Radar Controller w on_off toggle.lsl

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

the Zip file

Download all files for Radar_Controller_w_on_off_toggle
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Radar_Controller_w_on_off_toggle_1.lsl
1
2 float scanWeather = 0.1;
3 float scanAirTraffic = 1;
4 float scanTactical = 5;
5 integer notify = 1;
6 integer interval = 30;
7 integer range = 300;
8 string radarID="";
9 key id;
10 float rotSpeed;
11
12 //commands for on/off toggle
13 string gOff= "radaroff";
14 string gOn = "radaron";
15
16 default
17 {
19 {
20 key owner = llGetOwner();
21 //listen for owner to turn on
22 llListen(0,"",owner,gOn);
23 }
24
25 listen(integer channel, string name, key id, string message)
26 {
27 if(message == gOn)
28 {
29 state ON;
30 }
31 }
32 }
33
34 state ON
35 {
37 {
38 key owner = llGetOwner();
39 // Figure out who owns me and listen to them
40 llListen(0,"",owner,"");
41
42 //listen for owner to turn off
43 llListen(0,"",owner,gOff);
44
45 // Set up initial rotation
46 rotSpeed = scanAirTraffic;
47 llTargetOmega(<0,0,1>, rotSpeed, 0);
48
49 // Turn on sensor
50 if(notify==1)
51 llSensorRepeat("","",AGENT,range,PI,interval);
52 }
53
54 // Handle sensor events (if turned on)
55 sensor(integer n) {
56 integer i;
57 string preamble;
58 vector pos;
59 vector me = llGetPos();
60 integer dist;
62 string dt =
63 (string)((t/3600)%24)
64 +":"
65 +(string)((t%3600)/60)
66 +":"
67 +(string)(t%60);
68 string iSee = " ";
69 for(i=0; i<n; i++) {
70 pos = llDetectedPos(i);
71 dist = (integer)llVecDist(me, pos);
72 iSee += " ["+llDetectedName(i)+" @ "+(string)dist+"M] ";
73 }
74 if(radarID!="")
75 preamble="["+radarID+"] : ";
76 else
77 preamble = "";
78 key owner = llGetOwner();
79 llInstantMessage(owner, preamble+iSee);
80 }
81
82 // Listen for instructions
83 listen(integer channel, string name, key id, string message) {
84 float magnitude = 2;
85 rotSpeed = -1;
86 list cmd = llParseString2List(message, [" "], []);
87 string auth = llList2String(cmd, 0);
88
89 if(message == gOff)
90 {
92 }
93
94 if(id != llGetOwner()) {
95 //string op = llToUpper(llList2String(cmd, 0));
96 //llSay(0, op+" NAK: Control by non-owners is forbidden.");
97 return;
98 }
99
100 // Handle 'factory'
101 if(auth=="factory") {
102 llSay(0, "FACTORY ACK: Resetting to factory defaults.");
104 // This stuff is obsolete, oh well
105 notify = 1;
106 interval = 60;
107 range = 96;
108 radarID="";
109 rotSpeed = scanAirTraffic;
110 llTargetOmega(<0,0,1>, rotSpeed, 2);
112 llSensorRepeat("","",AGENT,range,PI,interval);
113 }
114
115 // Handle 'scanctl x y'
116 if(auth=="scanctl") {
117 integer scanset=0;
118 string scan = llList2String(cmd, 1);
119 if(scan=="on") {
121 llSensorRepeat("","",AGENT,range,PI,interval);
122 scan="Enable scanner";
123 scanset=1;
124 }
125 if(scan=="off") {
127 scan="Disable scanner";
128 scanset=1;
129 }
130 if(scan=="interval") {
131 interval = llList2Integer(cmd, 2);
132 scan="Set interval "+(string)interval+" and enable scanner";
134 llSensorRepeat("","",AGENT,range,PI,interval);
135 scanset=1;
136 }
137 if(scan=="range") {
138 range = llList2Integer(cmd, 2);
139 scan="Set range "+(string)range+" and enable scanner";
141 llSensorRepeat("","",AGENT,range,PI,interval);
142 scanset=1;
143 }
144 if(scan=="name") {
145 radarID = llList2String(cmd, 2);
146 scan="Set name '"+radarID+"'";
147 scanset=1;
148 }
149 if(scanset!=1) {
150 llSay(0, "SCANCTL: Try 'on', 'off', 'name xyz', 'interval x' (seconds), or 'range x' (0-96).");
151 } else {
152 llSay(0, "SCANCTL ACK: ["+scan+"]");
153 }
154 }
155
156 // Handle 'radarctl x y z'
157 if(auth=="radarctl") {
158 string speed = llList2String(cmd, 1);
159 if(speed=="Weather")
160 rotSpeed = scanWeather;
161 if(speed=="AirTraffic")
162 rotSpeed = scanAirTraffic;
163 if(speed=="Tactical")
164 rotSpeed = scanTactical;
165 if(speed=="stop")
166 rotSpeed = 0;
167 if(speed=="speed") {
168 rotSpeed = llList2Float(cmd, 2);
169 speed = "Set speed "+(string)rotSpeed;
170 }
171 if(rotSpeed == -1) {
172 llSay(0, "RADARCTL: Try 'Weather', 'AirTraffic', 'Tactical', 'stop', or 'speed n.nn'.");
173 }
174 if(rotSpeed >= 0) {
175 llSay(0, "RADARCTL ACK: ["+speed+"]");
176 if(rotSpeed==0)
177 magnitude = 0;
178 llTargetOmega(<0,0,1>, rotSpeed, magnitude);
179 }
180 }
181 }
182 }// END //

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