aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs305
1 files changed, 12 insertions, 293 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index 4192d40..c00254d 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -52,11 +52,11 @@ namespace OpenSim.Region.ScriptEngine.Common
52 { 52 {
53 // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 53 // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
54 54
55 private ScriptEngineBase.ScriptEngine m_ScriptEngine; 55 internal ScriptEngineBase.ScriptEngine m_ScriptEngine;
56 private SceneObjectPart m_host; 56 internal SceneObjectPart m_host;
57 private uint m_localID; 57 internal uint m_localID;
58 private LLUUID m_itemID; 58 internal LLUUID m_itemID;
59 private bool throwErrorOnNotImplemented = true; 59 internal bool throwErrorOnNotImplemented = true;
60 60
61 public LSL_BuiltIn_Commands(ScriptEngineBase.ScriptEngine ScriptEngine, SceneObjectPart host, uint localID, LLUUID itemID) 61 public LSL_BuiltIn_Commands(ScriptEngineBase.ScriptEngine ScriptEngine, SceneObjectPart host, uint localID, LLUUID itemID)
62 { 62 {
@@ -5303,317 +5303,36 @@ namespace OpenSim.Region.ScriptEngine.Common
5303 return new LSL_Types.list(); 5303 return new LSL_Types.list();
5304 } 5304 }
5305 5305
5306 //
5307 // OpenSim functions
5308 //
5309
5310 public int osTerrainSetHeight(int x, int y, double val)
5311 {
5312 m_host.AddScriptLPS(1);
5313 if (x > 255 || x < 0 || y > 255 || y < 0)
5314 LSLError("osTerrainSetHeight: Coordinate out of bounds");
5315
5316 if (World.PermissionsMngr.CanTerraform(m_host.OwnerID, new LLVector3(x, y, 0)))
5317 {
5318 World.Heightmap[x, y] = val;
5319 return 1;
5320 }
5321 else
5322 {
5323 return 0;
5324 }
5325 }
5326
5327 public double osTerrainGetHeight(int x, int y)
5328 {
5329 m_host.AddScriptLPS(1);
5330 if (x > 255 || x < 0 || y > 255 || y < 0)
5331 LSLError("osTerrainGetHeight: Coordinate out of bounds");
5332
5333 return World.Heightmap[x, y];
5334 }
5335
5336 public int osRegionRestart(double seconds)
5337 {
5338 m_host.AddScriptLPS(1);
5339 if (World.PermissionsMngr.CanRestartSim(m_host.OwnerID))
5340 {
5341 World.Restart((float)seconds);
5342 return 1;
5343 }
5344 else
5345 {
5346 return 0;
5347 }
5348 }
5349
5350 public void osRegionNotice(string msg)
5351 {
5352 m_host.AddScriptLPS(1);
5353 World.SendGeneralAlert(msg);
5354 }
5355
5356 public void osSetRot(LLUUID target, Quaternion rotation)
5357 {
5358 m_host.AddScriptLPS(1);
5359 if (World.Entities.ContainsKey(target))
5360 {
5361 World.Entities[target].Rotation = rotation;
5362 }
5363 else
5364 {
5365 LSLError("osSetRot: Invalid target");
5366 }
5367 }
5368
5369 public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
5370 int timer)
5371 {
5372 m_host.AddScriptLPS(1);
5373 if (dynamicID == String.Empty)
5374 {
5375 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
5376 LLUUID createdTexture =
5377 textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
5378 extraParams, timer);
5379 return createdTexture.ToString();
5380 }
5381 else
5382 {
5383 //TODO update existing dynamic textures
5384 }
5385
5386 return LLUUID.Zero.ToString();
5387 }
5388
5389 public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
5390 int timer, int alpha)
5391 {
5392 m_host.AddScriptLPS(1);
5393 if (dynamicID == String.Empty)
5394 {
5395 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
5396 LLUUID createdTexture =
5397 textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
5398 extraParams, timer, true, (byte) alpha );
5399 return createdTexture.ToString();
5400 }
5401 else
5402 {
5403 //TODO update existing dynamic textures
5404 }
5405
5406 return LLUUID.Zero.ToString();
5407 }
5408
5409 public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
5410 int timer)
5411 {
5412 m_host.AddScriptLPS(1);
5413 if (dynamicID == String.Empty)
5414 {
5415 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
5416 if (textureManager != null)
5417 {
5418 LLUUID createdTexture =
5419 textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data,
5420 extraParams, timer);
5421 return createdTexture.ToString();
5422 }
5423 }
5424 else
5425 {
5426 //TODO update existing dynamic textures
5427 }
5428
5429 return LLUUID.Zero.ToString();
5430 }
5431
5432 public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
5433 int timer, int alpha)
5434 {
5435 m_host.AddScriptLPS(1);
5436 if (dynamicID == String.Empty)
5437 {
5438 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
5439 if (textureManager != null)
5440 {
5441 LLUUID createdTexture =
5442 textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data,
5443 extraParams, timer, true, (byte) alpha);
5444 return createdTexture.ToString();
5445 }
5446 }
5447 else
5448 {
5449 //TODO update existing dynamic textures
5450 }
5451 5306
5452 return LLUUID.Zero.ToString(); 5307 internal LLUUID ScriptByName(string name)
5453 }
5454
5455 public bool osConsoleCommand(string command)
5456 {
5457 m_host.AddScriptLPS(1);
5458 Nini.Config.IConfigSource config = new Nini.Config.IniConfigSource(Application.iniFilePath);
5459 if (config.Configs["LL-Functions"] == null)
5460 config.AddConfig("LL-Functions");
5461
5462 if (config.Configs["LL-Functions"].GetBoolean("AllowosConsoleCommand", false))
5463 {
5464 if (World.PermissionsMngr.CanRunConsoleCommand(m_host.OwnerID))
5465 {
5466 OpenSim.Framework.Console.MainConsole.Instance.RunCommand(command);
5467 return true;
5468 }
5469 return false;
5470 }
5471 return false;
5472 }
5473
5474 private LLUUID ScriptByName(string name)
5475 { 5308 {
5476 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 5309 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
5477 { 5310 {
5478 if(item.Type == 10 && item.Name == name) 5311 if (item.Type == 10 && item.Name == name)
5479 return item.ItemID; 5312 return item.ItemID;
5480 } 5313 }
5481 return LLUUID.Zero; 5314 return LLUUID.Zero;
5482 } 5315 }
5483 5316
5484 private void ShoutError(string msg) 5317 internal void ShoutError(string msg)
5485 {
5486 llShout(BuiltIn_Commands_BaseClass.DEBUG_CHANNEL,msg);
5487 }
5488
5489 public void osSetPrimFloatOnWater(int floatYN)
5490 {
5491 m_host.AddScriptLPS(1);
5492 if (m_host.ParentGroup != null)
5493 {
5494 if (m_host.ParentGroup.RootPart != null)
5495 {
5496 m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN);
5497 }
5498 }
5499 }
5500
5501 // Adam's super super custom animation functions
5502 public void osAvatarPlayAnimation(string avatar, string animation)
5503 { 5318 {
5504 m_host.AddScriptLPS(1); 5319 llShout(BuiltIn_Commands_BaseClass.DEBUG_CHANNEL, msg);
5505 if (World.Entities.ContainsKey(avatar) && World.Entities[avatar] is ScenePresence)
5506 {
5507 ScenePresence target = (ScenePresence)World.Entities[avatar];
5508 target.AddAnimation(avatar, 0);
5509 }
5510 }
5511
5512 public void osAvatarStopAnimation(string avatar, string animation)
5513 {
5514 m_host.AddScriptLPS(1);
5515 if (World.Entities.ContainsKey(avatar) && World.Entities[avatar] is ScenePresence)
5516 {
5517 ScenePresence target = (ScenePresence)World.Entities[avatar];
5518 target.RemoveAnimation(animation);
5519 }
5520 } 5320 }
5521 5321
5522 //Texture draw functions
5523 public string osMovePen(string drawList, int x, int y)
5524 {
5525 m_host.AddScriptLPS(1);
5526 drawList += "MoveTo " + x + "," + y + ";";
5527 return drawList;
5528 }
5529 5322
5530 public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
5531 {
5532 m_host.AddScriptLPS(1);
5533 drawList += "MoveTo "+ startX+","+ startY +"; LineTo "+endX +","+endY +"; ";
5534 return drawList;
5535 }
5536
5537 public string osDrawLine(string drawList, int endX, int endY)
5538 {
5539 m_host.AddScriptLPS(1);
5540 drawList += "LineTo " + endX + "," + endY + "; ";
5541 return drawList;
5542 }
5543
5544 public string osDrawText(string drawList, string text)
5545 {
5546 m_host.AddScriptLPS(1);
5547 drawList += "Text " + text + "; ";
5548 return drawList;
5549 }
5550
5551 public string osDrawEllipse(string drawList, int width, int height)
5552 {
5553 m_host.AddScriptLPS(1);
5554 drawList += "Ellipse " + width + "," + height + "; ";
5555 return drawList;
5556 }
5557
5558 public string osDrawRectangle(string drawList, int width, int height)
5559 {
5560 m_host.AddScriptLPS(1);
5561 drawList += "Rectangle " + width + "," + height + "; ";
5562 return drawList;
5563 }
5564
5565 public string osDrawFilledRectangle(string drawList, int width, int height)
5566 {
5567 m_host.AddScriptLPS(1);
5568 drawList += "FillRectangle " + width + "," + height + "; ";
5569 return drawList;
5570 }
5571
5572 public string osSetFontSize(string drawList, int fontSize)
5573 {
5574 m_host.AddScriptLPS(1);
5575 drawList += "FontSize "+ fontSize +"; ";
5576 return drawList;
5577 }
5578
5579 public string osSetPenSize(string drawList, int penSize)
5580 {
5581 m_host.AddScriptLPS(1);
5582 drawList += "PenSize " + penSize + "; ";
5583 return drawList;
5584 }
5585
5586 public string osSetPenColour(string drawList, string colour)
5587 {
5588 m_host.AddScriptLPS(1);
5589 drawList += "PenColour " + colour + "; ";
5590 return drawList;
5591 }
5592
5593 public string osDrawImage(string drawList, int width, int height, string imageUrl)
5594 {
5595 m_host.AddScriptLPS(1);
5596 drawList +="Image " +width + "," + height+ ","+ imageUrl +"; " ;
5597 return drawList;
5598 }
5599
5600 public void osSetStateEvents(int events)
5601 {
5602 m_host.setScriptEvents(m_itemID,events);
5603 }
5604 5323
5605 private void NotImplemented(string command) 5324 internal void NotImplemented(string command)
5606 { 5325 {
5607 if (throwErrorOnNotImplemented) 5326 if (throwErrorOnNotImplemented)
5608 throw new NotImplementedException("Command not implemented: " + command); 5327 throw new NotImplementedException("Command not implemented: " + command);
5609 } 5328 }
5610 5329
5611 private void Deprecated(string command) 5330 internal void Deprecated(string command)
5612 { 5331 {
5613 throw new Exception("Command deprecated: " + command); 5332 throw new Exception("Command deprecated: " + command);
5614 } 5333 }
5615 5334
5616 private void LSLError(string msg) 5335 internal void LSLError(string msg)
5617 { 5336 {
5618 throw new Exception("LSL Runtime Error: " + msg); 5337 throw new Exception("LSL Runtime Error: " + msg);
5619 } 5338 }