From 44b0c59ba9a1654ea0f7fadd4601b08d5cd9930b Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Thu, 6 Nov 2008 09:12:14 +0000 Subject: From: Christopher Yeoh The following patch implements osMakeNotecard as specified on the OpenSim website --- .../Shared/Api/Implementation/OSSL_Api.cs | 53 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 3 +- .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 ++ 3 files changed, 60 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 8a967ac..bd14a13 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Runtime.Remoting.Lifetime; +using System.Text; using OpenMetaverse; using Nini.Config; using OpenSim; @@ -959,5 +960,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api sceneOP.LocalId, new EventParams( "dataserver", resobj, new DetectParams[0])); } + + + public void osMakeNotecard(string notecardName, LSL_Types.list contents) + { + CheckThreatLevel(ThreatLevel.None, "osMakeNotecard"); + m_host.AddScriptLPS(1); + + // Create new asset + AssetBase asset = new AssetBase(); + asset.Name = notecardName; + asset.Description = "Script Generated Notecard"; + asset.Type = 7; + asset.FullID = UUID.Random(); + string notecardData = ""; + + for (int i = 0; i < contents.Length; i++) { + notecardData += contents.GetLSLStringItem(i) + "\n"; + } + + int textLength = notecardData.Length; + notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " + + textLength.ToString() + "\n" + notecardData + "}\n"; + + asset.Data = Encoding.ASCII.GetBytes(notecardData); + World.AssetCache.AddAsset(asset); + + // Create Task Entry + TaskInventoryItem taskItem=new TaskInventoryItem(); + + taskItem.ResetIDs(m_host.UUID); + taskItem.ParentID = m_host.UUID; + taskItem.CreationDate = (uint)Util.UnixTimeSinceEpoch(); + taskItem.Name = asset.Name; + taskItem.Description = asset.Description; + taskItem.Type = 7; + taskItem.InvType = 7; + taskItem.OwnerID = m_host.OwnerID; + taskItem.CreatorID = m_host.OwnerID; + taskItem.BasePermissions = (uint)PermissionMask.All; + taskItem.CurrentPermissions = (uint)PermissionMask.All; + taskItem.EveryonePermissions = (uint)PermissionMask.All; + taskItem.NextPermissions = (uint)PermissionMask.All; + taskItem.GroupID = m_host.GroupID; + taskItem.GroupPermissions = 0; + taskItem.Flags = 0; + taskItem.PermsGranter = UUID.Zero; + taskItem.PermsMask = 0; + taskItem.AssetID = asset.FullID; + + m_host.AddInventoryItem(taskItem); + + } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index b1749f9..2e02bd1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -95,6 +95,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces Hashtable osParseJSON(string JSON); void osMessageObject(key objectUUID,string message); - + + void osMakeNotecard(string notecardName, LSL_Types.list contents); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 35a8830..01b2d86 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -237,6 +237,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osMessageObject(objectUUID,message); } + public void osMakeNotecard(string notecardName, LSL_Types.list contents) + { + m_OSSL_Functions.osMakeNotecard(notecardName, contents); + } + public OSSLPrim Prim; [Serializable] -- cgit v1.1