diff options
author | Mic Bowman | 2014-02-09 18:07:49 -0800 |
---|---|---|
committer | Mic Bowman | 2014-02-09 18:07:49 -0800 |
commit | b83a22414784495f772d29386bdeb0e2aa708374 (patch) | |
tree | 04a9c964a55e114090bcd115a2e2a615f65a5ff1 | |
parent | Add zadark to CONTRIBUTORS.txt (diff) | |
download | opensim-SC-b83a22414784495f772d29386bdeb0e2aa708374.zip opensim-SC-b83a22414784495f772d29386bdeb0e2aa708374.tar.gz opensim-SC-b83a22414784495f772d29386bdeb0e2aa708374.tar.bz2 opensim-SC-b83a22414784495f772d29386bdeb0e2aa708374.tar.xz |
Add JsonRezAtRoot script function. Operation is very similar to
llRezAtRoot except that the start parameter is a Json string that will
be unpacked into a json store identified by the objects uuid. This
makes a much more expressive (and simpler) way of passing initial
parameters to a rezzed object.
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 9fbfb66..a6c12fd 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | |||
@@ -320,6 +320,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
320 | /// </summary> | 320 | /// </summary> |
321 | // ----------------------------------------------------------------- | 321 | // ----------------------------------------------------------------- |
322 | [ScriptInvocation] | 322 | [ScriptInvocation] |
323 | public UUID JsonRezAtRoot(UUID hostID, UUID scriptID, string item, Vector3 pos, Vector3 vel, Quaternion rot, string param) | ||
324 | { | ||
325 | UUID reqID = UUID.Random(); | ||
326 | Util.FireAndForget(o => DoJsonRezObject(hostID, scriptID, reqID, item, pos, vel, rot, param)); | ||
327 | return reqID; | ||
328 | } | ||
329 | |||
330 | // ----------------------------------------------------------------- | ||
331 | /// <summary> | ||
332 | /// | ||
333 | /// </summary> | ||
334 | // ----------------------------------------------------------------- | ||
335 | [ScriptInvocation] | ||
323 | public UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, string notecardIdentifier) | 336 | public UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, string notecardIdentifier) |
324 | { | 337 | { |
325 | UUID reqID = UUID.Random(); | 338 | UUID reqID = UUID.Random(); |
@@ -682,5 +695,103 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
682 | return path; | 695 | return path; |
683 | } | 696 | } |
684 | 697 | ||
698 | // ----------------------------------------------------------------- | ||
699 | /// <summary> | ||
700 | /// | ||
701 | /// </summary> | ||
702 | // ----------------------------------------------------------------- | ||
703 | private void DoJsonRezObject(UUID hostID, UUID scriptID, UUID reqID, string name, Vector3 pos, Vector3 vel, Quaternion rot, string param) | ||
704 | { | ||
705 | if (Double.IsNaN(rot.X) || Double.IsNaN(rot.Y) || Double.IsNaN(rot.Z) || Double.IsNaN(rot.W)) | ||
706 | { | ||
707 | GenerateRuntimeError("Invalid rez rotation"); | ||
708 | return; | ||
709 | } | ||
710 | |||
711 | SceneObjectGroup host = m_scene.GetSceneObjectGroup(hostID); | ||
712 | if (host == null) | ||
713 | { | ||
714 | GenerateRuntimeError(String.Format("Unable to find rezzing host '{0}'",hostID)); | ||
715 | return; | ||
716 | } | ||
717 | |||
718 | // hpos = host.RootPart.GetWorldPosition() | ||
719 | // float dist = (float)llVecDist(hpos, pos); | ||
720 | // if (dist > m_ScriptDistanceFactor * 10.0f) | ||
721 | // return; | ||
722 | |||
723 | TaskInventoryItem item = host.RootPart.Inventory.GetInventoryItem(name); | ||
724 | if (item == null) | ||
725 | { | ||
726 | GenerateRuntimeError(String.Format("Unable to find object to rez '{0}'",name)); | ||
727 | return; | ||
728 | } | ||
729 | |||
730 | if (item.InvType != (int)InventoryType.Object) | ||
731 | { | ||
732 | GenerateRuntimeError("Can't create requested object; object is missing from database"); | ||
733 | return; | ||
734 | } | ||
735 | |||
736 | List<SceneObjectGroup> objlist; | ||
737 | List<Vector3> veclist; | ||
738 | |||
739 | bool success = host.RootPart.Inventory.GetRezReadySceneObjects(item, out objlist, out veclist); | ||
740 | if (! success) | ||
741 | { | ||
742 | GenerateRuntimeError("Failed to create object"); | ||
743 | return; | ||
744 | } | ||
745 | |||
746 | int totalPrims = 0; | ||
747 | foreach (SceneObjectGroup group in objlist) | ||
748 | totalPrims += group.PrimCount; | ||
749 | |||
750 | if (! m_scene.Permissions.CanRezObject(totalPrims, item.OwnerID, pos)) | ||
751 | { | ||
752 | GenerateRuntimeError("Not allowed to create the object"); | ||
753 | return; | ||
754 | } | ||
755 | |||
756 | if (! m_scene.Permissions.BypassPermissions()) | ||
757 | { | ||
758 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
759 | host.RootPart.Inventory.RemoveInventoryItem(item.ItemID); | ||
760 | } | ||
761 | |||
762 | for (int i = 0; i < objlist.Count; i++) | ||
763 | { | ||
764 | SceneObjectGroup group = objlist[i]; | ||
765 | Vector3 curpos = pos + veclist[i]; | ||
766 | |||
767 | if (group.IsAttachment == false && group.RootPart.Shape.State != 0) | ||
768 | { | ||
769 | group.RootPart.AttachedPos = group.AbsolutePosition; | ||
770 | group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint; | ||
771 | } | ||
772 | |||
773 | group.FromPartID = host.RootPart.UUID; | ||
774 | m_scene.AddNewSceneObject(group, true, curpos, rot, vel); | ||
775 | |||
776 | UUID storeID = group.UUID; | ||
777 | if (! m_store.CreateStore(param, ref storeID)) | ||
778 | { | ||
779 | GenerateRuntimeError("Unable to create jsonstore for new object"); | ||
780 | continue; | ||
781 | } | ||
782 | |||
783 | // We can only call this after adding the scene object, since the scene object references the scene | ||
784 | // to find out if scripts should be activated at all. | ||
785 | group.RootPart.SetDieAtEdge(true); | ||
786 | group.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 3); | ||
787 | group.ResumeScripts(); | ||
788 | |||
789 | group.ScheduleGroupForFullUpdate(); | ||
790 | |||
791 | // send the reply back to the host object, use the integer param to indicate the number | ||
792 | // of remaining objects | ||
793 | m_comms.DispatchReply(scriptID, objlist.Count-i-1, group.RootPart.UUID.ToString(), reqID.ToString()); | ||
794 | } | ||
795 | } | ||
685 | } | 796 | } |
686 | } | 797 | } |