aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine/OSSL_ScriptCommands.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/OSSL_ScriptCommands.cs553
1 files changed, 553 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/OSSL_ScriptCommands.cs b/OpenSim/Region/ScriptEngine/XEngine/OSSL_ScriptCommands.cs
new file mode 100644
index 0000000..bc4e8ba
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/XEngine/OSSL_ScriptCommands.cs
@@ -0,0 +1,553 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using Axiom.Math;
29using libsecondlife;
30using Nini.Config;
31using OpenSim.Framework.Console;
32using OpenSim.Region.Environment.Interfaces;
33using OpenSim.Region.Environment.Scenes;
34using OpenSim.Region.ScriptEngine.XEngine.Script;
35
36namespace OpenSim.Region.ScriptEngine.XEngine
37{
38 [Serializable]
39 public class OSSL_ScriptCommands : MarshalByRefObject, IOSSL_ScriptCommands
40 {
41 internal XEngine m_ScriptEngine;
42 internal XScriptInstance m_Instance;
43 internal SceneObjectPart m_host;
44 internal uint m_localID;
45 internal LLUUID m_itemID;
46
47 public OSSL_ScriptCommands(XEngine scriptEngine,
48 XScriptInstance instance, SceneObjectPart host,
49 uint localID, LLUUID itemID)
50 {
51 m_ScriptEngine = scriptEngine;
52 m_Instance = instance;
53 m_host = host;
54 m_localID = localID;
55 m_itemID = itemID;
56 }
57
58
59 //
60 // OpenSim functions
61 //
62
63 public int osTerrainSetHeight(int x, int y, double val)
64 {
65 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
66 {
67 OSSLError("osTerrainSetHeight: permission denied");
68 return 0;
69 }
70
71 m_host.AddScriptLPS(1);
72 if (x > 255 || x < 0 || y > 255 || y < 0)
73 OSSLError("osTerrainSetHeight: Coordinate out of bounds");
74
75 if (World.ExternalChecks.ExternalChecksCanTerraformLand(m_host.OwnerID, new LLVector3(x, y, 0)))
76 {
77 World.Heightmap[x, y] = val;
78 return 1;
79 }
80 else
81 {
82 return 0;
83 }
84 }
85
86 public double osTerrainGetHeight(int x, int y)
87 {
88 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
89 {
90 OSSLError("osTerrainGetHeight: permission denied");
91 return 0.0;
92 }
93
94 m_host.AddScriptLPS(1);
95 if (x > 255 || x < 0 || y > 255 || y < 0)
96 OSSLError("osTerrainGetHeight: Coordinate out of bounds");
97
98 return World.Heightmap[x, y];
99 }
100
101 public int osRegionRestart(double seconds)
102 {
103 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
104 {
105 OSSLError("osRegionRestart: permission denied");
106 return 0;
107 }
108
109 m_host.AddScriptLPS(1);
110 if (World.ExternalChecks.ExternalChecksCanIssueEstateCommand(m_host.OwnerID))
111 {
112 World.Restart((float)seconds);
113 return 1;
114 }
115 else
116 {
117 return 0;
118 }
119 }
120
121 public void osRegionNotice(string msg)
122 {
123 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
124 {
125 OSSLError("osRegionNotice: permission denied");
126 return;
127 }
128
129 m_host.AddScriptLPS(1);
130 World.SendGeneralAlert(msg);
131 }
132
133 public void osSetRot(LLUUID target, Quaternion rotation)
134 {
135 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
136 {
137 OSSLError("osSetRot: permission denied");
138 return;
139 }
140
141 m_host.AddScriptLPS(1);
142 if (World.Entities.ContainsKey(target))
143 {
144 World.Entities[target].Rotation = rotation;
145 }
146 else
147 {
148 OSSLError("osSetRot: Invalid target");
149 }
150 }
151
152 public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
153 int timer)
154 {
155 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
156 {
157 OSSLError("osSetDynamicTextureURL: permission denied");
158 return String.Empty;
159 }
160
161 m_host.AddScriptLPS(1);
162 if (dynamicID == String.Empty)
163 {
164 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
165 LLUUID createdTexture =
166 textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
167 extraParams, timer);
168 return createdTexture.ToString();
169 }
170 else
171 {
172 //TODO update existing dynamic textures
173 }
174
175 return LLUUID.Zero.ToString();
176 }
177
178 public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
179 int timer, int alpha)
180 {
181 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
182 {
183 OSSLError("osSetDynamicTextureURLBlend: permission denied");
184 return String.Empty;
185 }
186
187 m_host.AddScriptLPS(1);
188 if (dynamicID == String.Empty)
189 {
190 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
191 LLUUID createdTexture =
192 textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
193 extraParams, timer, true, (byte) alpha);
194 return createdTexture.ToString();
195 }
196 else
197 {
198 //TODO update existing dynamic textures
199 }
200
201 return LLUUID.Zero.ToString();
202 }
203
204 public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
205 int timer)
206 {
207 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
208 {
209 OSSLError("osSetDynamicTextureData: permission denied");
210 return String.Empty;
211 }
212
213 m_host.AddScriptLPS(1);
214 if (dynamicID == String.Empty)
215 {
216 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
217 if (textureManager != null)
218 {
219 LLUUID createdTexture =
220 textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data,
221 extraParams, timer);
222 return createdTexture.ToString();
223 }
224 }
225 else
226 {
227 //TODO update existing dynamic textures
228 }
229
230 return LLUUID.Zero.ToString();
231 }
232
233 public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
234 int timer, int alpha)
235 {
236 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
237 {
238 OSSLError("osSetDynamicTextureDataBlend: permission denied");
239 return String.Empty;
240 }
241
242 m_host.AddScriptLPS(1);
243 if (dynamicID == String.Empty)
244 {
245 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
246 if (textureManager != null)
247 {
248 LLUUID createdTexture =
249 textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data,
250 extraParams, timer, true, (byte) alpha);
251 return createdTexture.ToString();
252 }
253 }
254 else
255 {
256 //TODO update existing dynamic textures
257 }
258
259 return LLUUID.Zero.ToString();
260 }
261
262 public bool osConsoleCommand(string command)
263 {
264 m_host.AddScriptLPS(1);
265 if (m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowosConsoleCommand", false))
266 {
267 if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID))
268 {
269 MainConsole.Instance.RunCommand(command);
270 return true;
271 }
272 return false;
273 }
274 return false;
275 }
276 public void osSetPrimFloatOnWater(int floatYN)
277 {
278 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
279 {
280 OSSLError("osSetPrimFloatOnWater: permission denied");
281 return;
282 }
283
284 m_host.AddScriptLPS(1);
285 if (m_host.ParentGroup != null)
286 {
287 if (m_host.ParentGroup.RootPart != null)
288 {
289 m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN);
290 }
291 }
292 }
293
294 // Adam's super super custom animation functions
295 public void osAvatarPlayAnimation(string avatar, string animation)
296 {
297 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
298 {
299 OSSLError("osAvatarPlayAnimation: permission denied");
300 return;
301 }
302
303 m_host.AddScriptLPS(1);
304 if (World.Entities.ContainsKey(avatar) && World.Entities[avatar] is ScenePresence)
305 {
306 ScenePresence target = (ScenePresence)World.Entities[avatar];
307 target.AddAnimation(avatar);
308 }
309 }
310
311 public void osAvatarStopAnimation(string avatar, string animation)
312 {
313 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
314 {
315 OSSLError("osAvatarStopAnimation: permission denied");
316 return;
317 }
318
319 m_host.AddScriptLPS(1);
320 if (World.Entities.ContainsKey(avatar) && World.Entities[avatar] is ScenePresence)
321 {
322 ScenePresence target = (ScenePresence)World.Entities[avatar];
323 target.RemoveAnimation(animation);
324 }
325 }
326
327 //Texture draw functions
328 public string osMovePen(string drawList, int x, int y)
329 {
330 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
331 {
332 OSSLError("osMovePen: permission denied");
333 return String.Empty;
334 }
335
336 m_host.AddScriptLPS(1);
337 drawList += "MoveTo " + x + "," + y + ";";
338 return drawList;
339 }
340
341 public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
342 {
343 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
344 {
345 OSSLError("osDrawLine: permission denied");
346 return String.Empty;
347 }
348
349 m_host.AddScriptLPS(1);
350 drawList += "MoveTo "+ startX+","+ startY +"; LineTo "+endX +","+endY +"; ";
351 return drawList;
352 }
353
354 public string osDrawLine(string drawList, int endX, int endY)
355 {
356 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
357 {
358 OSSLError("osDrawLine: permission denied");
359 return String.Empty;
360 }
361
362 m_host.AddScriptLPS(1);
363 drawList += "LineTo " + endX + "," + endY + "; ";
364 return drawList;
365 }
366
367 public string osDrawText(string drawList, string text)
368 {
369 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
370 {
371 OSSLError("osDrawText: permission denied");
372 return String.Empty;
373 }
374
375 m_host.AddScriptLPS(1);
376 drawList += "Text " + text + "; ";
377 return drawList;
378 }
379
380 public string osDrawEllipse(string drawList, int width, int height)
381 {
382 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
383 {
384 OSSLError("osDrawEllipse: permission denied");
385 return String.Empty;
386 }
387
388 m_host.AddScriptLPS(1);
389 drawList += "Ellipse " + width + "," + height + "; ";
390 return drawList;
391 }
392
393 public string osDrawRectangle(string drawList, int width, int height)
394 {
395 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
396 {
397 OSSLError("osDrawRectangle: permission denied");
398 return String.Empty;
399 }
400
401 m_host.AddScriptLPS(1);
402 drawList += "Rectangle " + width + "," + height + "; ";
403 return drawList;
404 }
405
406 public string osDrawFilledRectangle(string drawList, int width, int height)
407 {
408 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
409 {
410 OSSLError("osDrawFilledRectangle: permission denied");
411 return String.Empty;
412 }
413
414 m_host.AddScriptLPS(1);
415 drawList += "FillRectangle " + width + "," + height + "; ";
416 return drawList;
417 }
418
419 public string osSetFontSize(string drawList, int fontSize)
420 {
421 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
422 {
423 OSSLError("osSetFontSize: permission denied");
424 return String.Empty;
425 }
426
427 m_host.AddScriptLPS(1);
428 drawList += "FontSize "+ fontSize +"; ";
429 return drawList;
430 }
431
432 public string osSetPenSize(string drawList, int penSize)
433 {
434 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
435 {
436 OSSLError("osSetPenSize: permission denied");
437 return String.Empty;
438 }
439
440 m_host.AddScriptLPS(1);
441 drawList += "PenSize " + penSize + "; ";
442 return drawList;
443 }
444
445 public string osSetPenColour(string drawList, string colour)
446 {
447 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
448 {
449 OSSLError("osSetPenColour: permission denied");
450 return String.Empty;
451 }
452
453 m_host.AddScriptLPS(1);
454 drawList += "PenColour " + colour + "; ";
455 return drawList;
456 }
457
458 public string osDrawImage(string drawList, int width, int height, string imageUrl)
459 {
460 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
461 {
462 OSSLError("osDrawImage: permission denied");
463 return String.Empty;
464 }
465
466 m_host.AddScriptLPS(1);
467 drawList +="Image " +width + "," + height+ ","+ imageUrl +"; " ;
468 return drawList;
469 }
470
471 public void osSetStateEvents(int events)
472 {
473 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
474 {
475 OSSLError("osSetStateEvents: permission denied");
476 return;
477 }
478
479 m_host.SetScriptEvents(m_itemID, events);
480 }
481
482 public void osSetRegionWaterHeight(double height)
483 {
484 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
485 {
486 OSSLError("osSetRegionWaterHeight: permission denied");
487 return;
488 }
489
490 m_host.AddScriptLPS(1);
491 //Check to make sure that the script's owner is the estate manager/master
492 //World.Permissions.GenericEstatePermission(
493 if (World.ExternalChecks.ExternalChecksCanBeGodLike(m_host.OwnerID))
494 {
495 World.EventManager.TriggerRequestChangeWaterHeight((float)height);
496 }
497 }
498
499 public double osList2Double(LSL_Types.list src, int index)
500 {
501 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
502 {
503 OSSLError("osList2Double: permission denied");
504 return 0.0;
505 }
506
507 m_host.AddScriptLPS(1);
508 if (index < 0)
509 {
510 index = src.Length + index;
511 }
512 if (index >= src.Length)
513 {
514 return 0.0;
515 }
516 return Convert.ToDouble(src.Data[index]);
517 }
518
519 public void osSetParcelMediaURL(string url)
520 {
521 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
522 {
523 OSSLError("osSetParcelMediaURL: permission denied");
524 return;
525 }
526
527 m_host.AddScriptLPS(1);
528 LLUUID landowner = World.GetLandOwner(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
529
530 if (landowner == LLUUID.Zero)
531 {
532 return;
533 }
534
535 if (landowner != m_host.ObjectOwner)
536 {
537 return;
538 }
539
540 World.SetLandMediaURL(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, url);
541 }
542
543 public Scene World
544 {
545 get { return m_ScriptEngine.World; }
546 }
547
548 internal void OSSLError(string msg)
549 {
550 throw new Exception("OSSL Runtime Error: " + msg);
551 }
552 }
553}