diff options
author | Charles Krinke | 2008-06-07 22:37:48 +0000 |
---|---|---|
committer | Charles Krinke | 2008-06-07 22:37:48 +0000 |
commit | 0e5f2b329361e8e3c911e6171d639720e800a490 (patch) | |
tree | 64aa88bd43bd049dd0f64e6471cfc5a4777e5ee2 /OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs | |
parent | Mantis#1495. Thank you kindly, Kinoc for: (diff) | |
download | opensim-SC-0e5f2b329361e8e3c911e6171d639720e800a490.zip opensim-SC-0e5f2b329361e8e3c911e6171d639720e800a490.tar.gz opensim-SC-0e5f2b329361e8e3c911e6171d639720e800a490.tar.bz2 opensim-SC-0e5f2b329361e8e3c911e6171d639720e800a490.tar.xz |
Mantis#1496. Thank you kindly, Melanie for a patch that:
Adds full implementation of all llDetected* functions for sensors,
collisions and touches. Adds changed(CHANGED_REGION_RESTART) event
to allow restarting of eye-candy functionality not currently
persisted with the prim.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs | 117 |
1 files changed, 31 insertions, 86 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs b/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs index bf0e14e..46c6c33 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs | |||
@@ -550,113 +550,55 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
550 | public string llDetectedName(int number) | 550 | public string llDetectedName(int number) |
551 | { | 551 | { |
552 | m_host.AddScriptLPS(1); | 552 | m_host.AddScriptLPS(1); |
553 | LLUUID sensedUUID = m_ScriptEngine.GetDetectID(m_itemID, number); | 553 | XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); |
554 | if (sensedUUID != LLUUID.Zero) | 554 | if (d == null) |
555 | return resolveName(sensedUUID); | 555 | return String.Empty; |
556 | return String.Empty; | 556 | return d.Name; |
557 | } | ||
558 | |||
559 | public LLUUID uuidDetectedKey(int number) | ||
560 | { | ||
561 | return m_ScriptEngine.GetDetectID(m_itemID, number); | ||
562 | } | ||
563 | |||
564 | public EntityBase entityDetectedKey(int number) | ||
565 | { | ||
566 | LLUUID sensedUUID = m_ScriptEngine.GetDetectID(m_itemID, number); | ||
567 | if (sensedUUID != LLUUID.Zero) | ||
568 | { | ||
569 | EntityBase SensedObject = null; | ||
570 | lock (World.Entities) | ||
571 | { | ||
572 | World.Entities.TryGetValue(sensedUUID, out SensedObject); | ||
573 | } | ||
574 | return SensedObject; | ||
575 | } | ||
576 | return null; | ||
577 | } | 557 | } |
578 | 558 | ||
579 | public string llDetectedKey(int number) | 559 | public string llDetectedKey(int number) |
580 | { | 560 | { |
581 | m_host.AddScriptLPS(1); | 561 | m_host.AddScriptLPS(1); |
582 | LLUUID SensedUUID = uuidDetectedKey(number); | 562 | XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); |
583 | if (SensedUUID == LLUUID.Zero) | 563 | if (d == null) |
584 | return String.Empty; | 564 | return String.Empty; |
585 | 565 | return d.Key.ToString(); | |
586 | return SensedUUID.ToString(); | ||
587 | } | 566 | } |
588 | 567 | ||
589 | public string llDetectedOwner(int number) | 568 | public string llDetectedOwner(int number) |
590 | { | 569 | { |
591 | // returns UUID of owner of object detected | ||
592 | m_host.AddScriptLPS(1); | 570 | m_host.AddScriptLPS(1); |
593 | EntityBase SensedObject = entityDetectedKey(number); | 571 | XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); |
594 | if (SensedObject == null) | 572 | if (d == null) |
595 | return String.Empty; | 573 | return String.Empty; |
596 | LLUUID SensedUUID = uuidDetectedKey(number); | 574 | return d.Owner.ToString(); |
597 | if (World.GetScenePresence(SensedUUID) == null) | 575 | } |
598 | { | ||
599 | // sensed object is not an avatar | ||
600 | // so get the owner of the sensed object | ||
601 | SceneObjectPart SOP = World.GetSceneObjectPart(SensedUUID); | ||
602 | if (SOP != null) | ||
603 | { | ||
604 | return SOP.ObjectOwner.ToString(); | ||
605 | } | ||
606 | } | ||
607 | else | ||
608 | { | ||
609 | // sensed object is an avatar, and so must be its own owner | ||
610 | return SensedUUID.ToString(); | ||
611 | } | ||
612 | |||
613 | return String.Empty; | ||
614 | } | ||
615 | 576 | ||
616 | public LSL_Types.LSLInteger llDetectedType(int number) | 577 | public LSL_Types.LSLInteger llDetectedType(int number) |
617 | { | 578 | { |
618 | m_host.AddScriptLPS(1); | 579 | m_host.AddScriptLPS(1); |
619 | EntityBase SensedObject = entityDetectedKey(number); | 580 | XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); |
620 | if (SensedObject == null) | 581 | if (d == null) |
621 | return 0; | 582 | return 0; |
622 | int mask = 0; | 583 | return new LSL_Types.LSLInteger(d.Type); |
623 | |||
624 | LLUUID SensedUUID = uuidDetectedKey(number); | ||
625 | LSL_Types.Vector3 ZeroVector = new LSL_Types.Vector3(0, 0, 0); | ||
626 | |||
627 | if (World.GetScenePresence(SensedUUID) != null) | ||
628 | mask |= 0x01; // actor | ||
629 | |||
630 | if (SensedObject.Velocity.Equals(ZeroVector)) | ||
631 | mask |= 0x04; // passive non-moving | ||
632 | else | ||
633 | mask |= 0x02; // active moving | ||
634 | |||
635 | if (SensedObject is IScript) | ||
636 | mask |= 0x08; // Scripted. It COULD have one hidden ... | ||
637 | |||
638 | return mask; | ||
639 | } | 584 | } |
640 | 585 | ||
641 | public LSL_Types.Vector3 llDetectedPos(int number) | 586 | public LSL_Types.Vector3 llDetectedPos(int number) |
642 | { | 587 | { |
643 | m_host.AddScriptLPS(1); | 588 | m_host.AddScriptLPS(1); |
644 | EntityBase SensedObject = entityDetectedKey(number); | 589 | XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); |
645 | if (SensedObject == null) | 590 | if (d == null) |
646 | return new LSL_Types.Vector3(0, 0, 0); | 591 | return new LSL_Types.Vector3(); |
647 | 592 | return d.Position; | |
648 | return new LSL_Types.Vector3(SensedObject.AbsolutePosition.X,SensedObject.AbsolutePosition.Y,SensedObject.AbsolutePosition.Z); | ||
649 | } | 593 | } |
650 | 594 | ||
651 | public LSL_Types.Vector3 llDetectedVel(int number) | 595 | public LSL_Types.Vector3 llDetectedVel(int number) |
652 | { | 596 | { |
653 | m_host.AddScriptLPS(1); | 597 | m_host.AddScriptLPS(1); |
654 | EntityBase SensedObject = entityDetectedKey(number); | 598 | XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); |
655 | if (SensedObject == null) | 599 | if (d == null) |
656 | return new LSL_Types.Vector3(0, 0, 0); | 600 | return new LSL_Types.Vector3(); |
657 | 601 | return d.Velocity; | |
658 | return new LSL_Types.Vector3(SensedObject.Velocity.X, SensedObject.Velocity.Y, SensedObject.Velocity.Z); | ||
659 | // return new LSL_Types.Vector3(); | ||
660 | } | 602 | } |
661 | 603 | ||
662 | public LSL_Types.Vector3 llDetectedGrab(int number) | 604 | public LSL_Types.Vector3 llDetectedGrab(int number) |
@@ -672,18 +614,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
672 | public LSL_Types.Quaternion llDetectedRot(int number) | 614 | public LSL_Types.Quaternion llDetectedRot(int number) |
673 | { | 615 | { |
674 | m_host.AddScriptLPS(1); | 616 | m_host.AddScriptLPS(1); |
675 | EntityBase SensedObject = entityDetectedKey(number); | 617 | XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); |
676 | if (SensedObject == null) | 618 | if (d == null) |
677 | return new LSL_Types.Quaternion(); | 619 | return new LSL_Types.Quaternion(); |
678 | 620 | return d.Rotation; | |
679 | return new LSL_Types.Quaternion(SensedObject.Rotation.x, SensedObject.Rotation.y, SensedObject.Rotation.z, SensedObject.Rotation.w); | ||
680 | } | 621 | } |
681 | 622 | ||
682 | public LSL_Types.LSLInteger llDetectedGroup(int number) | 623 | public LSL_Types.LSLInteger llDetectedGroup(int number) |
683 | { | 624 | { |
684 | m_host.AddScriptLPS(1); | 625 | m_host.AddScriptLPS(1); |
685 | NotImplemented("llDetectedGroup"); | 626 | XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number); |
686 | return 0; | 627 | if (d == null) |
628 | return new LSL_Types.LSLInteger(0); | ||
629 | if(m_host.GroupID == d.Group) | ||
630 | return new LSL_Types.LSLInteger(1); | ||
631 | return new LSL_Types.LSLInteger(0); | ||
687 | } | 632 | } |
688 | 633 | ||
689 | public LSL_Types.LSLInteger llDetectedLinkNumber(int number) | 634 | public LSL_Types.LSLInteger llDetectedLinkNumber(int number) |