diff options
author | Tedd Hansen | 2008-02-25 19:34:38 +0000 |
---|---|---|
committer | Tedd Hansen | 2008-02-25 19:34:38 +0000 |
commit | 5739e13f5b69f6f83ecf11e21549bfe90461790c (patch) | |
tree | 02b9e54b6fbc6cf8640861cb1c7037751fb5b3a1 /OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | |
parent | * Resolve Mantis 667 by not passing on textures with no actual data onto Text... (diff) | |
download | opensim-SC-5739e13f5b69f6f83ecf11e21549bfe90461790c.zip opensim-SC-5739e13f5b69f6f83ecf11e21549bfe90461790c.tar.gz opensim-SC-5739e13f5b69f6f83ecf11e21549bfe90461790c.tar.bz2 opensim-SC-5739e13f5b69f6f83ecf11e21549bfe90461790c.tar.xz |
Initial patch for llSensor*
llSensor, llSensorRepeat, llSensorRemove, llDetectedName, llDetectedKey, llDetectedOwner, llDetectedType, llDetectedPos, llDetectedVel, llDetectedRot
Thank you very much kinoc! :)
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 144 |
1 files changed, 125 insertions, 19 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index b2f2d59..f9bcc06 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections; | ||
30 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 33 | using System.Text; |
@@ -362,64 +363,163 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
362 | public void llSensor(string name, string id, int type, double range, double arc) | 363 | public void llSensor(string name, string id, int type, double range, double arc) |
363 | { | 364 | { |
364 | m_host.AddScriptLPS(1); | 365 | m_host.AddScriptLPS(1); |
365 | NotImplemented("llSensor"); | 366 | LLUUID keyID = LLUUID.Zero; |
367 | try | ||
368 | { | ||
369 | if (id.Length > 0) keyID = new LLUUID(id); | ||
370 | } | ||
371 | catch | ||
372 | { | ||
373 | } | ||
374 | m_ScriptEngine.m_ASYNCLSLCommandManager.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host); | ||
375 | |||
366 | return; | 376 | return; |
367 | } | 377 | // NotImplemented("llSensor"); |
378 | } | ||
368 | 379 | ||
369 | public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) | 380 | public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) |
370 | { | 381 | { |
371 | m_host.AddScriptLPS(1); | 382 | m_host.AddScriptLPS(1); |
372 | NotImplemented("llSensorRepeat"); | 383 | LLUUID keyID = LLUUID.Zero; |
384 | try | ||
385 | { | ||
386 | if (id.Length > 0) keyID = new LLUUID(id); | ||
387 | } | ||
388 | catch | ||
389 | { | ||
390 | } | ||
391 | |||
392 | m_ScriptEngine.m_ASYNCLSLCommandManager.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host); | ||
373 | return; | 393 | return; |
374 | } | 394 | // NotImplemented("llSensorRepeat"); |
395 | } | ||
375 | 396 | ||
376 | public void llSensorRemove() | 397 | public void llSensorRemove() |
377 | { | 398 | { |
378 | m_host.AddScriptLPS(1); | 399 | m_host.AddScriptLPS(1); |
379 | NotImplemented("llSensorRemove"); | 400 | m_ScriptEngine.m_ASYNCLSLCommandManager.UnSetSenseRepeaterEvents(m_localID, m_itemID); |
380 | return; | 401 | return; |
402 | // NotImplemented("llSensorRemove"); | ||
381 | } | 403 | } |
382 | 404 | ||
383 | public string llDetectedName(int number) | 405 | public string llDetectedName(int number) |
384 | { | 406 | { |
385 | m_host.AddScriptLPS(1); | 407 | m_host.AddScriptLPS(1); |
386 | NotImplemented("llDetectedName"); | 408 | LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.GetSensorList(m_localID, m_itemID); |
387 | return String.Empty; | 409 | if ((number>0)&&(number <= SenseList.Length)) |
410 | { | ||
411 | LLUUID SensedUUID = (LLUUID)SenseList.Data[number]; | ||
412 | //ScenePresence SensedObject = World.GetScenePresence(SensedUUID); | ||
413 | EntityBase SensedObject=null; | ||
414 | lock (World.Entities) | ||
415 | { | ||
416 | World.Entities.TryGetValue(SensedUUID, out SensedObject); | ||
417 | } | ||
418 | |||
419 | if (SensedObject == null) | ||
420 | return String.Empty; | ||
421 | return SensedObject.Name; | ||
422 | } | ||
423 | else | ||
424 | return String.Empty; | ||
425 | //NotImplemented("llDetectedName"); | ||
426 | } | ||
427 | |||
428 | public LLUUID uuidDetectedKey(int number) | ||
429 | { | ||
430 | LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.GetSensorList(m_localID, m_itemID); | ||
431 | if ((number >= 0) && (number < SenseList.Length)) | ||
432 | { | ||
433 | LLUUID SensedUUID = (LLUUID)SenseList.Data[number]; | ||
434 | return SensedUUID; | ||
435 | } | ||
436 | return LLUUID.Zero; | ||
437 | } | ||
438 | |||
439 | public EntityBase entityDetectedKey(int number) | ||
440 | { | ||
441 | LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.GetSensorList(m_localID, m_itemID); | ||
442 | if ((number >= 0) && (number < SenseList.Length)) | ||
443 | { | ||
444 | LLUUID SensedUUID = (LLUUID)SenseList.Data[number]; | ||
445 | EntityBase SensedObject = null; | ||
446 | lock (World.Entities) | ||
447 | { | ||
448 | World.Entities.TryGetValue(SensedUUID, out SensedObject); | ||
449 | } | ||
450 | return SensedObject; | ||
451 | } | ||
452 | return null; | ||
388 | } | 453 | } |
389 | 454 | ||
390 | public string llDetectedKey(int number) | 455 | public string llDetectedKey(int number) |
391 | { | 456 | { |
392 | m_host.AddScriptLPS(1); | 457 | m_host.AddScriptLPS(1); |
393 | NotImplemented("llDetectedKey"); | 458 | LLUUID SensedUUID = uuidDetectedKey(number); |
394 | return String.Empty; | 459 | if (SensedUUID == LLUUID.Zero) |
460 | return String.Empty; | ||
461 | |||
462 | return SensedUUID.ToString(); | ||
395 | } | 463 | } |
396 | 464 | ||
397 | public string llDetectedOwner(int number) | 465 | public string llDetectedOwner(int number) |
398 | { | 466 | { |
399 | m_host.AddScriptLPS(1); | 467 | m_host.AddScriptLPS(1); |
400 | NotImplemented("llDetectedOwner"); | 468 | EntityBase SensedObject = entityDetectedKey(number); |
469 | if (SensedObject ==null) | ||
470 | return String.Empty; | ||
471 | //return SensedObject.O .Name; // What is the owner of the object ? | ||
472 | //EntityBase SensedObject = World.GetScenePresence(SensedUUID); | ||
473 | LLUUID SensedUUID = uuidDetectedKey(number); | ||
474 | SceneObjectPart SOP = World.GetSceneObjectPart(SensedUUID); | ||
475 | if (SOP != null) { return SOP.ObjectOwner.ToString(); } | ||
401 | return String.Empty; | 476 | return String.Empty; |
402 | } | 477 | |
478 | } | ||
403 | 479 | ||
404 | public int llDetectedType(int number) | 480 | public int llDetectedType(int number) |
405 | { | 481 | { |
406 | m_host.AddScriptLPS(1); | 482 | m_host.AddScriptLPS(1); |
407 | NotImplemented("llDetectedType"); | 483 | EntityBase SensedObject = entityDetectedKey(number); |
408 | return 0; | 484 | if (SensedObject == null) |
485 | return 0; | ||
486 | int mask = 0; | ||
487 | |||
488 | LLUUID SensedUUID = uuidDetectedKey(number); | ||
489 | LSL_Types.Vector3 ZeroVector = new LSL_Types.Vector3(0, 0, 0); | ||
490 | |||
491 | if (World.GetScenePresence(SensedUUID) != null) mask |= 0x01; // actor | ||
492 | if (SensedObject.Velocity.Equals(ZeroVector)) | ||
493 | mask |= 0x04; // passive non-moving | ||
494 | else | ||
495 | mask |= 0x02; // active moving | ||
496 | if (SensedObject is IScript) mask |= 0x08; // Scripted. It COULD have one hidden ... | ||
497 | return mask; | ||
498 | |||
409 | } | 499 | } |
410 | 500 | ||
411 | public LSL_Types.Vector3 llDetectedPos(int number) | 501 | public LSL_Types.Vector3 llDetectedPos(int number) |
412 | { | 502 | { |
413 | m_host.AddScriptLPS(1); | 503 | m_host.AddScriptLPS(1); |
414 | NotImplemented("llDetectedPos"); | 504 | EntityBase SensedObject = entityDetectedKey(number); |
415 | return new LSL_Types.Vector3(); | 505 | if (SensedObject == null) |
506 | return new LSL_Types.Vector3(0, 0, 0); | ||
507 | |||
508 | return new LSL_Types.Vector3(SensedObject.AbsolutePosition.X,SensedObject.AbsolutePosition.Y,SensedObject.AbsolutePosition.Z); | ||
509 | |||
510 | //NotImplemented("llDetectedPos"); | ||
416 | } | 511 | } |
417 | 512 | ||
418 | public LSL_Types.Vector3 llDetectedVel(int number) | 513 | public LSL_Types.Vector3 llDetectedVel(int number) |
419 | { | 514 | { |
420 | m_host.AddScriptLPS(1); | 515 | m_host.AddScriptLPS(1); |
421 | NotImplemented("llDetectedVel"); | 516 | EntityBase SensedObject = entityDetectedKey(number); |
422 | return new LSL_Types.Vector3(); | 517 | if (SensedObject == null) |
518 | return new LSL_Types.Vector3(0, 0, 0); | ||
519 | |||
520 | return new LSL_Types.Vector3(SensedObject.Velocity.X, SensedObject.Velocity.Y, SensedObject.Velocity.Z); | ||
521 | // NotImplemented("llDetectedVel"); | ||
522 | // return new LSL_Types.Vector3(); | ||
423 | } | 523 | } |
424 | 524 | ||
425 | public LSL_Types.Vector3 llDetectedGrab(int number) | 525 | public LSL_Types.Vector3 llDetectedGrab(int number) |
@@ -432,8 +532,11 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
432 | public LSL_Types.Quaternion llDetectedRot(int number) | 532 | public LSL_Types.Quaternion llDetectedRot(int number) |
433 | { | 533 | { |
434 | m_host.AddScriptLPS(1); | 534 | m_host.AddScriptLPS(1); |
435 | NotImplemented("llDetectedRot"); | 535 | EntityBase SensedObject = entityDetectedKey(number); |
436 | return new LSL_Types.Quaternion(); | 536 | if (SensedObject == null) |
537 | return new LSL_Types.Quaternion(); | ||
538 | |||
539 | return new LSL_Types.Quaternion(SensedObject.Rotation.x, SensedObject.Rotation.y, SensedObject.Rotation.z, SensedObject.Rotation.w); | ||
437 | } | 540 | } |
438 | 541 | ||
439 | public int llDetectedGroup(int number) | 542 | public int llDetectedGroup(int number) |
@@ -2401,6 +2504,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
2401 | ret.Add(str); | 2504 | ret.Add(str); |
2402 | } | 2505 | } |
2403 | return ret; | 2506 | return ret; |
2507 | |||
2404 | } | 2508 | } |
2405 | 2509 | ||
2406 | public int llOverMyLand(string id) | 2510 | public int llOverMyLand(string id) |
@@ -3222,6 +3326,8 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
3222 | { | 3326 | { |
3223 | m_host.AddScriptLPS(1); | 3327 | m_host.AddScriptLPS(1); |
3224 | //temp fix so that lsl wiki examples aren't annoying to use to test other functions | 3328 | //temp fix so that lsl wiki examples aren't annoying to use to test other functions |
3329 | //should be similar to : llInstantMessage(llGetOwner(),msg) | ||
3330 | // llGetOwner ==> m_host.ObjectOwner.ToString() | ||
3225 | World.SimChat(Helpers.StringToField(msg), ChatTypeEnum.Say, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID); | 3331 | World.SimChat(Helpers.StringToField(msg), ChatTypeEnum.Say, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID); |
3226 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 3332 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
3227 | wComm.DeliverMessage(m_host.UUID.ToString(), ChatTypeEnum.Say, 0, m_host.Name, msg); | 3333 | wComm.DeliverMessage(m_host.UUID.ToString(), ChatTypeEnum.Say, 0, m_host.Name, msg); |