aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs226
1 files changed, 190 insertions, 36 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index fd6d64c..26969a5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2214,7 +2214,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2214 public LSL_Vector llGetVel() 2214 public LSL_Vector llGetVel()
2215 { 2215 {
2216 m_host.AddScriptLPS(1); 2216 m_host.AddScriptLPS(1);
2217 return new LSL_Vector(m_host.Velocity.X, m_host.Velocity.Y, m_host.Velocity.Z); 2217
2218 Vector3 vel;
2219
2220 if (m_host.IsAttachment)
2221 {
2222 ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.AttachedAvatar);
2223 vel = avatar.Velocity;
2224 }
2225 else
2226 {
2227 vel = m_host.Velocity;
2228 }
2229
2230 return new LSL_Vector(vel.X, vel.Y, vel.Z);
2218 } 2231 }
2219 2232
2220 public LSL_Vector llGetAccel() 2233 public LSL_Vector llGetAccel()
@@ -2510,10 +2523,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2510 /// negative (indicating end-relative) and may be inverted, 2523 /// negative (indicating end-relative) and may be inverted,
2511 /// i.e. end < start. 2524 /// i.e. end < start.
2512 /// </summary> 2525 /// </summary>
2513
2514 public LSL_String llDeleteSubString(string src, int start, int end) 2526 public LSL_String llDeleteSubString(string src, int start, int end)
2515 { 2527 {
2516
2517 m_host.AddScriptLPS(1); 2528 m_host.AddScriptLPS(1);
2518 2529
2519 // Normalize indices (if negative). 2530 // Normalize indices (if negative).
@@ -2593,10 +2604,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2593 /// which case it is end-relative. The index may exceed either 2604 /// which case it is end-relative. The index may exceed either
2594 /// string bound, with the result being a concatenation. 2605 /// string bound, with the result being a concatenation.
2595 /// </summary> 2606 /// </summary>
2596
2597 public LSL_String llInsertString(string dest, int index, string src) 2607 public LSL_String llInsertString(string dest, int index, string src)
2598 { 2608 {
2599
2600 m_host.AddScriptLPS(1); 2609 m_host.AddScriptLPS(1);
2601 2610
2602 // Normalize indices (if negative). 2611 // Normalize indices (if negative).
@@ -9983,6 +9992,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9983 public LSL_List llGetObjectDetails(string id, LSL_List args) 9992 public LSL_List llGetObjectDetails(string id, LSL_List args)
9984 { 9993 {
9985 m_host.AddScriptLPS(1); 9994 m_host.AddScriptLPS(1);
9995
9986 LSL_List ret = new LSL_List(); 9996 LSL_List ret = new LSL_List();
9987 UUID key = new UUID(); 9997 UUID key = new UUID();
9988 if (UUID.TryParse(id, out key)) 9998 if (UUID.TryParse(id, out key))
@@ -9993,72 +10003,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9993 { 10003 {
9994 foreach (object o in args.Data) 10004 foreach (object o in args.Data)
9995 { 10005 {
9996 switch (o.ToString()) 10006 switch (int.Parse(o.ToString()))
9997 { 10007 {
9998 case "1": 10008 case ScriptBaseClass.OBJECT_NAME:
9999 ret.Add(new LSL_String(av.Firstname + " " + av.Lastname)); 10009 ret.Add(new LSL_String(av.Firstname + " " + av.Lastname));
10000 break; 10010 break;
10001 case "2": 10011 case ScriptBaseClass.OBJECT_DESC:
10002 ret.Add(new LSL_String("")); 10012 ret.Add(new LSL_String(""));
10003 break; 10013 break;
10004 case "3": 10014 case ScriptBaseClass.OBJECT_POS:
10005 ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z)); 10015 ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z));
10006 break; 10016 break;
10007 case "4": 10017 case ScriptBaseClass.OBJECT_ROT:
10008 ret.Add(new LSL_Rotation((double)av.Rotation.X, (double)av.Rotation.Y, (double)av.Rotation.Z, (double)av.Rotation.W)); 10018 ret.Add(new LSL_Rotation((double)av.Rotation.X, (double)av.Rotation.Y, (double)av.Rotation.Z, (double)av.Rotation.W));
10009 break; 10019 break;
10010 case "5": 10020 case ScriptBaseClass.OBJECT_VELOCITY:
10011 ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z)); 10021 ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z));
10012 break; 10022 break;
10013 case "6": 10023 case ScriptBaseClass.OBJECT_OWNER:
10014 ret.Add(new LSL_String(id)); 10024 ret.Add(new LSL_String(id));
10015 break; 10025 break;
10016 case "7": 10026 case ScriptBaseClass.OBJECT_GROUP:
10017 ret.Add(new LSL_String(UUID.Zero.ToString())); 10027 ret.Add(new LSL_String(UUID.Zero.ToString()));
10018 break; 10028 break;
10019 case "8": 10029 case ScriptBaseClass.OBJECT_CREATOR:
10020 ret.Add(new LSL_String(UUID.Zero.ToString())); 10030 ret.Add(new LSL_String(UUID.Zero.ToString()));
10021 break; 10031 break;
10022 } 10032 }
10023 } 10033 }
10034
10024 return ret; 10035 return ret;
10025 } 10036 }
10037
10026 SceneObjectPart obj = World.GetSceneObjectPart(key); 10038 SceneObjectPart obj = World.GetSceneObjectPart(key);
10027 if (obj != null) 10039 if (obj != null)
10028 { 10040 {
10029 foreach (object o in args.Data) 10041 foreach (object o in args.Data)
10030 { 10042 {
10031 switch (o.ToString()) 10043 switch (int.Parse(o.ToString()))
10032 { 10044 {
10033 case "1": 10045 case ScriptBaseClass.OBJECT_NAME:
10034 ret.Add(new LSL_String(obj.Name)); 10046 ret.Add(new LSL_String(obj.Name));
10035 break; 10047 break;
10036 case "2": 10048 case ScriptBaseClass.OBJECT_DESC:
10037 ret.Add(new LSL_String(obj.Description)); 10049 ret.Add(new LSL_String(obj.Description));
10038 break; 10050 break;
10039 case "3": 10051 case ScriptBaseClass.OBJECT_POS:
10040 ret.Add(new LSL_Vector(obj.AbsolutePosition.X, obj.AbsolutePosition.Y, obj.AbsolutePosition.Z)); 10052 ret.Add(new LSL_Vector(obj.AbsolutePosition.X, obj.AbsolutePosition.Y, obj.AbsolutePosition.Z));
10041 break; 10053 break;
10042 case "4": 10054 case ScriptBaseClass.OBJECT_ROT:
10043 ret.Add(new LSL_Rotation(obj.RotationOffset.X, obj.RotationOffset.Y, obj.RotationOffset.Z, obj.RotationOffset.W)); 10055 ret.Add(new LSL_Rotation(obj.RotationOffset.X, obj.RotationOffset.Y, obj.RotationOffset.Z, obj.RotationOffset.W));
10044 break; 10056 break;
10045 case "5": 10057 case ScriptBaseClass.OBJECT_VELOCITY:
10046 ret.Add(new LSL_Vector(obj.Velocity.X, obj.Velocity.Y, obj.Velocity.Z)); 10058 ret.Add(new LSL_Vector(obj.Velocity.X, obj.Velocity.Y, obj.Velocity.Z));
10047 break; 10059 break;
10048 case "6": 10060 case ScriptBaseClass.OBJECT_OWNER:
10049 ret.Add(new LSL_String(obj.OwnerID.ToString())); 10061 ret.Add(new LSL_String(obj.OwnerID.ToString()));
10050 break; 10062 break;
10051 case "7": 10063 case ScriptBaseClass.OBJECT_GROUP:
10052 ret.Add(new LSL_String(obj.GroupID.ToString())); 10064 ret.Add(new LSL_String(obj.GroupID.ToString()));
10053 break; 10065 break;
10054 case "8": 10066 case ScriptBaseClass.OBJECT_CREATOR:
10055 ret.Add(new LSL_String(obj.CreatorID.ToString())); 10067 ret.Add(new LSL_String(obj.CreatorID.ToString()));
10056 break; 10068 break;
10057 } 10069 }
10058 } 10070 }
10071
10059 return ret; 10072 return ret;
10060 } 10073 }
10061 } 10074 }
10075
10062 return new LSL_List(); 10076 return new LSL_List();
10063 } 10077 }
10064 10078
@@ -10309,51 +10323,191 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10309 return rq.ToString(); 10323 return rq.ToString();
10310 } 10324 }
10311 10325
10326 public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
10327 {
10328 m_host.AddScriptLPS(1);
10329
10330 Vector3 dir = new Vector3((float)(end-start).x, (float)(end-start).y, (float)(end-start).z);
10331 Vector3 startvector = new Vector3((float)start.x, (float)start.y, (float)start.z);
10332 Vector3 endvector = new Vector3((float)end.x, (float)end.y, (float)end.z);
10333
10334 int count = 0;
10335// int detectPhantom = 0;
10336 int dataFlags = 0;
10337 int rejectTypes = 0;
10338
10339 for (int i = 0; i < options.Length; i += 2)
10340 {
10341 if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_MAX_HITS)
10342 {
10343 count = options.GetLSLIntegerItem(i + 1);
10344 }
10345// else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DETECT_PHANTOM)
10346// {
10347// detectPhantom = options.GetLSLIntegerItem(i + 1);
10348// }
10349 else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DATA_FLAGS)
10350 {
10351 dataFlags = options.GetLSLIntegerItem(i + 1);
10352 }
10353 else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_REJECT_TYPES)
10354 {
10355 rejectTypes = options.GetLSLIntegerItem(i + 1);
10356 }
10357 }
10358
10359 LSL_List list = new LSL_List();
10360 List<ContactResult> results = World.PhysicsScene.RaycastWorld(startvector, dir, dir.Length(), count);
10361
10362 double distance = Util.GetDistanceTo(startvector, endvector);
10363
10364 if (distance == 0)
10365 distance = 0.001;
10366
10367 Vector3 posToCheck = startvector;
10368 ITerrainChannel channel = World.RequestModuleInterface<ITerrainChannel>();
10369
10370 bool checkTerrain = !((rejectTypes & ScriptBaseClass.RC_REJECT_LAND) == ScriptBaseClass.RC_REJECT_LAND);
10371 bool checkAgents = !((rejectTypes & ScriptBaseClass.RC_REJECT_AGENTS) == ScriptBaseClass.RC_REJECT_AGENTS);
10372 bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL);
10373 bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL);
10374
10375 for (float i = 0; i <= distance; i += 0.1f)
10376 {
10377 posToCheck = startvector + (dir * (i / (float)distance));
10378
10379 if (checkTerrain && channel[(int)(posToCheck.X + startvector.X), (int)(posToCheck.Y + startvector.Y)] < posToCheck.Z)
10380 {
10381 ContactResult result = new ContactResult();
10382 result.ConsumerID = 0;
10383 result.Depth = 0;
10384 result.Normal = Vector3.Zero;
10385 result.Pos = posToCheck;
10386 results.Add(result);
10387 checkTerrain = false;
10388 }
10389
10390 if (checkAgents)
10391 {
10392 World.ForEachScenePresence(delegate(ScenePresence sp)
10393 {
10394 if (sp.AbsolutePosition.ApproxEquals(posToCheck, sp.PhysicsActor.Size.X))
10395 {
10396 ContactResult result = new ContactResult ();
10397 result.ConsumerID = sp.LocalId;
10398 result.Depth = 0;
10399 result.Normal = Vector3.Zero;
10400 result.Pos = posToCheck;
10401 results.Add(result);
10402 }
10403 });
10404 }
10405 }
10406
10407 int refcount = 0;
10408 foreach (ContactResult result in results)
10409 {
10410 if ((rejectTypes & ScriptBaseClass.RC_REJECT_LAND)
10411 == ScriptBaseClass.RC_REJECT_LAND && result.ConsumerID == 0)
10412 continue;
10413
10414 ISceneEntity entity = World.GetSceneObjectPart(result.ConsumerID);
10415
10416 if (entity == null && (rejectTypes & ScriptBaseClass.RC_REJECT_AGENTS) != ScriptBaseClass.RC_REJECT_AGENTS)
10417 entity = World.GetScenePresence(result.ConsumerID); //Only check if we should be looking for agents
10418
10419 if (entity == null)
10420 {
10421 list.Add(UUID.Zero);
10422
10423 if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM)
10424 list.Add(0);
10425
10426 list.Add(result.Pos);
10427
10428 if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL)
10429 list.Add(result.Normal);
10430
10431 continue; //Can't find it, so add UUID.Zero
10432 }
10433
10434 /*if (detectPhantom == 0 && intersection.obj is ISceneChildEntity &&
10435 ((ISceneChildEntity)intersection.obj).PhysActor == null)
10436 continue;*/ //Can't do this ATM, physics engine knows only of non phantom objects
10437
10438 if (entity is SceneObjectPart)
10439 {
10440 if (((SceneObjectPart)entity).PhysActor != null && ((SceneObjectPart)entity).PhysActor.IsPhysical)
10441 {
10442 if (!checkPhysical)
10443 continue;
10444 }
10445 else
10446 {
10447 if (!checkNonPhysical)
10448 continue;
10449 }
10450 }
10451
10452 refcount++;
10453 if ((dataFlags & ScriptBaseClass.RC_GET_ROOT_KEY) == ScriptBaseClass.RC_GET_ROOT_KEY && entity is SceneObjectPart)
10454 list.Add(((SceneObjectPart)entity).ParentGroup.UUID);
10455 else
10456 list.Add(entity.UUID);
10457
10458 if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM)
10459 {
10460 if (entity is SceneObjectPart)
10461 list.Add(((SceneObjectPart)entity).LinkNum);
10462 else
10463 list.Add(0);
10464 }
10465
10466 list.Add(result.Pos);
10467
10468 if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL)
10469 list.Add(result.Normal);
10470 }
10471
10472 list.Add(refcount); //The status code, either the # of contacts, RCERR_SIM_PERF_LOW, or RCERR_CAST_TIME_EXCEEDED
10473
10474 return list;
10475 }
10476
10312 #region Not Implemented 10477 #region Not Implemented
10313 // 10478 //
10314 // Listing the unimplemented lsl functions here, please move 10479 // Listing the unimplemented lsl functions here, please move
10315 // them from this region as they are completed 10480 // them from this region as they are completed
10316 // 10481 //
10317 public void llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
10318 {
10319 m_host.AddScriptLPS(1);
10320 NotImplemented("llCastRay");
10321
10322 }
10323 10482
10324 public void llGetEnv(LSL_String name) 10483 public void llGetEnv(LSL_String name)
10325 { 10484 {
10326 m_host.AddScriptLPS(1); 10485 m_host.AddScriptLPS(1);
10327 NotImplemented("llGetEnv"); 10486 NotImplemented("llGetEnv");
10328
10329 } 10487 }
10330 10488
10331 public void llGetSPMaxMemory() 10489 public void llGetSPMaxMemory()
10332 { 10490 {
10333 m_host.AddScriptLPS(1); 10491 m_host.AddScriptLPS(1);
10334 NotImplemented("llGetSPMaxMemory"); 10492 NotImplemented("llGetSPMaxMemory");
10335
10336 } 10493 }
10337 10494
10338 public void llGetUsedMemory() 10495 public void llGetUsedMemory()
10339 { 10496 {
10340 m_host.AddScriptLPS(1); 10497 m_host.AddScriptLPS(1);
10341 NotImplemented("llGetUsedMemory"); 10498 NotImplemented("llGetUsedMemory");
10342
10343 } 10499 }
10344 10500
10345 public void llRegionSayTo( LSL_Key target, LSL_Integer channel, LSL_String msg ) 10501 public void llRegionSayTo(LSL_Key target, LSL_Integer channel, LSL_String msg)
10346 { 10502 {
10347 m_host.AddScriptLPS(1); 10503 m_host.AddScriptLPS(1);
10348 NotImplemented("llRegionSayTo"); 10504 NotImplemented("llRegionSayTo");
10349
10350 } 10505 }
10351 10506
10352 public void llScriptProfiler( LSL_Integer flags ) 10507 public void llScriptProfiler(LSL_Integer flags)
10353 { 10508 {
10354 m_host.AddScriptLPS(1); 10509 m_host.AddScriptLPS(1);
10355 NotImplemented("llScriptProfiler"); 10510 NotImplemented("llScriptProfiler");
10356
10357 } 10511 }
10358 10512
10359 public void llSetSoundQueueing(int queue) 10513 public void llSetSoundQueueing(int queue)