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
Sim Feedback Sim Stats  

Sim Stats

Reports sim stats as a HUD

Category: Sim Feedback
By : Ariane Brodie
Created: 2010-01-10 Edited: 2014-02-15
Worlds: Second Life

the Zip file

Download all files for Sim Stats
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Sim stats HUD.lsl
1 //
2
3 string TitleName = ""; //default title
4 integer TitleMode = 1; //default mode
5 string alist;
6
7 float tz = -7;
8 integer mil = 0;
9
10
11 integer Count; // counter for averaging FPS
12 integer FPS_Total; // total fps for averaging
13
14 string clock(float timezone, integer military)
15 {
16 integer raw = (integer)(llGetGMTclock() + (timezone * 3600));
17 integer shiftraw = raw;
18 if((timezone * 3600) + raw > 86400)
19 {
20 shiftraw = raw - 86400;
21 }
22 else if((timezone * 3600) + raw < 0)
23 {
24 shiftraw = raw + 86400;
25 }
26 integer hours = shiftraw / 3600;
27 integer minutes = (shiftraw % 3600) / 60;
28 integer seconds = shiftraw % 60;
29 string ampm;
30 //non-military time adjustments
31 if(!military)
32 {
33 if(shiftraw < 43200)
34 {
35 ampm = " AM";
36 }
37 else
38 {
39 ampm = " PM";
40 hours -= 12;
41 }
42 }
43 string shours = (string)hours;
44 string sminutes = (string)minutes;
45 string sseconds = (string)seconds;
46
47 //add zeros to single digit minutes/seconds
48 if(llStringLength(sminutes) == 1)
49 {
50 sminutes = "0" + sminutes;
51 }
52 if(llStringLength(sseconds) == 1)
53 {
54 sseconds = "0" + sseconds;
55 }
56 string time = "real time: " + shours + ":" + sminutes + ":" + sseconds + ampm;
57 //the following will time stamp the data sent using SL time.
58 raw = (integer)llGetTimeOfDay();
59 minutes = raw/60;
60 integer mintill;
61 string suntime = "";
62 if(minutes < 30) {
63 mintill = 30 - minutes;
64 suntime = (string)mintill + " min till Sunrise";
65 }
66 if(minutes == 30)
67 suntime = "Sunrise";
68 if(minutes > 30) {
69 mintill = 210 - minutes;
70 suntime = (string)mintill + " min till Sunset";
71 }
72 if(minutes == 210)
73 suntime = "Sunset";
74 if(minutes > 210){
75 mintill = 270 - minutes;
76 suntime = (string)mintill + " min till Sunrise";
77 }
78 shours = "0"+(string)((raw/3600)%4);
79 integer len = llStringLength(shours);
80 shours = llGetSubString(shours, len - 2, len - 1);
81 sminutes = "0"+(string)((raw%3600)/60);
82 len = llStringLength(sminutes);
83 sminutes = llGetSubString(sminutes, len - 2, len - 1);
84 sseconds = "0"+(string)(raw%60);
85 len = llStringLength(sseconds);
86 sseconds = llGetSubString(sseconds, len - 2, len - 1);
87 time = time+"\nsim time: "+shours + ":" + sminutes + ":" + sseconds + "\n" + suntime;
88 return time;
89 }
90
91 string positionData()
92 {
93 vector pos = llGetPos();
94 float currentSpeed = llVecMag(llGetVel()) * 3.6;
95
96 return "You are at: " + llGetRegionName() + " (" + (string)((integer)pos.x) + ", " + (string)((integer)pos.y) + ") \nHeight: " + (string)((integer)pos.z) + " \nSpeed: " + (string)((integer)currentSpeed) +"km/h";
97 }
98 integer CommandIs(string msg,string cmd)
99 {
100 return llSubStringIndex(msg,cmd) == 0;
101 }
102 ParseAndIssueCommand(string cmd)
103 {
104
105 if(CommandIs(cmd,"title"))
106 {
107 TitleMode = 1;
108 string name = llGetSubString(cmd,6,-1);
109 TitleName = name;
110 if(name == "title")
111 llSetText("",<0,1,0>,1.0);
112 else
113 llSetText(name,<0,1,0>,1.0);
114 }
115
116 if(cmd == "scan")
117 TitleMode = 2;
118 if(cmd == "time")
119 TitleMode = 3;
120 if(cmd == "pos")
121 TitleMode = 4;
122 if(cmd == "ani")
123 TitleMode = 5;
124 if(cmd == "lag")
125 TitleMode = 6;
126 if(cmd == "to" || cmd == "toff") {
127 TitleMode = 1;
128 llSetText("",<0,1,0>,1.0);
129 }
130 if(cmd == "ton"){
131 TitleMode = 1;
132 llSetText(TitleName,<0,1,0>,1.0);
133 }
134 }
135
136 default
137 {
139 {
140 llListen(2,"",llGetOwner(),"");
141 llSensorRepeat("","",AGENT,96,PI,1);
142 llSetTimerEvent(1.0);
143 }
144 on_rez(integer start_param)
145 {
147 }
148 listen(integer channel, string name, key id, string msg)
149 {
150 ParseAndIssueCommand(msg);
151 }
152
153 sensor(integer n)
154 {
155 //TitleMode 1 = Title
156 //TitleMode 2 = Scan
157 if(TitleMode == 2) {
158 integer i;
159 vector pos;
160 vector targetPos = llGetPos();
161 integer dist;
162 string iSee = "";
163 for(i=0; i<n; i++) {
165 pos = llDetectedPos(i);
166 dist = (integer)llVecDist(pos, targetPos);
167 iSee += "[1:"+llDetectedName(i)+" @ "+(string)dist+"M]\n";
168 }
169 }
170 llSetText(iSee,<1,1,1>,1.0);
171 }
172 }
173
174 no_sensor()
175 {
176 if(TitleMode == 2)
177 llSetText("",<1,1,1>,1.0);
178 }
179
180 timer()
181 {
182 //TitleMode 3 = Time
183 if(TitleMode == 3)
184 llSetText(clock(tz,mil),<0,0,1>,1.0);
185 //TitleMode 4 = Position
186 if(TitleMode == 4)
187 llSetText(positionData(),<1,0,0>,1.0);
188 //TitleMode 5 = Animation View
189 if(TitleMode == 5){
190 alist = llGetAnimation(llGetOwner()); // get the current animation state
191 llSetText(alist, <0, 1, 1>, 1.0); // display it as floating text
192 }
193 //TitleMode 6 = Lag
194 if(TitleMode == 6) {
195 Count += 1;
196 integer RegFPS = llFloor(llGetRegionFPS());
197 FPS_Total += RegFPS;
198 integer avgFPS = FPS_Total / Count;
199 string avg = (string)avgFPS;
200 string fps_condition;
201 string dil_cond;
202 if(RegFPS >= 1000)
203 {
204 fps_condition = "(Incredible!)";
205 }
206 else if(RegFPS >= 500)
207 {
208 fps_condition = "(Great!)";
209 }
210 else if(RegFPS > 400)
211 {
212 fps_condition = "(Good!)";
213 }
214 else if(RegFPS > 300)
215 {
216 fps_condition = "(Fair)";
217 }
218 else if(RegFPS > 200)
219 {
220 fps_condition = "(Could be better)";
221 }
222 else if(RegFPS > 100)
223 {
224 fps_condition = "(Sucky)";
225 }
226 else if(RegFPS > 50)
227 {
228 fps_condition = "(Start Praying)";
229 }
230 else
231 {
232 fps_condition = "(OMG this Server BLOWS)";
233 }
234 string RegName = llGetRegionName();
236 if(TimeDil >= 0.96)
237 {
238 dil_cond = "(Sim is Stable)";
239 }
240 else if(TimeDil >= 0.90)
241 {
242 dil_cond = "(Sim is Hiccuping)";
243 }
244 else if(TimeDil >= 0.80)
245 {
246 dil_cond = "(Sim is Lagging)";
247 }
248 else if(TimeDil >= 0.60)
249 {
250 dil_cond = "(Potential Sim Crash!)";
251 }
252 else
253 {
254 dil_cond = "(Sim is DOOMED!)";
255 }
256 string s_count = (string)Count;
257 llSetText("Sim = "+RegName+"\nFPS = "+(string)RegFPS+" "+fps_condition+" (Avg: "+avg+")\nDil = "+(string)TimeDil+" "+dil_cond+"\nPolls: "+s_count,<1,1,0>,1.0);
258 }
259 }
260 }

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